Makefile.rump revision 1.64
11.64Spooka#	$NetBSD: Makefile.rump,v 1.64 2012/11/13 19:12:42 pooka 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.57SpookaCPPFLAGS+=	-D_RUMPKERNEL
141.56Spooka.else
151.56SpookaCPPFLAGS+=	-D_RUMP_NATIVE_ABI
161.18Spooka.endif
171.18Spooka
181.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
191.63Sjoerg.if (defined(HAVE_GCC) && ${HAVE_GCC} >= 3) || defined(HAVE_LLVM)
201.61SmattCFLAGS+=	-Wsign-compare
211.61SmattCFLAGS+=	-Wno-pointer-sign -Wno-attributes
221.61SmattCFLAGS+=	-std=gnu99
231.61Smatt.endif
241.50SpookaCWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
251.23SpookaCPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
261.21SpookaCPPFLAGS+=	-DMAXUSERS=32
271.60SmattCPPFLAGS+=	-DCOMPAT_50=1
281.38SpookaCPPFLAGS+=	-DDEBUGPRINT
291.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
301.58SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include -isystem ${RUMPTOP}/../arch
311.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
321.21SpookaCPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
331.58SpookaCPPFLAGS+=	-nostdinc -isystem ${RUMPTOP}/..
341.45SpookaLDFLAGS+=	-T ${RUMPTOP}/ldscript.rump
351.62Spooka
361.62SpookaRUMP_DIAGNOSTIC?=yes
371.62Spooka.if ${RUMP_DIAGNOSTIC} == "yes"
381.62SpookaCPPFLAGS+=	-DDIAGNOSTIC
391.62Spooka.endif
401.62Spooka
411.62Spooka.ifdef RUMP_DEBUG
421.62SpookaCPPFLAGS+=	-DDEBUG
431.62Spooka.endif
441.1Spooka
451.59Spooka.ifdef RUMP_LOCKDEBUG
461.59SpookaCPPFLAGS+=	-DLOCKDEBUG
471.59Spooka.endif
481.59Spooka
491.42Spooka# kernel libs should not get linked against libc
501.43Spooka# XXX: actually, we would like to enable this but cannot, since it
511.43Spooka# also leaves out libgcc, it causes problems on some platforms.
521.43Spooka# revisit some day.
531.43Spooka#LDFLAGS+=	-nodefaultlibs
541.42Spooka
551.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
561.64Spooka# aaand make sure cc doesn't source files any wild ideas
571.39SpookaCPPFLAGS+=	-D__NetBSD__
581.64SpookaCPPFLAGS+=	-Ulinux -U__linux -U__linux__ -U__gnu_linux__
591.39Spooka
601.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
611.11Spooka
621.13Spooka# workaround: evbppc is not a well-defined arch
631.13Spooka.if (${MACHINE} == "evbppc")
641.16SpookaCPPFLAGS+=	-DPPC_OEA
651.13Spooka.endif
661.13Spooka
671.25Spooka# If this file changes, we need a full rebuild
681.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
691.24Spooka
701.24Spooka#
711.24Spooka# Rename library symbols before use.  If a symbol does not already belong
721.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
731.24Spooka# avoids accidentally linking any kernel symbol against host platform
741.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
751.24Spooka# the GOT, which are more a property of the compiler than the kernel.
761.24Spooka#
771.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
781.29Spooka# satisfied by the toolchain itself when the program is linked.
791.29Spooka# Unfortunately, we do not know which of the symbols are generated by
801.29Spooka# the toolchain.  Worse, they vary from platform to platform and
811.29Spooka# toolchain to toolchain.  The good news, however, is that this will
821.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
831.29Spooka# a quirktable here.
841.46Spooka#
851.46Spooka# We also allow calling ourselves externally with e.g.:
861.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
871.46Spooka#
881.29Spooka.if ${MACHINE_CPU} == "mips"
891.29Spooka_SYMQUIRK='|_gp_disp'
901.29Spooka.elif ${MACHINE_CPU} == "hppa"
911.29Spooka_SYMQUIRK='|\$$\$$'
921.54Smrg.elif ${MACHINE_ARCH} == "powerpc64"
931.55Smrg_SYMQUIRK="|PF_funcs"
941.55Smrg.endif
951.55Smrg
961.55Smrg#
971.55Smrg# Prefix quirks.  At least one toolchain generates global
981.55Smrg# symbols with prefixes which really need to remain as prefixes
991.55Smrg# (i.e. the '.' on the front of some ppc64 globals).  The
1001.55Smrg# way to know if you have the problem is if you get later
1011.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
1021.55Smrg# the 'X' part was added by the toolchain and will need to
1031.55Smrg# be mentioned here.
1041.55Smrg# 
1051.55Smrg.if ${MACHINE_ARCH} == "powerpc64"
1061.55Smrg_PQ="\.?"
1071.55Smrg.else
1081.55Smrg_PQ=
1091.29Spooka.endif
1101.46Spooka
1111.46Spookarump_symren: __archivebuild
1121.46Spooka.if !defined(RUMP_SYMREN)
1131.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
1141.46Spooka	@false
1151.46Spooka.endif
1161.46Spooka
1171.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
1181.46Spooka# build the arrrrchive.  otherwise just rename symbols.
1191.24Spooka__archivebuild: .USE
1201.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
1211.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
1221.46Spooka	@false
1231.46Spooka.endif
1241.46Spooka.if defined(RUMP_SYMREN)
1251.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
1261.46Spooka.else
1271.24Spooka	${_MKTARGET_BUILD}
1281.24Spooka	rm -f ${.TARGET}
1291.34Spooka	${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
1301.46Spooka.endif
1311.46Spooka	${NM} -go ${RUMP_SYMREN:U${.TARGET}} | ${TOOL_AWK} '	\
1321.55Smrg	    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
1331.55Smrg	      {s = $$NF; sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}' \
1341.24Spooka	    | sort | uniq  > renametab.${.TARGET}
1351.37Spooka	${OBJCOPY} --preserve-dates --redefine-syms \
1361.46Spooka	    renametab.${.TARGET} ${RUMP_SYMREN:U${.TARGET}}
1371.24Spooka	rm -f renametab.${.TARGET}
1381.46Spooka.if !defined(RUMP_SYMREN)
1391.36Sperry	${AR} ${_ARRANFL} ${.TARGET}
1401.46Spooka.endif
1411.47Spooka
1421.53Spooka_BSD_IOCONF_MK_USER_=1
1431.53Spooka.include <bsd.ioconf.mk>
1441.47Spooka
1451.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
1461.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
147