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