Makefile.rump revision 1.90
11.90Spooka#	$NetBSD: Makefile.rump,v 1.90 2014/03/10 22:38:53 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.90Spooka# Use NetBSD kernel ABI by default on x86 archs.  Performance-related
101.90Spooka# compile-time options may override this at a later date.
111.90Spooka.if ${MACHINE_ARCH} == "i386" || \
121.90Spooka    ${MACHINE_ARCH} == "x86_64"
131.90Spooka_RUMP_NATIVEABI= yes
141.90SpookaCPPFLAGS+=	-D_RUMP_NATIVE_ABI
151.90Spooka.else
161.90Spooka_RUMP_NATIVEABI= no
171.18SpookaCPPFLAGS:=	-I${RUMPTOP}/include ${CPPFLAGS}
181.57SpookaCPPFLAGS+=	-D_RUMPKERNEL
191.18Spooka.endif
201.18Spooka
211.66SpookaCPPFLAGS+=	-DMAXUSERS=32
221.84SpookaCPPFLAGS+=	-DCOMPAT_50=1 -DCOMPAT_60=1
231.66Spooka
241.66SpookaCPPFLAGS+=	-nostdinc
251.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
261.66Spooka
271.50SpookaCWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
281.23SpookaCPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
291.38SpookaCPPFLAGS+=	-DDEBUGPRINT
301.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
311.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include
321.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
331.21SpookaCPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
341.65Spooka
351.65Spooka.ifdef NEED_ISYSTEM
361.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/../arch
371.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/..
381.65Spooka.else
391.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../arch
401.65SpookaCPPFLAGS+=	-I${RUMPTOP}/..
411.65Spooka.endif
421.65Spooka
431.79SpookaRUMP_LDSCRIPT?=yes
441.79Spooka.if ${RUMP_LDSCRIPT} != "no"
451.72Spooka# my ld or yours?
461.72Spooka.ifdef HAVE_SUN_LD
471.72SpookaLDFLAGS+=	-Wl,-M ${RUMPTOP}/ldscript_sun.rump
481.72SpookaSRCS+=		linksyms_sun.c
491.74Spooka.PATH:		${RUMPTOP}
501.72Spooka.else
511.85SjoergLDFLAGS+=	-Wl,-T,${RUMPTOP}/ldscript.rump
521.73Spooka.endif
531.79Spooka.endif
541.62Spooka
551.62SpookaRUMP_DIAGNOSTIC?=yes
561.62Spooka.if ${RUMP_DIAGNOSTIC} == "yes"
571.62SpookaCPPFLAGS+=	-DDIAGNOSTIC
581.62Spooka.endif
591.62Spooka
601.62Spooka.ifdef RUMP_DEBUG
611.62SpookaCPPFLAGS+=	-DDEBUG
621.62Spooka.endif
631.1Spooka
641.59Spooka.ifdef RUMP_LOCKDEBUG
651.59SpookaCPPFLAGS+=	-DLOCKDEBUG
661.59Spooka.endif
671.59Spooka
681.89SpookaRUMP_KTRACE?=yes
691.89Spooka.if ${RUMP_KTRACE} == "yes"
701.89SpookaCPPFLAGS+=	-DKTRACE
711.89Spooka.endif
721.89Spooka
731.42Spooka# kernel libs should not get linked against libc
741.43Spooka# XXX: actually, we would like to enable this but cannot, since it
751.43Spooka# also leaves out libgcc, it causes problems on some platforms.
761.43Spooka# revisit some day.
771.43Spooka#LDFLAGS+=	-nodefaultlibs
781.42Spooka
791.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
801.67Spooka# also, give those builds a way to undef the local compiler's macros
811.67SpookaCPPFLAGS+=	-D__NetBSD__ ${RUMPKERN_UNDEF}
821.39Spooka
831.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
841.11Spooka
851.13Spooka# workaround: evbppc is not a well-defined arch
861.13Spooka.if (${MACHINE} == "evbppc")
871.16SpookaCPPFLAGS+=	-DPPC_OEA
881.13Spooka.endif
891.13Spooka
901.25Spooka# If this file changes, we need a full rebuild
911.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
921.24Spooka
931.24Spooka#
941.69Spooka# Support for component-specific hypercalls
951.69Spooka#
961.69Spooka
971.82Spooka# XXX: Warning flags are not in CWARNFLAGS.  Manually add a few important ones.
981.75Schristos
991.86Spooka.ifdef RUMPCOMP_USER && !defined(RUMPKERN_ONLY)
1001.75Schristos.if empty(DESTDIR)
1011.75SchristosDESTDIR=/
1021.75Schristos.endif
1031.75SchristosBUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR}
1041.82SpookaRUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:}
1051.70Spookarumpcomp_user.d: rumpcomp_user.c
1061.69Spooka	${_MKTARGET_CREATE}
1071.80Spooka	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*rumpcomp_user.c}
1081.69Spooka
1091.70Spookarumpcomp_user.o: rumpcomp_user.c
1101.69Spooka	${_MKTARGET_COMPILE}
1111.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}
1121.69Spooka
1131.70Spookarumpcomp_user.pico: rumpcomp_user.c
1141.69Spooka	${_MKTARGET_COMPILE}
1151.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}
1161.69Spooka
1171.70Spookarumpcomp_user.po: rumpcomp_user.c
1181.69Spooka	${_MKTARGET_COMPILE}
1191.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}
1201.69Spooka
1211.87SpookaRUMPOBJ_NORENAME+=rumpcomp_user.*o
1221.70SpookaSRCS+=rumpcomp_user.c
1231.69Spooka.endif
1241.69Spooka
1251.69Spooka#
1261.24Spooka# Rename library symbols before use.  If a symbol does not already belong
1271.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
1281.24Spooka# avoids accidentally linking any kernel symbol against host platform
1291.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
1301.24Spooka# the GOT, which are more a property of the compiler than the kernel.
1311.24Spooka#
1321.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
1331.29Spooka# satisfied by the toolchain itself when the program is linked.
1341.29Spooka# Unfortunately, we do not know which of the symbols are generated by
1351.29Spooka# the toolchain.  Worse, they vary from platform to platform and
1361.29Spooka# toolchain to toolchain.  The good news, however, is that this will
1371.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
1381.29Spooka# a quirktable here.
1391.46Spooka#
1401.46Spooka# We also allow calling ourselves externally with e.g.:
1411.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
1421.46Spooka#
1431.29Spooka.if ${MACHINE_CPU} == "mips"
1441.29Spooka_SYMQUIRK='|_gp_disp'
1451.29Spooka.elif ${MACHINE_CPU} == "hppa"
1461.29Spooka_SYMQUIRK='|\$$\$$'
1471.54Smrg.elif ${MACHINE_ARCH} == "powerpc64"
1481.55Smrg_SYMQUIRK="|PF_funcs"
1491.55Smrg.endif
1501.55Smrg
1511.55Smrg#
1521.55Smrg# Prefix quirks.  At least one toolchain generates global
1531.55Smrg# symbols with prefixes which really need to remain as prefixes
1541.55Smrg# (i.e. the '.' on the front of some ppc64 globals).  The
1551.55Smrg# way to know if you have the problem is if you get later
1561.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
1571.55Smrg# the 'X' part was added by the toolchain and will need to
1581.55Smrg# be mentioned here.
1591.55Smrg# 
1601.55Smrg.if ${MACHINE_ARCH} == "powerpc64"
1611.55Smrg_PQ="\.?"
1621.55Smrg.else
1631.55Smrg_PQ=
1641.29Spooka.endif
1651.46Spooka
1661.46Spookarump_symren: __archivebuild
1671.46Spooka.if !defined(RUMP_SYMREN)
1681.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
1691.46Spooka	@false
1701.46Spooka.endif
1711.46Spooka
1721.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
1731.46Spooka# build the arrrrchive.  otherwise just rename symbols.
1741.24Spooka__archivebuild: .USE
1751.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
1761.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
1771.46Spooka	@false
1781.46Spooka.endif
1791.46Spooka.if defined(RUMP_SYMREN)
1801.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
1811.46Spooka.else
1821.24Spooka	${_MKTARGET_BUILD}
1831.24Spooka	rm -f ${.TARGET}
1841.46Spooka.endif
1851.87Spooka	for obj in ${RUMP_SYMREN:U${.ALLSRC:N${RUMPOBJ_NORENAME}}}; do \
1861.69Spooka		${NM} -go $${obj} | ${TOOL_AWK} ' \
1871.69Spooka		    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
1881.69Spooka		      {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
1891.69Spooka		    | sort | uniq  > renametab.$${obj}; \
1901.69Spooka		${OBJCOPY} --preserve-dates --redefine-syms \
1911.69Spooka		    renametab.$${obj} $${obj}; \
1921.69Spooka		rm -f renametab.$${obj}; \
1931.69Spooka	done
1941.46Spooka.if !defined(RUMP_SYMREN)
1951.69Spooka	${AR} ${_ARFL} ${.TARGET} \
1961.69Spooka	    `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
1971.46Spooka.endif
1981.47Spooka
1991.53Spooka_BSD_IOCONF_MK_USER_=1
2001.53Spooka.include <bsd.ioconf.mk>
2011.47Spooka
2021.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
2031.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
204