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