Makefile.rump revision 1.110
11.110Spooka#	$NetBSD: Makefile.rump,v 1.110 2015/04/23 14:49:26 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.90Spooka.else
171.90Spooka_RUMP_NATIVEABI= no
181.18SpookaCPPFLAGS:=	-I${RUMPTOP}/include ${CPPFLAGS}
191.92SpookaCPPFLAGS+=	-D_RUMPKERNEL -I${RUMPTOP}/librump/rumpkern
201.18Spooka.endif
211.18Spooka
221.99Salnsn# Define baseline cpu for mips ports, required for
231.99Salnsn# rumpcomp_sync_icache() hypercall.
241.99Salnsn.if !empty(MACHINE_ARCH:Mmips*)
251.99Salnsn.if !empty(MACHINE_ARCH:Mmips64*)
261.99SalnsnCPPFLAGS+=	-DMIPS64=1
271.99Salnsn.else
281.99SalnsnCPPFLAGS+=	-DMIPS1=1
291.99Salnsn.endif
301.99Salnsn.endif
311.99Salnsn
321.110SpookaRUMP_NBCOMPAT?=	60 70
331.110Spooka.if ${RUMP_NBCOMPAT} == "all"
341.110SpookaRUMP_NBCOMPAT=	50 60 70
351.109Spooka.endif
361.109Spooka# normalize alternatively accepted comma-separated list
371.110SpookaRUMP_NBCOMPAT:=	${RUMP_NBCOMPAT:S/,/ /g}
381.110SpookaCPPFLAGS+=	${RUMP_NBCOMPAT:C/[1-9]0/-DCOMPAT_&/g}
391.104Spooka
401.66SpookaCPPFLAGS+=	-DMAXUSERS=32
411.66Spooka
421.66SpookaCPPFLAGS+=	-nostdinc
431.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
441.66Spooka
451.50SpookaCWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
461.23SpookaCPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
471.38SpookaCPPFLAGS+=	-DDEBUGPRINT
481.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
491.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include
501.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
511.21SpookaCPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
521.65Spooka
531.103SpookaSHLIB_MAJOR?=	0
541.103SpookaSHLIB_MINOR?=	0
551.103Spooka
561.65Spooka.ifdef NEED_ISYSTEM
571.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/../arch
581.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/..
591.65Spooka.else
601.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../arch
611.65SpookaCPPFLAGS+=	-I${RUMPTOP}/..
621.65Spooka.endif
631.65Spooka
641.93SpookaRUMP_LDSCRIPT?=	GNU
651.79Spooka.if ${RUMP_LDSCRIPT} != "no"
661.72Spooka# my ld or yours?
671.97Spooka.if ${RUMP_LDSCRIPT} == "sun"
681.72SpookaLDFLAGS+=	-Wl,-M ${RUMPTOP}/ldscript_sun.rump
691.72SpookaSRCS+=		linksyms_sun.c
701.74Spooka.PATH:		${RUMPTOP}
711.93Spooka.elif ${RUMP_LDSCRIPT} == "GNU"
721.93SpookaLDFLAGS+=	-Wl,-T,${RUMPTOP}/ldscript.rump
731.96Spooka.elif ${RUMP_LDSCRIPT} == "ctor"
741.96SpookaCPPFLAGS+=	-DRUMP_USE_CTOR
751.72Spooka.else
761.93Spooka.error Unknown ldscript ${RUMP_LDSCRIPT}
771.73Spooka.endif
781.79Spooka.endif
791.62Spooka
801.94Spooka.if defined(RUMP_CURLWP)
811.94Spooka.if   ${RUMP_CURLWP} == "hypercall"
821.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP_HYPERCALL
831.94Spooka.elif ${RUMP_CURLWP} == "__thread"
841.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP___THREAD
851.94Spooka.elif ${RUMP_CURLWP} == "register"
861.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP_REGISTER
871.94Spooka.else
881.94Spooka.error Unsupported curlwp scheme: ${RUMP_CURLWP}
891.94Spooka.endif
901.94Spooka.endif
911.94Spooka
921.62SpookaRUMP_DIAGNOSTIC?=yes
931.62Spooka.if ${RUMP_DIAGNOSTIC} == "yes"
941.62SpookaCPPFLAGS+=	-DDIAGNOSTIC
951.62Spooka.endif
961.62Spooka
971.62Spooka.ifdef RUMP_DEBUG
981.62SpookaCPPFLAGS+=	-DDEBUG
991.62Spooka.endif
1001.1Spooka
1011.59Spooka.ifdef RUMP_LOCKDEBUG
1021.59SpookaCPPFLAGS+=	-DLOCKDEBUG
1031.59Spooka.endif
1041.59Spooka
1051.89SpookaRUMP_KTRACE?=yes
1061.89Spooka.if ${RUMP_KTRACE} == "yes"
1071.89SpookaCPPFLAGS+=	-DKTRACE
1081.89Spooka.endif
1091.89Spooka
1101.42Spooka# kernel libs should not get linked against libc
1111.43Spooka# XXX: actually, we would like to enable this but cannot, since it
1121.43Spooka# also leaves out libgcc, it causes problems on some platforms.
1131.43Spooka# revisit some day.
1141.43Spooka#LDFLAGS+=	-nodefaultlibs
1151.42Spooka
1161.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
1171.67Spooka# also, give those builds a way to undef the local compiler's macros
1181.67SpookaCPPFLAGS+=	-D__NetBSD__ ${RUMPKERN_UNDEF}
1191.39Spooka
1201.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
1211.11Spooka
1221.13Spooka# workaround: evbppc is not a well-defined arch
1231.13Spooka.if (${MACHINE} == "evbppc")
1241.16SpookaCPPFLAGS+=	-DPPC_OEA
1251.13Spooka.endif
1261.13Spooka
1271.25Spooka# If this file changes, we need a full rebuild
1281.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
1291.24Spooka
1301.24Spooka#
1311.69Spooka# Support for component-specific hypercalls
1321.69Spooka#
1331.69Spooka
1341.101Spooka# no easy way to get WARNS out of bsd.sys.mk
1351.102SpookaRUMPCOMP_USER_WARNFLAGS=	-Wall -Wextra -Wno-unused-parameter
1361.102SpookaRUMPCOMP_USER_WARNFLAGS+=	-Wstrict-prototypes -Wmissing-prototypes
1371.75Schristos
1381.91Spooka.ifdef RUMPCOMP_USER_SRCS && !defined(RUMPKERN_ONLY)
1391.75Schristos.if empty(DESTDIR)
1401.75SchristosDESTDIR=/
1411.75Schristos.endif
1421.75SchristosBUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR}
1431.82SpookaRUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:}
1441.91Spooka.for rcusrc in ${RUMPCOMP_USER_SRCS:R}
1451.91Spooka${rcusrc}.d: ${rcusrc}.c
1461.69Spooka	${_MKTARGET_CREATE}
1471.91Spooka	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*${rcusrc}.c}
1481.69Spooka
1491.91Spooka${rcusrc}.o: ${rcusrc}.c
1501.69Spooka	${_MKTARGET_COMPILE}
1511.101Spooka	${CC} -o ${.TARGET} ${DBG} ${CWARNFLAGS} ${RUMPCOMP_USER_WERROR} ${RUMPCOMP_USER_WARNFLAGS} ${BUILDRUMP_CPPFLAGS} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.ALLSRC:O:u:M*${rcusrc}.c}
1521.69Spooka
1531.91Spooka${rcusrc}.pico: ${rcusrc}.c
1541.69Spooka	${_MKTARGET_COMPILE}
1551.101Spooka	${CC} -o ${.TARGET} -fPIC -DPIC ${DBG} ${CWARNFLAGS} ${RUMPCOMP_USER_WERROR} ${RUMPCOMP_USER_WARNFLAGS} ${BUILDRUMP_CPPFLAGS} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.ALLSRC:O:u:M*${rcusrc}.c}
1561.69Spooka
1571.91Spooka${rcusrc}.po: ${rcusrc}.c
1581.69Spooka	${_MKTARGET_COMPILE}
1591.101Spooka	${CC} -o ${.TARGET} ${PROFFLAGS} -pg ${DBG} ${CWARNFLAGS} ${RUMPCOMP_USER_WERROR} ${RUMPCOMP_USER_WARNFLAGS} ${BUILDRUMP_CPPFLAGS} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.ALLSRC:O:u:M*${rcusrc}.c}
1601.69Spooka
1611.91SpookaRUMPOBJ_NORENAME+=${rcusrc}.o ${rcusrc}.pico ${rcusrc}.po
1621.91SpookaSRCS+=${rcusrc}.c
1631.91Spooka.endfor
1641.69Spooka.endif
1651.69Spooka
1661.69Spooka#
1671.24Spooka# Rename library symbols before use.  If a symbol does not already belong
1681.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
1691.24Spooka# avoids accidentally linking any kernel symbol against host platform
1701.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
1711.24Spooka# the GOT, which are more a property of the compiler than the kernel.
1721.24Spooka#
1731.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
1741.29Spooka# satisfied by the toolchain itself when the program is linked.
1751.29Spooka# Unfortunately, we do not know which of the symbols are generated by
1761.29Spooka# the toolchain.  Worse, they vary from platform to platform and
1771.29Spooka# toolchain to toolchain.  The good news, however, is that this will
1781.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
1791.29Spooka# a quirktable here.
1801.46Spooka#
1811.46Spooka# We also allow calling ourselves externally with e.g.:
1821.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
1831.46Spooka#
1841.29Spooka.if ${MACHINE_CPU} == "mips"
1851.29Spooka_SYMQUIRK='|_gp_disp'
1861.29Spooka.elif ${MACHINE_CPU} == "hppa"
1871.29Spooka_SYMQUIRK='|\$$\$$'
1881.54Smrg.elif ${MACHINE_ARCH} == "powerpc64"
1891.55Smrg_SYMQUIRK="|PF_funcs"
1901.55Smrg.endif
1911.55Smrg
1921.55Smrg#
1931.55Smrg# Prefix quirks.  At least one toolchain generates global
1941.55Smrg# symbols with prefixes which really need to remain as prefixes
1951.55Smrg# (i.e. the '.' on the front of some ppc64 globals).  The
1961.55Smrg# way to know if you have the problem is if you get later
1971.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
1981.55Smrg# the 'X' part was added by the toolchain and will need to
1991.55Smrg# be mentioned here.
2001.55Smrg# 
2011.55Smrg.if ${MACHINE_ARCH} == "powerpc64"
2021.55Smrg_PQ="\.?"
2031.55Smrg.else
2041.55Smrg_PQ=
2051.29Spooka.endif
2061.46Spooka
2071.46Spookarump_symren: __archivebuild
2081.46Spooka.if !defined(RUMP_SYMREN)
2091.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
2101.46Spooka	@false
2111.46Spooka.endif
2121.46Spooka
2131.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
2141.46Spooka# build the arrrrchive.  otherwise just rename symbols.
2151.24Spooka__archivebuild: .USE
2161.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
2171.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
2181.46Spooka	@false
2191.46Spooka.endif
2201.46Spooka.if defined(RUMP_SYMREN)
2211.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
2221.46Spooka.else
2231.24Spooka	${_MKTARGET_BUILD}
2241.24Spooka	rm -f ${.TARGET}
2251.46Spooka.endif
2261.91Spooka	for renameobj in ${RUMP_SYMREN:U${.ALLSRC:C/(${RUMPOBJ_NORENAME:ts|})//g}}; do \
2271.91Spooka		${NM} -go $${renameobj} | ${TOOL_AWK} ' \
2281.98Spooka		    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}'${RUMP_SYM_NORENAME:D|${RUMP_SYM_NORENAME}})/ \
2291.69Spooka		      {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
2301.91Spooka		    | sort | uniq  > renametab.$${renameobj}; \
2311.69Spooka		${OBJCOPY} --preserve-dates --redefine-syms \
2321.91Spooka		    renametab.$${renameobj} $${renameobj}; \
2331.91Spooka		rm -f renametab.$${renameobj}; \
2341.69Spooka	done
2351.46Spooka.if !defined(RUMP_SYMREN)
2361.69Spooka	${AR} ${_ARFL} ${.TARGET} \
2371.69Spooka	    `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
2381.46Spooka.endif
2391.47Spooka
2401.53Spooka_BSD_IOCONF_MK_USER_=1
2411.53Spooka.include <bsd.ioconf.mk>
2421.47Spooka
2431.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
2441.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
2451.95Spooka
2461.95Spooka.endif # _RUMP_MK
247