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