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