Makefile.rump revision 1.89
11.89Spooka#	$NetBSD: Makefile.rump,v 1.89 2013/12/09 17:57:11 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.66SpookaCPPFLAGS+=	-DMAXUSERS=32
191.84SpookaCPPFLAGS+=	-DCOMPAT_50=1 -DCOMPAT_60=1
201.66Spooka
211.66SpookaCPPFLAGS+=	-nostdinc
221.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
231.66Spooka
241.50SpookaCWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
251.23SpookaCPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
261.38SpookaCPPFLAGS+=	-DDEBUGPRINT
271.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
281.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include
291.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
301.21SpookaCPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
311.65Spooka
321.65Spooka.ifdef NEED_ISYSTEM
331.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/../arch
341.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/..
351.65Spooka.else
361.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../arch
371.65SpookaCPPFLAGS+=	-I${RUMPTOP}/..
381.65Spooka.endif
391.65Spooka
401.79SpookaRUMP_LDSCRIPT?=yes
411.79Spooka.if ${RUMP_LDSCRIPT} != "no"
421.72Spooka# my ld or yours?
431.72Spooka.ifdef HAVE_SUN_LD
441.72SpookaLDFLAGS+=	-Wl,-M ${RUMPTOP}/ldscript_sun.rump
451.72SpookaSRCS+=		linksyms_sun.c
461.74Spooka.PATH:		${RUMPTOP}
471.72Spooka.else
481.85SjoergLDFLAGS+=	-Wl,-T,${RUMPTOP}/ldscript.rump
491.73Spooka.endif
501.79Spooka.endif
511.62Spooka
521.62SpookaRUMP_DIAGNOSTIC?=yes
531.62Spooka.if ${RUMP_DIAGNOSTIC} == "yes"
541.62SpookaCPPFLAGS+=	-DDIAGNOSTIC
551.62Spooka.endif
561.62Spooka
571.62Spooka.ifdef RUMP_DEBUG
581.62SpookaCPPFLAGS+=	-DDEBUG
591.62Spooka.endif
601.1Spooka
611.59Spooka.ifdef RUMP_LOCKDEBUG
621.59SpookaCPPFLAGS+=	-DLOCKDEBUG
631.59Spooka.endif
641.59Spooka
651.89SpookaRUMP_KTRACE?=yes
661.89Spooka.if ${RUMP_KTRACE} == "yes"
671.89SpookaCPPFLAGS+=	-DKTRACE
681.89Spooka.endif
691.89Spooka
701.42Spooka# kernel libs should not get linked against libc
711.43Spooka# XXX: actually, we would like to enable this but cannot, since it
721.43Spooka# also leaves out libgcc, it causes problems on some platforms.
731.43Spooka# revisit some day.
741.43Spooka#LDFLAGS+=	-nodefaultlibs
751.42Spooka
761.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
771.67Spooka# also, give those builds a way to undef the local compiler's macros
781.67SpookaCPPFLAGS+=	-D__NetBSD__ ${RUMPKERN_UNDEF}
791.39Spooka
801.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
811.11Spooka
821.13Spooka# workaround: evbppc is not a well-defined arch
831.13Spooka.if (${MACHINE} == "evbppc")
841.16SpookaCPPFLAGS+=	-DPPC_OEA
851.13Spooka.endif
861.13Spooka
871.25Spooka# If this file changes, we need a full rebuild
881.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
891.24Spooka
901.24Spooka#
911.69Spooka# Support for component-specific hypercalls
921.69Spooka#
931.69Spooka
941.82Spooka# XXX: Warning flags are not in CWARNFLAGS.  Manually add a few important ones.
951.75Schristos
961.86Spooka.ifdef RUMPCOMP_USER && !defined(RUMPKERN_ONLY)
971.75Schristos.if empty(DESTDIR)
981.75SchristosDESTDIR=/
991.75Schristos.endif
1001.75SchristosBUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR}
1011.82SpookaRUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:}
1021.70Spookarumpcomp_user.d: rumpcomp_user.c
1031.69Spooka	${_MKTARGET_CREATE}
1041.80Spooka	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*rumpcomp_user.c}
1051.69Spooka
1061.70Spookarumpcomp_user.o: rumpcomp_user.c
1071.69Spooka	${_MKTARGET_COMPILE}
1081.82Spooka	${CC} -o ${.TARGET} ${DBG} ${CWARNFLAGS} ${RUMPCOMP_USER_WERROR} -Wall -Wmissing-prototypes ${BUILDRUMP_CPPFLAGS} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.ALLSRC:O:u:M*rumpcomp_user.c}
1091.69Spooka
1101.70Spookarumpcomp_user.pico: rumpcomp_user.c
1111.69Spooka	${_MKTARGET_COMPILE}
1121.82Spooka	${CC} -o ${.TARGET} -fPIC -DPIC ${DBG} ${CWARNFLAGS} ${RUMPCOMP_USER_WERROR} -Wall -Wmissing-prototypes ${BUILDRUMP_CPPFLAGS} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.ALLSRC:O:u:M*rumpcomp_user.c}
1131.69Spooka
1141.70Spookarumpcomp_user.po: rumpcomp_user.c
1151.69Spooka	${_MKTARGET_COMPILE}
1161.83Spooka	${CC} -o ${.TARGET} ${PROFFLAGS} -pg ${DBG} ${CWARNFLAGS} ${RUMPCOMP_USER_WERROR} -Wall -Wmissing-prototypes ${BUILDRUMP_CPPFLAGS} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.ALLSRC:O:u:M*rumpcomp_user.c}
1171.69Spooka
1181.87SpookaRUMPOBJ_NORENAME+=rumpcomp_user.*o
1191.70SpookaSRCS+=rumpcomp_user.c
1201.69Spooka.endif
1211.69Spooka
1221.69Spooka#
1231.24Spooka# Rename library symbols before use.  If a symbol does not already belong
1241.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
1251.24Spooka# avoids accidentally linking any kernel symbol against host platform
1261.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
1271.24Spooka# the GOT, which are more a property of the compiler than the kernel.
1281.24Spooka#
1291.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
1301.29Spooka# satisfied by the toolchain itself when the program is linked.
1311.29Spooka# Unfortunately, we do not know which of the symbols are generated by
1321.29Spooka# the toolchain.  Worse, they vary from platform to platform and
1331.29Spooka# toolchain to toolchain.  The good news, however, is that this will
1341.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
1351.29Spooka# a quirktable here.
1361.46Spooka#
1371.46Spooka# We also allow calling ourselves externally with e.g.:
1381.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
1391.46Spooka#
1401.29Spooka.if ${MACHINE_CPU} == "mips"
1411.29Spooka_SYMQUIRK='|_gp_disp'
1421.29Spooka.elif ${MACHINE_CPU} == "hppa"
1431.29Spooka_SYMQUIRK='|\$$\$$'
1441.54Smrg.elif ${MACHINE_ARCH} == "powerpc64"
1451.55Smrg_SYMQUIRK="|PF_funcs"
1461.55Smrg.endif
1471.55Smrg
1481.55Smrg#
1491.55Smrg# Prefix quirks.  At least one toolchain generates global
1501.55Smrg# symbols with prefixes which really need to remain as prefixes
1511.55Smrg# (i.e. the '.' on the front of some ppc64 globals).  The
1521.55Smrg# way to know if you have the problem is if you get later
1531.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
1541.55Smrg# the 'X' part was added by the toolchain and will need to
1551.55Smrg# be mentioned here.
1561.55Smrg# 
1571.55Smrg.if ${MACHINE_ARCH} == "powerpc64"
1581.55Smrg_PQ="\.?"
1591.55Smrg.else
1601.55Smrg_PQ=
1611.29Spooka.endif
1621.46Spooka
1631.46Spookarump_symren: __archivebuild
1641.46Spooka.if !defined(RUMP_SYMREN)
1651.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
1661.46Spooka	@false
1671.46Spooka.endif
1681.46Spooka
1691.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
1701.46Spooka# build the arrrrchive.  otherwise just rename symbols.
1711.24Spooka__archivebuild: .USE
1721.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
1731.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
1741.46Spooka	@false
1751.46Spooka.endif
1761.46Spooka.if defined(RUMP_SYMREN)
1771.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
1781.46Spooka.else
1791.24Spooka	${_MKTARGET_BUILD}
1801.24Spooka	rm -f ${.TARGET}
1811.46Spooka.endif
1821.87Spooka	for obj in ${RUMP_SYMREN:U${.ALLSRC:N${RUMPOBJ_NORENAME}}}; do \
1831.69Spooka		${NM} -go $${obj} | ${TOOL_AWK} ' \
1841.69Spooka		    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
1851.69Spooka		      {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
1861.69Spooka		    | sort | uniq  > renametab.$${obj}; \
1871.69Spooka		${OBJCOPY} --preserve-dates --redefine-syms \
1881.69Spooka		    renametab.$${obj} $${obj}; \
1891.69Spooka		rm -f renametab.$${obj}; \
1901.69Spooka	done
1911.46Spooka.if !defined(RUMP_SYMREN)
1921.69Spooka	${AR} ${_ARFL} ${.TARGET} \
1931.69Spooka	    `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
1941.46Spooka.endif
1951.47Spooka
1961.53Spooka_BSD_IOCONF_MK_USER_=1
1971.53Spooka.include <bsd.ioconf.mk>
1981.47Spooka
1991.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
2001.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
201