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