Makefile.rump revision 1.95
11.95Spooka#	$NetBSD: Makefile.rump,v 1.95 2014/04/15 13:41:46 pooka Exp $
21.1Spooka#
31.1Spooka
41.95Spooka.if !defined(_RUMP_MK)
51.95Spooka_RUMP_MK= #defined
61.95Spooka
71.33SlukemWARNS?=		3	# XXX: src/sys won't compile with -Wsign-compare yet
81.10SpookaNOLINT=		# kernel code
91.1Spooka
101.20Spooka.include <bsd.own.mk>
111.20Spooka
121.90Spooka# Use NetBSD kernel ABI by default on x86 archs.  Performance-related
131.90Spooka# compile-time options may override this at a later date.
141.92Spooka.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64")
151.90Spooka_RUMP_NATIVEABI= yes
161.90SpookaCPPFLAGS+=	-D_RUMP_NATIVE_ABI
171.90Spooka.else
181.90Spooka_RUMP_NATIVEABI= no
191.18SpookaCPPFLAGS:=	-I${RUMPTOP}/include ${CPPFLAGS}
201.92SpookaCPPFLAGS+=	-D_RUMPKERNEL -I${RUMPTOP}/librump/rumpkern
211.18Spooka.endif
221.18Spooka
231.66SpookaCPPFLAGS+=	-DMAXUSERS=32
241.84SpookaCPPFLAGS+=	-DCOMPAT_50=1 -DCOMPAT_60=1
251.66Spooka
261.66SpookaCPPFLAGS+=	-nostdinc
271.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
281.66Spooka
291.50SpookaCWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
301.23SpookaCPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
311.38SpookaCPPFLAGS+=	-DDEBUGPRINT
321.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
331.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include
341.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
351.21SpookaCPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
361.65Spooka
371.65Spooka.ifdef NEED_ISYSTEM
381.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/../arch
391.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/..
401.65Spooka.else
411.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../arch
421.65SpookaCPPFLAGS+=	-I${RUMPTOP}/..
431.65Spooka.endif
441.65Spooka
451.93SpookaRUMP_LDSCRIPT?=	GNU
461.79Spooka.if ${RUMP_LDSCRIPT} != "no"
471.72Spooka# my ld or yours?
481.93Spooka.if ${RUMP_LDSCRIPT} == "sun" || defined(HAVE_SUN_LD)
491.72SpookaLDFLAGS+=	-Wl,-M ${RUMPTOP}/ldscript_sun.rump
501.72SpookaSRCS+=		linksyms_sun.c
511.74Spooka.PATH:		${RUMPTOP}
521.93Spooka.elif ${RUMP_LDSCRIPT} == "GNU"
531.93SpookaLDFLAGS+=	-Wl,-T,${RUMPTOP}/ldscript.rump
541.72Spooka.else
551.93Spooka.error Unknown ldscript ${RUMP_LDSCRIPT}
561.73Spooka.endif
571.79Spooka.endif
581.62Spooka
591.94Spooka.if defined(RUMP_CURLWP)
601.94Spooka.if   ${RUMP_CURLWP} == "hypercall"
611.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP_HYPERCALL
621.94Spooka.elif ${RUMP_CURLWP} == "__thread"
631.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP___THREAD
641.94Spooka.elif ${RUMP_CURLWP} == "register"
651.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP_REGISTER
661.94Spooka.else
671.94Spooka.error Unsupported curlwp scheme: ${RUMP_CURLWP}
681.94Spooka.endif
691.94Spooka.endif
701.94Spooka
711.62SpookaRUMP_DIAGNOSTIC?=yes
721.62Spooka.if ${RUMP_DIAGNOSTIC} == "yes"
731.62SpookaCPPFLAGS+=	-DDIAGNOSTIC
741.62Spooka.endif
751.62Spooka
761.62Spooka.ifdef RUMP_DEBUG
771.62SpookaCPPFLAGS+=	-DDEBUG
781.62Spooka.endif
791.1Spooka
801.59Spooka.ifdef RUMP_LOCKDEBUG
811.59SpookaCPPFLAGS+=	-DLOCKDEBUG
821.59Spooka.endif
831.59Spooka
841.89SpookaRUMP_KTRACE?=yes
851.89Spooka.if ${RUMP_KTRACE} == "yes"
861.89SpookaCPPFLAGS+=	-DKTRACE
871.89Spooka.endif
881.89Spooka
891.42Spooka# kernel libs should not get linked against libc
901.43Spooka# XXX: actually, we would like to enable this but cannot, since it
911.43Spooka# also leaves out libgcc, it causes problems on some platforms.
921.43Spooka# revisit some day.
931.43Spooka#LDFLAGS+=	-nodefaultlibs
941.42Spooka
951.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
961.67Spooka# also, give those builds a way to undef the local compiler's macros
971.67SpookaCPPFLAGS+=	-D__NetBSD__ ${RUMPKERN_UNDEF}
981.39Spooka
991.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
1001.11Spooka
1011.13Spooka# workaround: evbppc is not a well-defined arch
1021.13Spooka.if (${MACHINE} == "evbppc")
1031.16SpookaCPPFLAGS+=	-DPPC_OEA
1041.13Spooka.endif
1051.13Spooka
1061.25Spooka# If this file changes, we need a full rebuild
1071.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
1081.24Spooka
1091.24Spooka#
1101.69Spooka# Support for component-specific hypercalls
1111.69Spooka#
1121.69Spooka
1131.82Spooka# XXX: Warning flags are not in CWARNFLAGS.  Manually add a few important ones.
1141.75Schristos
1151.91Spooka.ifdef RUMPCOMP_USER
1161.91Spooka.warning RUMPCOMP_USER is deprecated.  Use RUMPCOMP_USER_SRCS
1171.91SpookaRUMPCOMP_USER_SRCS= rumpcomp_user.c
1181.91Spooka.endif
1191.91Spooka.ifdef RUMPCOMP_USER_SRCS && !defined(RUMPKERN_ONLY)
1201.75Schristos.if empty(DESTDIR)
1211.75SchristosDESTDIR=/
1221.75Schristos.endif
1231.75SchristosBUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR}
1241.82SpookaRUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:}
1251.91Spooka.for rcusrc in ${RUMPCOMP_USER_SRCS:R}
1261.91Spooka${rcusrc}.d: ${rcusrc}.c
1271.69Spooka	${_MKTARGET_CREATE}
1281.91Spooka	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*${rcusrc}.c}
1291.69Spooka
1301.91Spooka${rcusrc}.o: ${rcusrc}.c
1311.69Spooka	${_MKTARGET_COMPILE}
1321.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}
1331.69Spooka
1341.91Spooka${rcusrc}.pico: ${rcusrc}.c
1351.69Spooka	${_MKTARGET_COMPILE}
1361.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}
1371.69Spooka
1381.91Spooka${rcusrc}.po: ${rcusrc}.c
1391.69Spooka	${_MKTARGET_COMPILE}
1401.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}
1411.69Spooka
1421.91SpookaRUMPOBJ_NORENAME+=${rcusrc}.o ${rcusrc}.pico ${rcusrc}.po
1431.91SpookaSRCS+=${rcusrc}.c
1441.91Spooka.endfor
1451.69Spooka.endif
1461.69Spooka
1471.69Spooka#
1481.24Spooka# Rename library symbols before use.  If a symbol does not already belong
1491.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
1501.24Spooka# avoids accidentally linking any kernel symbol against host platform
1511.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
1521.24Spooka# the GOT, which are more a property of the compiler than the kernel.
1531.24Spooka#
1541.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
1551.29Spooka# satisfied by the toolchain itself when the program is linked.
1561.29Spooka# Unfortunately, we do not know which of the symbols are generated by
1571.29Spooka# the toolchain.  Worse, they vary from platform to platform and
1581.29Spooka# toolchain to toolchain.  The good news, however, is that this will
1591.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
1601.29Spooka# a quirktable here.
1611.46Spooka#
1621.46Spooka# We also allow calling ourselves externally with e.g.:
1631.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
1641.46Spooka#
1651.29Spooka.if ${MACHINE_CPU} == "mips"
1661.29Spooka_SYMQUIRK='|_gp_disp'
1671.29Spooka.elif ${MACHINE_CPU} == "hppa"
1681.29Spooka_SYMQUIRK='|\$$\$$'
1691.54Smrg.elif ${MACHINE_ARCH} == "powerpc64"
1701.55Smrg_SYMQUIRK="|PF_funcs"
1711.55Smrg.endif
1721.55Smrg
1731.55Smrg#
1741.55Smrg# Prefix quirks.  At least one toolchain generates global
1751.55Smrg# symbols with prefixes which really need to remain as prefixes
1761.55Smrg# (i.e. the '.' on the front of some ppc64 globals).  The
1771.55Smrg# way to know if you have the problem is if you get later
1781.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
1791.55Smrg# the 'X' part was added by the toolchain and will need to
1801.55Smrg# be mentioned here.
1811.55Smrg# 
1821.55Smrg.if ${MACHINE_ARCH} == "powerpc64"
1831.55Smrg_PQ="\.?"
1841.55Smrg.else
1851.55Smrg_PQ=
1861.29Spooka.endif
1871.46Spooka
1881.46Spookarump_symren: __archivebuild
1891.46Spooka.if !defined(RUMP_SYMREN)
1901.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
1911.46Spooka	@false
1921.46Spooka.endif
1931.46Spooka
1941.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
1951.46Spooka# build the arrrrchive.  otherwise just rename symbols.
1961.24Spooka__archivebuild: .USE
1971.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
1981.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
1991.46Spooka	@false
2001.46Spooka.endif
2011.46Spooka.if defined(RUMP_SYMREN)
2021.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
2031.46Spooka.else
2041.24Spooka	${_MKTARGET_BUILD}
2051.24Spooka	rm -f ${.TARGET}
2061.46Spooka.endif
2071.91Spooka	for renameobj in ${RUMP_SYMREN:U${.ALLSRC:C/(${RUMPOBJ_NORENAME:ts|})//g}}; do \
2081.91Spooka		${NM} -go $${renameobj} | ${TOOL_AWK} ' \
2091.69Spooka		    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
2101.69Spooka		      {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
2111.91Spooka		    | sort | uniq  > renametab.$${renameobj}; \
2121.69Spooka		${OBJCOPY} --preserve-dates --redefine-syms \
2131.91Spooka		    renametab.$${renameobj} $${renameobj}; \
2141.91Spooka		rm -f renametab.$${renameobj}; \
2151.69Spooka	done
2161.46Spooka.if !defined(RUMP_SYMREN)
2171.69Spooka	${AR} ${_ARFL} ${.TARGET} \
2181.69Spooka	    `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
2191.46Spooka.endif
2201.47Spooka
2211.53Spooka_BSD_IOCONF_MK_USER_=1
2221.53Spooka.include <bsd.ioconf.mk>
2231.47Spooka
2241.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
2251.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
2261.95Spooka
2271.95Spooka.endif # _RUMP_MK
228