Makefile.rump revision 1.99
11.99Salnsn#	$NetBSD: Makefile.rump,v 1.99 2014/07/22 20:25:13 alnsn 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.99Salnsn# Define baseline cpu for mips ports, required for
241.99Salnsn# rumpcomp_sync_icache() hypercall.
251.99Salnsn.if !empty(MACHINE_ARCH:Mmips*)
261.99Salnsn.if !empty(MACHINE_ARCH:Mmips64*)
271.99SalnsnCPPFLAGS+=	-DMIPS64=1
281.99Salnsn.else
291.99SalnsnCPPFLAGS+=	-DMIPS1=1
301.99Salnsn.endif
311.99Salnsn.endif
321.99Salnsn
331.66SpookaCPPFLAGS+=	-DMAXUSERS=32
341.84SpookaCPPFLAGS+=	-DCOMPAT_50=1 -DCOMPAT_60=1
351.66Spooka
361.66SpookaCPPFLAGS+=	-nostdinc
371.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
381.66Spooka
391.50SpookaCWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
401.23SpookaCPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
411.38SpookaCPPFLAGS+=	-DDEBUGPRINT
421.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
431.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include
441.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
451.21SpookaCPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
461.65Spooka
471.65Spooka.ifdef NEED_ISYSTEM
481.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/../arch
491.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/..
501.65Spooka.else
511.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../arch
521.65SpookaCPPFLAGS+=	-I${RUMPTOP}/..
531.65Spooka.endif
541.65Spooka
551.93SpookaRUMP_LDSCRIPT?=	GNU
561.79Spooka.if ${RUMP_LDSCRIPT} != "no"
571.72Spooka# my ld or yours?
581.97Spooka.if ${RUMP_LDSCRIPT} == "sun"
591.72SpookaLDFLAGS+=	-Wl,-M ${RUMPTOP}/ldscript_sun.rump
601.72SpookaSRCS+=		linksyms_sun.c
611.74Spooka.PATH:		${RUMPTOP}
621.93Spooka.elif ${RUMP_LDSCRIPT} == "GNU"
631.93SpookaLDFLAGS+=	-Wl,-T,${RUMPTOP}/ldscript.rump
641.96Spooka.elif ${RUMP_LDSCRIPT} == "ctor"
651.96SpookaCPPFLAGS+=	-DRUMP_USE_CTOR
661.72Spooka.else
671.93Spooka.error Unknown ldscript ${RUMP_LDSCRIPT}
681.73Spooka.endif
691.79Spooka.endif
701.62Spooka
711.94Spooka.if defined(RUMP_CURLWP)
721.94Spooka.if   ${RUMP_CURLWP} == "hypercall"
731.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP_HYPERCALL
741.94Spooka.elif ${RUMP_CURLWP} == "__thread"
751.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP___THREAD
761.94Spooka.elif ${RUMP_CURLWP} == "register"
771.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP_REGISTER
781.94Spooka.else
791.94Spooka.error Unsupported curlwp scheme: ${RUMP_CURLWP}
801.94Spooka.endif
811.94Spooka.endif
821.94Spooka
831.62SpookaRUMP_DIAGNOSTIC?=yes
841.62Spooka.if ${RUMP_DIAGNOSTIC} == "yes"
851.62SpookaCPPFLAGS+=	-DDIAGNOSTIC
861.62Spooka.endif
871.62Spooka
881.62Spooka.ifdef RUMP_DEBUG
891.62SpookaCPPFLAGS+=	-DDEBUG
901.62Spooka.endif
911.1Spooka
921.59Spooka.ifdef RUMP_LOCKDEBUG
931.59SpookaCPPFLAGS+=	-DLOCKDEBUG
941.59Spooka.endif
951.59Spooka
961.89SpookaRUMP_KTRACE?=yes
971.89Spooka.if ${RUMP_KTRACE} == "yes"
981.89SpookaCPPFLAGS+=	-DKTRACE
991.89Spooka.endif
1001.89Spooka
1011.42Spooka# kernel libs should not get linked against libc
1021.43Spooka# XXX: actually, we would like to enable this but cannot, since it
1031.43Spooka# also leaves out libgcc, it causes problems on some platforms.
1041.43Spooka# revisit some day.
1051.43Spooka#LDFLAGS+=	-nodefaultlibs
1061.42Spooka
1071.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
1081.67Spooka# also, give those builds a way to undef the local compiler's macros
1091.67SpookaCPPFLAGS+=	-D__NetBSD__ ${RUMPKERN_UNDEF}
1101.39Spooka
1111.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
1121.11Spooka
1131.13Spooka# workaround: evbppc is not a well-defined arch
1141.13Spooka.if (${MACHINE} == "evbppc")
1151.16SpookaCPPFLAGS+=	-DPPC_OEA
1161.13Spooka.endif
1171.13Spooka
1181.25Spooka# If this file changes, we need a full rebuild
1191.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
1201.24Spooka
1211.24Spooka#
1221.69Spooka# Support for component-specific hypercalls
1231.69Spooka#
1241.69Spooka
1251.82Spooka# XXX: Warning flags are not in CWARNFLAGS.  Manually add a few important ones.
1261.75Schristos
1271.91Spooka.ifdef RUMPCOMP_USER
1281.91Spooka.warning RUMPCOMP_USER is deprecated.  Use RUMPCOMP_USER_SRCS
1291.91SpookaRUMPCOMP_USER_SRCS= rumpcomp_user.c
1301.91Spooka.endif
1311.91Spooka.ifdef RUMPCOMP_USER_SRCS && !defined(RUMPKERN_ONLY)
1321.75Schristos.if empty(DESTDIR)
1331.75SchristosDESTDIR=/
1341.75Schristos.endif
1351.75SchristosBUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR}
1361.82SpookaRUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:}
1371.91Spooka.for rcusrc in ${RUMPCOMP_USER_SRCS:R}
1381.91Spooka${rcusrc}.d: ${rcusrc}.c
1391.69Spooka	${_MKTARGET_CREATE}
1401.91Spooka	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*${rcusrc}.c}
1411.69Spooka
1421.91Spooka${rcusrc}.o: ${rcusrc}.c
1431.69Spooka	${_MKTARGET_COMPILE}
1441.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}
1451.69Spooka
1461.91Spooka${rcusrc}.pico: ${rcusrc}.c
1471.69Spooka	${_MKTARGET_COMPILE}
1481.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}
1491.69Spooka
1501.91Spooka${rcusrc}.po: ${rcusrc}.c
1511.69Spooka	${_MKTARGET_COMPILE}
1521.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}
1531.69Spooka
1541.91SpookaRUMPOBJ_NORENAME+=${rcusrc}.o ${rcusrc}.pico ${rcusrc}.po
1551.91SpookaSRCS+=${rcusrc}.c
1561.91Spooka.endfor
1571.69Spooka.endif
1581.69Spooka
1591.69Spooka#
1601.24Spooka# Rename library symbols before use.  If a symbol does not already belong
1611.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
1621.24Spooka# avoids accidentally linking any kernel symbol against host platform
1631.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
1641.24Spooka# the GOT, which are more a property of the compiler than the kernel.
1651.24Spooka#
1661.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
1671.29Spooka# satisfied by the toolchain itself when the program is linked.
1681.29Spooka# Unfortunately, we do not know which of the symbols are generated by
1691.29Spooka# the toolchain.  Worse, they vary from platform to platform and
1701.29Spooka# toolchain to toolchain.  The good news, however, is that this will
1711.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
1721.29Spooka# a quirktable here.
1731.46Spooka#
1741.46Spooka# We also allow calling ourselves externally with e.g.:
1751.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
1761.46Spooka#
1771.29Spooka.if ${MACHINE_CPU} == "mips"
1781.29Spooka_SYMQUIRK='|_gp_disp'
1791.29Spooka.elif ${MACHINE_CPU} == "hppa"
1801.29Spooka_SYMQUIRK='|\$$\$$'
1811.54Smrg.elif ${MACHINE_ARCH} == "powerpc64"
1821.55Smrg_SYMQUIRK="|PF_funcs"
1831.55Smrg.endif
1841.55Smrg
1851.55Smrg#
1861.55Smrg# Prefix quirks.  At least one toolchain generates global
1871.55Smrg# symbols with prefixes which really need to remain as prefixes
1881.55Smrg# (i.e. the '.' on the front of some ppc64 globals).  The
1891.55Smrg# way to know if you have the problem is if you get later
1901.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
1911.55Smrg# the 'X' part was added by the toolchain and will need to
1921.55Smrg# be mentioned here.
1931.55Smrg# 
1941.55Smrg.if ${MACHINE_ARCH} == "powerpc64"
1951.55Smrg_PQ="\.?"
1961.55Smrg.else
1971.55Smrg_PQ=
1981.29Spooka.endif
1991.46Spooka
2001.46Spookarump_symren: __archivebuild
2011.46Spooka.if !defined(RUMP_SYMREN)
2021.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
2031.46Spooka	@false
2041.46Spooka.endif
2051.46Spooka
2061.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
2071.46Spooka# build the arrrrchive.  otherwise just rename symbols.
2081.24Spooka__archivebuild: .USE
2091.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
2101.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
2111.46Spooka	@false
2121.46Spooka.endif
2131.46Spooka.if defined(RUMP_SYMREN)
2141.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
2151.46Spooka.else
2161.24Spooka	${_MKTARGET_BUILD}
2171.24Spooka	rm -f ${.TARGET}
2181.46Spooka.endif
2191.91Spooka	for renameobj in ${RUMP_SYMREN:U${.ALLSRC:C/(${RUMPOBJ_NORENAME:ts|})//g}}; do \
2201.91Spooka		${NM} -go $${renameobj} | ${TOOL_AWK} ' \
2211.98Spooka		    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}'${RUMP_SYM_NORENAME:D|${RUMP_SYM_NORENAME}})/ \
2221.69Spooka		      {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
2231.91Spooka		    | sort | uniq  > renametab.$${renameobj}; \
2241.69Spooka		${OBJCOPY} --preserve-dates --redefine-syms \
2251.91Spooka		    renametab.$${renameobj} $${renameobj}; \
2261.91Spooka		rm -f renametab.$${renameobj}; \
2271.69Spooka	done
2281.46Spooka.if !defined(RUMP_SYMREN)
2291.69Spooka	${AR} ${_ARFL} ${.TARGET} \
2301.69Spooka	    `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
2311.46Spooka.endif
2321.47Spooka
2331.53Spooka_BSD_IOCONF_MK_USER_=1
2341.53Spooka.include <bsd.ioconf.mk>
2351.47Spooka
2361.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
2371.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
2381.95Spooka
2391.95Spooka.endif # _RUMP_MK
240