Makefile.rump revision 1.93
11.93Spooka#	$NetBSD: Makefile.rump,v 1.93 2014/03/16 14:02:06 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.92Spooka.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64")
121.90Spooka_RUMP_NATIVEABI= yes
131.90SpookaCPPFLAGS+=	-D_RUMP_NATIVE_ABI
141.90Spooka.else
151.90Spooka_RUMP_NATIVEABI= no
161.18SpookaCPPFLAGS:=	-I${RUMPTOP}/include ${CPPFLAGS}
171.92SpookaCPPFLAGS+=	-D_RUMPKERNEL -I${RUMPTOP}/librump/rumpkern
181.18Spooka.endif
191.18Spooka
201.66SpookaCPPFLAGS+=	-DMAXUSERS=32
211.84SpookaCPPFLAGS+=	-DCOMPAT_50=1 -DCOMPAT_60=1
221.66Spooka
231.66SpookaCPPFLAGS+=	-nostdinc
241.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
251.66Spooka
261.50SpookaCWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
271.23SpookaCPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
281.38SpookaCPPFLAGS+=	-DDEBUGPRINT
291.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
301.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include
311.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
321.21SpookaCPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
331.65Spooka
341.65Spooka.ifdef NEED_ISYSTEM
351.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/../arch
361.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/..
371.65Spooka.else
381.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../arch
391.65SpookaCPPFLAGS+=	-I${RUMPTOP}/..
401.65Spooka.endif
411.65Spooka
421.93SpookaRUMP_LDSCRIPT?=	GNU
431.79Spooka.if ${RUMP_LDSCRIPT} != "no"
441.72Spooka# my ld or yours?
451.93Spooka.if ${RUMP_LDSCRIPT} == "sun" || defined(HAVE_SUN_LD)
461.72SpookaLDFLAGS+=	-Wl,-M ${RUMPTOP}/ldscript_sun.rump
471.72SpookaSRCS+=		linksyms_sun.c
481.74Spooka.PATH:		${RUMPTOP}
491.93Spooka.elif ${RUMP_LDSCRIPT} == "GNU"
501.93SpookaLDFLAGS+=	-Wl,-T,${RUMPTOP}/ldscript.rump
511.72Spooka.else
521.93Spooka.error Unknown ldscript ${RUMP_LDSCRIPT}
531.73Spooka.endif
541.79Spooka.endif
551.62Spooka
561.62SpookaRUMP_DIAGNOSTIC?=yes
571.62Spooka.if ${RUMP_DIAGNOSTIC} == "yes"
581.62SpookaCPPFLAGS+=	-DDIAGNOSTIC
591.62Spooka.endif
601.62Spooka
611.62Spooka.ifdef RUMP_DEBUG
621.62SpookaCPPFLAGS+=	-DDEBUG
631.62Spooka.endif
641.1Spooka
651.59Spooka.ifdef RUMP_LOCKDEBUG
661.59SpookaCPPFLAGS+=	-DLOCKDEBUG
671.59Spooka.endif
681.59Spooka
691.89SpookaRUMP_KTRACE?=yes
701.89Spooka.if ${RUMP_KTRACE} == "yes"
711.89SpookaCPPFLAGS+=	-DKTRACE
721.89Spooka.endif
731.89Spooka
741.42Spooka# kernel libs should not get linked against libc
751.43Spooka# XXX: actually, we would like to enable this but cannot, since it
761.43Spooka# also leaves out libgcc, it causes problems on some platforms.
771.43Spooka# revisit some day.
781.43Spooka#LDFLAGS+=	-nodefaultlibs
791.42Spooka
801.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
811.67Spooka# also, give those builds a way to undef the local compiler's macros
821.67SpookaCPPFLAGS+=	-D__NetBSD__ ${RUMPKERN_UNDEF}
831.39Spooka
841.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
851.11Spooka
861.13Spooka# workaround: evbppc is not a well-defined arch
871.13Spooka.if (${MACHINE} == "evbppc")
881.16SpookaCPPFLAGS+=	-DPPC_OEA
891.13Spooka.endif
901.13Spooka
911.25Spooka# If this file changes, we need a full rebuild
921.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
931.24Spooka
941.24Spooka#
951.69Spooka# Support for component-specific hypercalls
961.69Spooka#
971.69Spooka
981.82Spooka# XXX: Warning flags are not in CWARNFLAGS.  Manually add a few important ones.
991.75Schristos
1001.91Spooka.ifdef RUMPCOMP_USER
1011.91Spooka.warning RUMPCOMP_USER is deprecated.  Use RUMPCOMP_USER_SRCS
1021.91SpookaRUMPCOMP_USER_SRCS= rumpcomp_user.c
1031.91Spooka.endif
1041.91Spooka.ifdef RUMPCOMP_USER_SRCS && !defined(RUMPKERN_ONLY)
1051.75Schristos.if empty(DESTDIR)
1061.75SchristosDESTDIR=/
1071.75Schristos.endif
1081.75SchristosBUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR}
1091.82SpookaRUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:}
1101.91Spooka.for rcusrc in ${RUMPCOMP_USER_SRCS:R}
1111.91Spooka${rcusrc}.d: ${rcusrc}.c
1121.69Spooka	${_MKTARGET_CREATE}
1131.91Spooka	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*${rcusrc}.c}
1141.69Spooka
1151.91Spooka${rcusrc}.o: ${rcusrc}.c
1161.69Spooka	${_MKTARGET_COMPILE}
1171.91Spooka	${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*${rcusrc}.c}
1181.69Spooka
1191.91Spooka${rcusrc}.pico: ${rcusrc}.c
1201.69Spooka	${_MKTARGET_COMPILE}
1211.91Spooka	${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*${rcusrc}.c}
1221.69Spooka
1231.91Spooka${rcusrc}.po: ${rcusrc}.c
1241.69Spooka	${_MKTARGET_COMPILE}
1251.91Spooka	${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*${rcusrc}.c}
1261.69Spooka
1271.91SpookaRUMPOBJ_NORENAME+=${rcusrc}.o ${rcusrc}.pico ${rcusrc}.po
1281.91SpookaSRCS+=${rcusrc}.c
1291.91Spooka.endfor
1301.69Spooka.endif
1311.69Spooka
1321.69Spooka#
1331.24Spooka# Rename library symbols before use.  If a symbol does not already belong
1341.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
1351.24Spooka# avoids accidentally linking any kernel symbol against host platform
1361.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
1371.24Spooka# the GOT, which are more a property of the compiler than the kernel.
1381.24Spooka#
1391.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
1401.29Spooka# satisfied by the toolchain itself when the program is linked.
1411.29Spooka# Unfortunately, we do not know which of the symbols are generated by
1421.29Spooka# the toolchain.  Worse, they vary from platform to platform and
1431.29Spooka# toolchain to toolchain.  The good news, however, is that this will
1441.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
1451.29Spooka# a quirktable here.
1461.46Spooka#
1471.46Spooka# We also allow calling ourselves externally with e.g.:
1481.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
1491.46Spooka#
1501.29Spooka.if ${MACHINE_CPU} == "mips"
1511.29Spooka_SYMQUIRK='|_gp_disp'
1521.29Spooka.elif ${MACHINE_CPU} == "hppa"
1531.29Spooka_SYMQUIRK='|\$$\$$'
1541.54Smrg.elif ${MACHINE_ARCH} == "powerpc64"
1551.55Smrg_SYMQUIRK="|PF_funcs"
1561.55Smrg.endif
1571.55Smrg
1581.55Smrg#
1591.55Smrg# Prefix quirks.  At least one toolchain generates global
1601.55Smrg# symbols with prefixes which really need to remain as prefixes
1611.55Smrg# (i.e. the '.' on the front of some ppc64 globals).  The
1621.55Smrg# way to know if you have the problem is if you get later
1631.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
1641.55Smrg# the 'X' part was added by the toolchain and will need to
1651.55Smrg# be mentioned here.
1661.55Smrg# 
1671.55Smrg.if ${MACHINE_ARCH} == "powerpc64"
1681.55Smrg_PQ="\.?"
1691.55Smrg.else
1701.55Smrg_PQ=
1711.29Spooka.endif
1721.46Spooka
1731.46Spookarump_symren: __archivebuild
1741.46Spooka.if !defined(RUMP_SYMREN)
1751.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
1761.46Spooka	@false
1771.46Spooka.endif
1781.46Spooka
1791.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
1801.46Spooka# build the arrrrchive.  otherwise just rename symbols.
1811.24Spooka__archivebuild: .USE
1821.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
1831.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
1841.46Spooka	@false
1851.46Spooka.endif
1861.46Spooka.if defined(RUMP_SYMREN)
1871.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
1881.46Spooka.else
1891.24Spooka	${_MKTARGET_BUILD}
1901.24Spooka	rm -f ${.TARGET}
1911.46Spooka.endif
1921.91Spooka	for renameobj in ${RUMP_SYMREN:U${.ALLSRC:C/(${RUMPOBJ_NORENAME:ts|})//g}}; do \
1931.91Spooka		${NM} -go $${renameobj} | ${TOOL_AWK} ' \
1941.69Spooka		    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
1951.69Spooka		      {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
1961.91Spooka		    | sort | uniq  > renametab.$${renameobj}; \
1971.69Spooka		${OBJCOPY} --preserve-dates --redefine-syms \
1981.91Spooka		    renametab.$${renameobj} $${renameobj}; \
1991.91Spooka		rm -f renametab.$${renameobj}; \
2001.69Spooka	done
2011.46Spooka.if !defined(RUMP_SYMREN)
2021.69Spooka	${AR} ${_ARFL} ${.TARGET} \
2031.69Spooka	    `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
2041.46Spooka.endif
2051.47Spooka
2061.53Spooka_BSD_IOCONF_MK_USER_=1
2071.53Spooka.include <bsd.ioconf.mk>
2081.47Spooka
2091.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
2101.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
211