Makefile.rump revision 1.47
11.47Spooka#	$NetBSD: Makefile.rump,v 1.47 2010/02/03 21:11:24 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.18Spooka# use kernel ABI instead of rump ABI (needs md code)
101.31She.ifndef RUMPKMOD
111.18SpookaCPPFLAGS:=	-I${RUMPTOP}/include ${CPPFLAGS}
121.18Spooka.endif
131.18Spooka
141.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
151.40SpookaCWARNFLAGS+=	-Wno-format-zero-length
161.32SpookaCPPFLAGS+=	-D_RUMPKERNEL
171.23SpookaCPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
181.21SpookaCPPFLAGS+=	-DMAXUSERS=32
191.17SpookaCPPFLAGS+=	-DDIAGNOSTIC
201.32SpookaCPPFLAGS+=	-DCOMPAT_50
211.38SpookaCPPFLAGS+=	-DDEBUGPRINT
221.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
231.14SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include -I${RUMPTOP}/../arch
241.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
251.21SpookaCPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
261.10SpookaCPPFLAGS+=	-nostdinc -I${RUMPTOP}/..
271.45SpookaLDFLAGS+=	-T ${RUMPTOP}/ldscript.rump
281.10Spooka#CPPFLAGS+=	-DDEBUG
291.1Spooka
301.42Spooka# kernel libs should not get linked against libc
311.43Spooka# XXX: actually, we would like to enable this but cannot, since it
321.43Spooka# also leaves out libgcc, it causes problems on some platforms.
331.43Spooka# revisit some day.
341.43Spooka#LDFLAGS+=	-nodefaultlibs
351.42Spooka
361.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
371.39SpookaCPPFLAGS+=	-D__NetBSD__
381.39Spooka
391.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
401.11Spooka
411.13Spooka# workaround: evbppc is not a well-defined arch
421.13Spooka.if (${MACHINE} == "evbppc")
431.16SpookaCPPFLAGS+=	-DPPC_OEA
441.13Spooka.endif
451.13Spooka
461.25Spooka# If this file changes, we need a full rebuild
471.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
481.24Spooka
491.24Spooka#
501.24Spooka# Rename library symbols before use.  If a symbol does not already belong
511.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
521.24Spooka# avoids accidentally linking any kernel symbol against host platform
531.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
541.24Spooka# the GOT, which are more a property of the compiler than the kernel.
551.24Spooka#
561.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
571.29Spooka# satisfied by the toolchain itself when the program is linked.
581.29Spooka# Unfortunately, we do not know which of the symbols are generated by
591.29Spooka# the toolchain.  Worse, they vary from platform to platform and
601.29Spooka# toolchain to toolchain.  The good news, however, is that this will
611.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
621.29Spooka# a quirktable here.
631.46Spooka#
641.46Spooka# We also allow calling ourselves externally with e.g.:
651.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
661.46Spooka#
671.29Spooka.if ${MACHINE_CPU} == "mips"
681.29Spooka_SYMQUIRK='|_gp_disp'
691.29Spooka.elif ${MACHINE_CPU} == "hppa"
701.29Spooka_SYMQUIRK='|\$$\$$'
711.29Spooka.endif
721.46Spooka
731.46Spookarump_symren: __archivebuild
741.46Spooka.if !defined(RUMP_SYMREN)
751.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
761.46Spooka	@false
771.46Spooka.endif
781.46Spooka
791.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
801.46Spooka# build the arrrrchive.  otherwise just rename symbols.
811.24Spooka__archivebuild: .USE
821.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
831.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
841.46Spooka	@false
851.46Spooka.endif
861.46Spooka.if defined(RUMP_SYMREN)
871.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
881.46Spooka.else
891.24Spooka	${_MKTARGET_BUILD}
901.24Spooka	rm -f ${.TARGET}
911.34Spooka	${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
921.46Spooka.endif
931.46Spooka	${NM} -go ${RUMP_SYMREN:U${.TARGET}} | ${TOOL_AWK} '	\
941.29Spooka	    $$NF!~/^(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
951.24Spooka	      {printf "%s rumpns_%s\n", $$NF, $$NF}' \
961.24Spooka	    | sort | uniq  > renametab.${.TARGET}
971.37Spooka	${OBJCOPY} --preserve-dates --redefine-syms \
981.46Spooka	    renametab.${.TARGET} ${RUMP_SYMREN:U${.TARGET}}
991.24Spooka	rm -f renametab.${.TARGET}
1001.46Spooka.if !defined(RUMP_SYMREN)
1011.36Sperry	${AR} ${_ARRANFL} ${.TARGET}
1021.46Spooka.endif
1031.47Spooka
1041.47Spooka# If IOCONFIG is defined, autocreate ioconf.c and locators.h.
1051.47Spooka# This is useful mainly for devices.
1061.47Spooka.if !empty(IOCONFIG)
1071.47Spookaioconf.c: ${IOCONFIG}
1081.47Spooka	${TOOL_CONFIG} -b ${.OBJDIR} -s ${RUMPTOP}/.. ${IOCONFIG} 
1091.47Spooka	# config doesn't change the files if they're unchanged.  however,
1101.47Spooka	# here we want to satisfy our make dependency, so force a
1111.47Spooka	# timestamp update
1121.47Spooka	touch ioconf.c locators.h
1131.47Spooka
1141.47SpookaCLEANFILES+= ioconf.c locators.h
1151.47SpookaDPSRCS+= ioconf.c locators.h
1161.47Spooka.endif
1171.47Spooka
1181.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
1191.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
120