Makefile.rump revision 1.98
1# $NetBSD: Makefile.rump,v 1.98 2014/06/20 11:57:56 pooka Exp $ 2# 3 4.if !defined(_RUMP_MK) 5_RUMP_MK= #defined 6 7WARNS?= 3 # XXX: src/sys won't compile with -Wsign-compare yet 8NOLINT= # kernel code 9 10.include <bsd.own.mk> 11 12# Use NetBSD kernel ABI by default on x86 archs. Performance-related 13# compile-time options may override this at a later date. 14.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64") 15_RUMP_NATIVEABI= yes 16CPPFLAGS+= -D_RUMP_NATIVE_ABI 17.else 18_RUMP_NATIVEABI= no 19CPPFLAGS:= -I${RUMPTOP}/include ${CPPFLAGS} 20CPPFLAGS+= -D_RUMPKERNEL -I${RUMPTOP}/librump/rumpkern 21.endif 22 23CPPFLAGS+= -DMAXUSERS=32 24CPPFLAGS+= -DCOMPAT_50=1 -DCOMPAT_60=1 25 26CPPFLAGS+= -nostdinc 27CFLAGS+= -ffreestanding -fno-strict-aliasing 28 29CWARNFLAGS+= -Wno-format-zero-length -Wno-pointer-sign 30CPPFLAGS+= -D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR 31CPPFLAGS+= -DDEBUGPRINT 32CPPFLAGS+= -I${.CURDIR} -I. 33CPPFLAGS+= -I${RUMPTOP}/../../common/include 34CPPFLAGS+= -I${RUMPTOP}/include 35CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern/opt 36 37.ifdef NEED_ISYSTEM 38CPPFLAGS+= -isystem ${RUMPTOP}/../arch 39CPPFLAGS+= -isystem ${RUMPTOP}/.. 40.else 41CPPFLAGS+= -I${RUMPTOP}/../arch 42CPPFLAGS+= -I${RUMPTOP}/.. 43.endif 44 45RUMP_LDSCRIPT?= GNU 46.if ${RUMP_LDSCRIPT} != "no" 47# my ld or yours? 48.if ${RUMP_LDSCRIPT} == "sun" 49LDFLAGS+= -Wl,-M ${RUMPTOP}/ldscript_sun.rump 50SRCS+= linksyms_sun.c 51.PATH: ${RUMPTOP} 52.elif ${RUMP_LDSCRIPT} == "GNU" 53LDFLAGS+= -Wl,-T,${RUMPTOP}/ldscript.rump 54.elif ${RUMP_LDSCRIPT} == "ctor" 55CPPFLAGS+= -DRUMP_USE_CTOR 56.else 57.error Unknown ldscript ${RUMP_LDSCRIPT} 58.endif 59.endif 60 61.if defined(RUMP_CURLWP) 62.if ${RUMP_CURLWP} == "hypercall" 63CPPFLAGS+= -DRUMP_CURLWP=RUMP_CURLWP_HYPERCALL 64.elif ${RUMP_CURLWP} == "__thread" 65CPPFLAGS+= -DRUMP_CURLWP=RUMP_CURLWP___THREAD 66.elif ${RUMP_CURLWP} == "register" 67CPPFLAGS+= -DRUMP_CURLWP=RUMP_CURLWP_REGISTER 68.else 69.error Unsupported curlwp scheme: ${RUMP_CURLWP} 70.endif 71.endif 72 73RUMP_DIAGNOSTIC?=yes 74.if ${RUMP_DIAGNOSTIC} == "yes" 75CPPFLAGS+= -DDIAGNOSTIC 76.endif 77 78.ifdef RUMP_DEBUG 79CPPFLAGS+= -DDEBUG 80.endif 81 82.ifdef RUMP_LOCKDEBUG 83CPPFLAGS+= -DLOCKDEBUG 84.endif 85 86RUMP_KTRACE?=yes 87.if ${RUMP_KTRACE} == "yes" 88CPPFLAGS+= -DKTRACE 89.endif 90 91# kernel libs should not get linked against libc 92# XXX: actually, we would like to enable this but cannot, since it 93# also leaves out libgcc, it causes problems on some platforms. 94# revisit some day. 95#LDFLAGS+= -nodefaultlibs 96 97# make sure __NetBSD__ gets defined (for builds on non-NetBSD) 98# also, give those builds a way to undef the local compiler's macros 99CPPFLAGS+= -D__NetBSD__ ${RUMPKERN_UNDEF} 100 101RUMPKERNEL= This is NetBSD and I am the rump. Good evening. 102 103# workaround: evbppc is not a well-defined arch 104.if (${MACHINE} == "evbppc") 105CPPFLAGS+= -DPPC_OEA 106.endif 107 108# If this file changes, we need a full rebuild 109DPSRCS+= ${RUMPTOP}/Makefile.rump 110 111# 112# Support for component-specific hypercalls 113# 114 115# XXX: Warning flags are not in CWARNFLAGS. Manually add a few important ones. 116 117.ifdef RUMPCOMP_USER 118.warning RUMPCOMP_USER is deprecated. Use RUMPCOMP_USER_SRCS 119RUMPCOMP_USER_SRCS= rumpcomp_user.c 120.endif 121.ifdef RUMPCOMP_USER_SRCS && !defined(RUMPKERN_ONLY) 122.if empty(DESTDIR) 123DESTDIR=/ 124.endif 125BUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR} 126RUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:} 127.for rcusrc in ${RUMPCOMP_USER_SRCS:R} 128${rcusrc}.d: ${rcusrc}.c 129 ${_MKTARGET_CREATE} 130 ${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*${rcusrc}.c} 131 132${rcusrc}.o: ${rcusrc}.c 133 ${_MKTARGET_COMPILE} 134 ${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} 135 136${rcusrc}.pico: ${rcusrc}.c 137 ${_MKTARGET_COMPILE} 138 ${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} 139 140${rcusrc}.po: ${rcusrc}.c 141 ${_MKTARGET_COMPILE} 142 ${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} 143 144RUMPOBJ_NORENAME+=${rcusrc}.o ${rcusrc}.pico ${rcusrc}.po 145SRCS+=${rcusrc}.c 146.endfor 147.endif 148 149# 150# Rename library symbols before use. If a symbol does not already belong 151# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns". This 152# avoids accidentally linking any kernel symbol against host platform 153# libraries. The only non-renamed symbols are linkset delimiters and 154# the GOT, which are more a property of the compiler than the kernel. 155# 156# Some toolchains generate unresolved symbols which are supposed to be 157# satisfied by the toolchain itself when the program is linked. 158# Unfortunately, we do not know which of the symbols are generated by 159# the toolchain. Worse, they vary from platform to platform and 160# toolchain to toolchain. The good news, however, is that this will 161# be detected by a compile-time failure, so we can fairly easily manage 162# a quirktable here. 163# 164# We also allow calling ourselves externally with e.g.: 165# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj 166# 167.if ${MACHINE_CPU} == "mips" 168_SYMQUIRK='|_gp_disp' 169.elif ${MACHINE_CPU} == "hppa" 170_SYMQUIRK='|\$$\$$' 171.elif ${MACHINE_ARCH} == "powerpc64" 172_SYMQUIRK="|PF_funcs" 173.endif 174 175# 176# Prefix quirks. At least one toolchain generates global 177# symbols with prefixes which really need to remain as prefixes 178# (i.e. the '.' on the front of some ppc64 globals). The 179# way to know if you have the problem is if you get later 180# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH'; 181# the 'X' part was added by the toolchain and will need to 182# be mentioned here. 183# 184.if ${MACHINE_ARCH} == "powerpc64" 185_PQ="\.?" 186.else 187_PQ= 188.endif 189 190rump_symren: __archivebuild 191.if !defined(RUMP_SYMREN) 192 @echo "Must supply RUMP_SYMREN for target rump_symren" 193 @false 194.endif 195 196# if we are called from lib build (RUMP_SYMREN is not specified), 197# build the arrrrchive. otherwise just rename symbols. 198__archivebuild: .USE 199.if defined(RUMP_SYMREN) && defined(RUMPTOP) 200 @echo "ERROR: RUMP_SYMREN can only be used standalone" 201 @false 202.endif 203.if defined(RUMP_SYMREN) 204 ${_MKMSG} " symbol rename " ${RUMP_SYMREN} 205.else 206 ${_MKTARGET_BUILD} 207 rm -f ${.TARGET} 208.endif 209 for renameobj in ${RUMP_SYMREN:U${.ALLSRC:C/(${RUMPOBJ_NORENAME:ts|})//g}}; do \ 210 ${NM} -go $${renameobj} | ${TOOL_AWK} ' \ 211 $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}'${RUMP_SYM_NORENAME:D|${RUMP_SYM_NORENAME}})/ \ 212 {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\ 213 | sort | uniq > renametab.$${renameobj}; \ 214 ${OBJCOPY} --preserve-dates --redefine-syms \ 215 renametab.$${renameobj} $${renameobj}; \ 216 rm -f renametab.$${renameobj}; \ 217 done 218.if !defined(RUMP_SYMREN) 219 ${AR} ${_ARFL} ${.TARGET} \ 220 `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}` 221.endif 222 223_BSD_IOCONF_MK_USER_=1 224.include <bsd.ioconf.mk> 225 226.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc" 227.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc" 228 229.endif # _RUMP_MK 230