Makefile.rump revision 1.55
11.55Smrg#	$NetBSD: Makefile.rump,v 1.55 2010/03/28 04:29:34 mrg Exp $
21.1Spooka#
31.1Spooka
41.33SlukemWARNS?=		3	# XXX: src/sys won't compile with -Wsign-compare yet
51.10SpookaNOLINT=		# kernel code
61.1Spooka
71.20Spooka.include <bsd.own.mk>
81.20Spooka
91.51Spooka# If RUMPKMOD is _not_ set (only on capable archs, from bsd.own.mk),
101.51Spooka# use rump ABI instead of the NetBSD kernel ABI.
111.31She.ifndef RUMPKMOD
121.18SpookaCPPFLAGS:=	-I${RUMPTOP}/include ${CPPFLAGS}
131.18Spooka.endif
141.18Spooka
151.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
161.50SpookaCWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
171.32SpookaCPPFLAGS+=	-D_RUMPKERNEL
181.23SpookaCPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
191.21SpookaCPPFLAGS+=	-DMAXUSERS=32
201.17SpookaCPPFLAGS+=	-DDIAGNOSTIC
211.32SpookaCPPFLAGS+=	-DCOMPAT_50
221.38SpookaCPPFLAGS+=	-DDEBUGPRINT
231.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
241.14SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include -I${RUMPTOP}/../arch
251.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
261.21SpookaCPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
271.10SpookaCPPFLAGS+=	-nostdinc -I${RUMPTOP}/..
281.45SpookaLDFLAGS+=	-T ${RUMPTOP}/ldscript.rump
291.10Spooka#CPPFLAGS+=	-DDEBUG
301.1Spooka
311.42Spooka# kernel libs should not get linked against libc
321.43Spooka# XXX: actually, we would like to enable this but cannot, since it
331.43Spooka# also leaves out libgcc, it causes problems on some platforms.
341.43Spooka# revisit some day.
351.43Spooka#LDFLAGS+=	-nodefaultlibs
361.42Spooka
371.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
381.39SpookaCPPFLAGS+=	-D__NetBSD__
391.39Spooka
401.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
411.11Spooka
421.13Spooka# workaround: evbppc is not a well-defined arch
431.13Spooka.if (${MACHINE} == "evbppc")
441.16SpookaCPPFLAGS+=	-DPPC_OEA
451.13Spooka.endif
461.13Spooka
471.25Spooka# If this file changes, we need a full rebuild
481.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
491.24Spooka
501.24Spooka#
511.24Spooka# Rename library symbols before use.  If a symbol does not already belong
521.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
531.24Spooka# avoids accidentally linking any kernel symbol against host platform
541.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
551.24Spooka# the GOT, which are more a property of the compiler than the kernel.
561.24Spooka#
571.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
581.29Spooka# satisfied by the toolchain itself when the program is linked.
591.29Spooka# Unfortunately, we do not know which of the symbols are generated by
601.29Spooka# the toolchain.  Worse, they vary from platform to platform and
611.29Spooka# toolchain to toolchain.  The good news, however, is that this will
621.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
631.29Spooka# a quirktable here.
641.46Spooka#
651.46Spooka# We also allow calling ourselves externally with e.g.:
661.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
671.46Spooka#
681.29Spooka.if ${MACHINE_CPU} == "mips"
691.29Spooka_SYMQUIRK='|_gp_disp'
701.29Spooka.elif ${MACHINE_CPU} == "hppa"
711.29Spooka_SYMQUIRK='|\$$\$$'
721.54Smrg.elif ${MACHINE_ARCH} == "powerpc64"
731.55Smrg_SYMQUIRK="|PF_funcs"
741.55Smrg.endif
751.55Smrg
761.55Smrg#
771.55Smrg# Prefix quirks.  At least one toolchain generates global
781.55Smrg# symbols with prefixes which really need to remain as prefixes
791.55Smrg# (i.e. the '.' on the front of some ppc64 globals).  The
801.55Smrg# way to know if you have the problem is if you get later
811.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
821.55Smrg# the 'X' part was added by the toolchain and will need to
831.55Smrg# be mentioned here.
841.55Smrg# 
851.55Smrg.if ${MACHINE_ARCH} == "powerpc64"
861.55Smrg_PQ="\.?"
871.55Smrg.else
881.55Smrg_PQ=
891.29Spooka.endif
901.46Spooka
911.46Spookarump_symren: __archivebuild
921.46Spooka.if !defined(RUMP_SYMREN)
931.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
941.46Spooka	@false
951.46Spooka.endif
961.46Spooka
971.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
981.46Spooka# build the arrrrchive.  otherwise just rename symbols.
991.24Spooka__archivebuild: .USE
1001.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
1011.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
1021.46Spooka	@false
1031.46Spooka.endif
1041.46Spooka.if defined(RUMP_SYMREN)
1051.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
1061.46Spooka.else
1071.24Spooka	${_MKTARGET_BUILD}
1081.24Spooka	rm -f ${.TARGET}
1091.34Spooka	${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
1101.46Spooka.endif
1111.46Spooka	${NM} -go ${RUMP_SYMREN:U${.TARGET}} | ${TOOL_AWK} '	\
1121.55Smrg	    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
1131.55Smrg	      {s = $$NF; sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}' \
1141.24Spooka	    | sort | uniq  > renametab.${.TARGET}
1151.37Spooka	${OBJCOPY} --preserve-dates --redefine-syms \
1161.46Spooka	    renametab.${.TARGET} ${RUMP_SYMREN:U${.TARGET}}
1171.24Spooka	rm -f renametab.${.TARGET}
1181.46Spooka.if !defined(RUMP_SYMREN)
1191.36Sperry	${AR} ${_ARRANFL} ${.TARGET}
1201.46Spooka.endif
1211.47Spooka
1221.53Spooka_BSD_IOCONF_MK_USER_=1
1231.53Spooka.include <bsd.ioconf.mk>
1241.47Spooka
1251.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
1261.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
127