Makefile.rump revision 1.54
11.54Smrg#	$NetBSD: Makefile.rump,v 1.54 2010/03/22 05:39:00 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.54Smrg_SYMQUIRK='|\.(rump|RUMP)'
741.29Spooka.endif
751.46Spooka
761.46Spookarump_symren: __archivebuild
771.46Spooka.if !defined(RUMP_SYMREN)
781.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
791.46Spooka	@false
801.46Spooka.endif
811.46Spooka
821.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
831.46Spooka# build the arrrrchive.  otherwise just rename symbols.
841.24Spooka__archivebuild: .USE
851.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
861.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
871.46Spooka	@false
881.46Spooka.endif
891.46Spooka.if defined(RUMP_SYMREN)
901.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
911.46Spooka.else
921.24Spooka	${_MKTARGET_BUILD}
931.24Spooka	rm -f ${.TARGET}
941.34Spooka	${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
951.46Spooka.endif
961.46Spooka	${NM} -go ${RUMP_SYMREN:U${.TARGET}} | ${TOOL_AWK} '	\
971.29Spooka	    $$NF!~/^(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
981.24Spooka	      {printf "%s rumpns_%s\n", $$NF, $$NF}' \
991.24Spooka	    | sort | uniq  > renametab.${.TARGET}
1001.37Spooka	${OBJCOPY} --preserve-dates --redefine-syms \
1011.46Spooka	    renametab.${.TARGET} ${RUMP_SYMREN:U${.TARGET}}
1021.24Spooka	rm -f renametab.${.TARGET}
1031.46Spooka.if !defined(RUMP_SYMREN)
1041.36Sperry	${AR} ${_ARRANFL} ${.TARGET}
1051.46Spooka.endif
1061.47Spooka
1071.53Spooka_BSD_IOCONF_MK_USER_=1
1081.53Spooka.include <bsd.ioconf.mk>
1091.47Spooka
1101.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
1111.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
112