Makefile.rump revision 1.120
11.120Spooka#	$NetBSD: Makefile.rump,v 1.120 2015/11/15 13:50:10 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.112Spooka# which NetBSD compat to build
331.113SpookaRUMP_NBCOMPAT?=default
341.113Spooka.if ${RUMP_NBCOMPAT} == "all" || ${RUMP_NBCOMPAT} == "default"
351.112SpookaRUMP_NBCOMPAT=	50 60 70
361.112Spooka.endif
371.112Spooka.if ${RUMP_NBCOMPAT} == "none"
381.112SpookaRUMP_NBCOMPAT=
391.112Spooka.endif
401.110SpookaRUMP_NBCOMPAT:=	${RUMP_NBCOMPAT:S/,/ /g}
411.110SpookaCPPFLAGS+=	${RUMP_NBCOMPAT:C/[1-9]0/-DCOMPAT_&/g}
421.104Spooka
431.66SpookaCPPFLAGS+=	-nostdinc
441.22SpookaCFLAGS+=	-ffreestanding -fno-strict-aliasing
451.66Spooka
461.50SpookaCWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
471.114Spooka
481.114SpookaCPPFLAGS+=	-imacros ${RUMPTOP}/include/opt/opt_rumpkernel.h
491.115Spooka.ifdef BUILDRUMP_IMACROS
501.115SpookaCPPFLAGS+=	-imacros ${BUILDRUMP_IMACROS}
511.115Spooka.endif
521.114Spooka
531.15SpookaCPPFLAGS+=	-I${.CURDIR} -I.
541.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../../common/include
551.18SpookaCPPFLAGS+=	-I${RUMPTOP}/include
561.117SpookaCPPFLAGS+=	-I${RUMPTOP}/include/opt
571.65Spooka
581.103SpookaSHLIB_MAJOR?=	0
591.103SpookaSHLIB_MINOR?=	0
601.103Spooka
611.65Spooka.ifdef NEED_ISYSTEM
621.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/../arch
631.65SpookaCPPFLAGS+=	-isystem ${RUMPTOP}/..
641.65Spooka.else
651.65SpookaCPPFLAGS+=	-I${RUMPTOP}/../arch
661.65SpookaCPPFLAGS+=	-I${RUMPTOP}/..
671.65Spooka.endif
681.65Spooka
691.93SpookaRUMP_LDSCRIPT?=	GNU
701.79Spooka.if ${RUMP_LDSCRIPT} != "no"
711.72Spooka# my ld or yours?
721.97Spooka.if ${RUMP_LDSCRIPT} == "sun"
731.72SpookaLDFLAGS+=	-Wl,-M ${RUMPTOP}/ldscript_sun.rump
741.72SpookaSRCS+=		linksyms_sun.c
751.74Spooka.PATH:		${RUMPTOP}
761.93Spooka.elif ${RUMP_LDSCRIPT} == "GNU"
771.93SpookaLDFLAGS+=	-Wl,-T,${RUMPTOP}/ldscript.rump
781.96Spooka.elif ${RUMP_LDSCRIPT} == "ctor"
791.96SpookaCPPFLAGS+=	-DRUMP_USE_CTOR
801.72Spooka.else
811.93Spooka.error Unknown ldscript ${RUMP_LDSCRIPT}
821.73Spooka.endif
831.79Spooka.endif
841.62Spooka
851.94Spooka.if defined(RUMP_CURLWP)
861.94Spooka.if   ${RUMP_CURLWP} == "hypercall"
871.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP_HYPERCALL
881.94Spooka.elif ${RUMP_CURLWP} == "__thread"
891.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP___THREAD
901.94Spooka.elif ${RUMP_CURLWP} == "register"
911.94SpookaCPPFLAGS+=	-DRUMP_CURLWP=RUMP_CURLWP_REGISTER
921.94Spooka.else
931.94Spooka.error Unsupported curlwp scheme: ${RUMP_CURLWP}
941.94Spooka.endif
951.94Spooka.endif
961.94Spooka
971.62SpookaRUMP_DIAGNOSTIC?=yes
981.62Spooka.if ${RUMP_DIAGNOSTIC} == "yes"
991.62SpookaCPPFLAGS+=	-DDIAGNOSTIC
1001.62Spooka.endif
1011.62Spooka
1021.62Spooka.ifdef RUMP_DEBUG
1031.62SpookaCPPFLAGS+=	-DDEBUG
1041.62Spooka.endif
1051.1Spooka
1061.59Spooka.ifdef RUMP_LOCKDEBUG
1071.59SpookaCPPFLAGS+=	-DLOCKDEBUG
1081.59Spooka.endif
1091.59Spooka
1101.89SpookaRUMP_KTRACE?=yes
1111.89Spooka.if ${RUMP_KTRACE} == "yes"
1121.89SpookaCPPFLAGS+=	-DKTRACE
1131.89Spooka.endif
1141.89Spooka
1151.42Spooka# kernel libs should not get linked against libc
1161.43Spooka# XXX: actually, we would like to enable this but cannot, since it
1171.43Spooka# also leaves out libgcc, it causes problems on some platforms.
1181.43Spooka# revisit some day.
1191.43Spooka#LDFLAGS+=	-nodefaultlibs
1201.42Spooka
1211.39Spooka# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
1221.67Spooka# also, give those builds a way to undef the local compiler's macros
1231.114SpookaCPPFLAGS+=	${RUMPKERN_UNDEF}
1241.39Spooka
1251.11SpookaRUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
1261.11Spooka
1271.13Spooka# workaround: evbppc is not a well-defined arch
1281.13Spooka.if (${MACHINE} == "evbppc")
1291.16SpookaCPPFLAGS+=	-DPPC_OEA
1301.13Spooka.endif
1311.13Spooka
1321.114Spooka# If any of these files change, we need a full rebuild
1331.25SpookaDPSRCS+=	${RUMPTOP}/Makefile.rump
1341.24Spooka
1351.24Spooka#
1361.69Spooka# Support for component-specific hypercalls
1371.69Spooka#
1381.69Spooka
1391.101Spooka# no easy way to get WARNS out of bsd.sys.mk
1401.102SpookaRUMPCOMP_USER_WARNFLAGS=	-Wall -Wextra -Wno-unused-parameter
1411.102SpookaRUMPCOMP_USER_WARNFLAGS+=	-Wstrict-prototypes -Wmissing-prototypes
1421.75Schristos
1431.91Spooka.ifdef RUMPCOMP_USER_SRCS && !defined(RUMPKERN_ONLY)
1441.75Schristos.if empty(DESTDIR)
1451.75SchristosDESTDIR=/
1461.75Schristos.endif
1471.75SchristosBUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR}
1481.82SpookaRUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:}
1491.91Spooka.for rcusrc in ${RUMPCOMP_USER_SRCS:R}
1501.91Spooka${rcusrc}.d: ${rcusrc}.c
1511.69Spooka	${_MKTARGET_CREATE}
1521.91Spooka	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*${rcusrc}.c}
1531.69Spooka
1541.91Spooka${rcusrc}.o: ${rcusrc}.c
1551.69Spooka	${_MKTARGET_COMPILE}
1561.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}
1571.69Spooka
1581.91Spooka${rcusrc}.pico: ${rcusrc}.c
1591.69Spooka	${_MKTARGET_COMPILE}
1601.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}
1611.69Spooka
1621.91Spooka${rcusrc}.po: ${rcusrc}.c
1631.69Spooka	${_MKTARGET_COMPILE}
1641.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}
1651.69Spooka
1661.91SpookaRUMPOBJ_NORENAME+=${rcusrc}.o ${rcusrc}.pico ${rcusrc}.po
1671.91SpookaSRCS+=${rcusrc}.c
1681.91Spooka.endfor
1691.69Spooka.endif
1701.69Spooka
1711.69Spooka#
1721.24Spooka# Rename library symbols before use.  If a symbol does not already belong
1731.24Spooka# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
1741.24Spooka# avoids accidentally linking any kernel symbol against host platform
1751.24Spooka# libraries.  The only non-renamed symbols are linkset delimiters and
1761.24Spooka# the GOT, which are more a property of the compiler than the kernel.
1771.24Spooka#
1781.29Spooka# Some toolchains generate unresolved symbols which are supposed to be
1791.29Spooka# satisfied by the toolchain itself when the program is linked.
1801.29Spooka# Unfortunately, we do not know which of the symbols are generated by
1811.29Spooka# the toolchain.  Worse, they vary from platform to platform and
1821.29Spooka# toolchain to toolchain.  The good news, however, is that this will
1831.29Spooka# be detected by a compile-time failure, so we can fairly easily manage
1841.29Spooka# a quirktable here.
1851.46Spooka#
1861.46Spooka# We also allow calling ourselves externally with e.g.:
1871.46Spooka# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
1881.46Spooka#
1891.29Spooka.if ${MACHINE_CPU} == "mips"
1901.29Spooka_SYMQUIRK='|_gp_disp'
1911.29Spooka.elif ${MACHINE_CPU} == "hppa"
1921.29Spooka_SYMQUIRK='|\$$\$$'
1931.54Smrg.elif ${MACHINE_ARCH} == "powerpc64"
1941.55Smrg_SYMQUIRK="|PF_funcs"
1951.55Smrg.endif
1961.55Smrg
1971.55Smrg#
1981.55Smrg# Prefix quirks.  At least one toolchain generates global
1991.55Smrg# symbols with prefixes which really need to remain as prefixes
2001.55Smrg# (i.e. the '.' on the front of some ppc64 globals).  The
2011.55Smrg# way to know if you have the problem is if you get later
2021.55Smrg# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
2031.55Smrg# the 'X' part was added by the toolchain and will need to
2041.55Smrg# be mentioned here.
2051.55Smrg# 
2061.55Smrg.if ${MACHINE_ARCH} == "powerpc64"
2071.55Smrg_PQ="\.?"
2081.55Smrg.else
2091.55Smrg_PQ=
2101.29Spooka.endif
2111.46Spooka
2121.46Spookarump_symren: __archivebuild
2131.46Spooka.if !defined(RUMP_SYMREN)
2141.46Spooka	@echo "Must supply RUMP_SYMREN for target rump_symren"
2151.46Spooka	@false
2161.46Spooka.endif
2171.46Spooka
2181.46Spooka# if we are called from lib build (RUMP_SYMREN is not specified),
2191.46Spooka# build the arrrrchive.  otherwise just rename symbols.
2201.24Spooka__archivebuild: .USE
2211.46Spooka.if defined(RUMP_SYMREN) && defined(RUMPTOP)
2221.46Spooka	@echo "ERROR: RUMP_SYMREN can only be used standalone"
2231.46Spooka	@false
2241.46Spooka.endif
2251.46Spooka.if defined(RUMP_SYMREN)
2261.46Spooka	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
2271.46Spooka.else
2281.24Spooka	${_MKTARGET_BUILD}
2291.24Spooka	rm -f ${.TARGET}
2301.46Spooka.endif
2311.91Spooka	for renameobj in ${RUMP_SYMREN:U${.ALLSRC:C/(${RUMPOBJ_NORENAME:ts|})//g}}; do \
2321.91Spooka		${NM} -go $${renameobj} | ${TOOL_AWK} ' \
2331.98Spooka		    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}'${RUMP_SYM_NORENAME:D|${RUMP_SYM_NORENAME}})/ \
2341.69Spooka		      {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
2351.91Spooka		    | sort | uniq  > renametab.$${renameobj}; \
2361.69Spooka		${OBJCOPY} --preserve-dates --redefine-syms \
2371.91Spooka		    renametab.$${renameobj} $${renameobj}; \
2381.91Spooka		rm -f renametab.$${renameobj}; \
2391.69Spooka	done
2401.46Spooka.if !defined(RUMP_SYMREN)
2411.69Spooka	${AR} ${_ARFL} ${.TARGET} \
2421.69Spooka	    `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
2431.46Spooka.endif
2441.47Spooka
2451.119SpookaCOMMENT?=	(no description)
2461.120Spookarumpdescribe: .PHONY
2471.119Spooka	@printf '%-24s %s\n' '${LIB}' '${COMMENT}'
2481.119Spooka
2491.53Spooka_BSD_IOCONF_MK_USER_=1
2501.53Spooka.include <bsd.ioconf.mk>
2511.47Spooka
2521.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
2531.44Spooka.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
2541.95Spooka
2551.95Spooka.endif # _RUMP_MK
256