Makefile.rump revision 1.65
1# $NetBSD: Makefile.rump,v 1.65 2012/11/21 17:48:05 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 18CFLAGS+= -ffreestanding -fno-strict-aliasing 19.if (defined(HAVE_GCC) && ${HAVE_GCC} >= 3) || defined(HAVE_LLVM) 20CFLAGS+= -Wsign-compare 21CFLAGS+= -Wno-pointer-sign -Wno-attributes 22CFLAGS+= -std=gnu99 23.endif 24CWARNFLAGS+= -Wno-format-zero-length -Wno-pointer-sign 25CPPFLAGS+= -D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR 26CPPFLAGS+= -DMAXUSERS=32 27CPPFLAGS+= -DCOMPAT_50=1 28CPPFLAGS+= -DDEBUGPRINT 29CPPFLAGS+= -I${.CURDIR} -I. 30CPPFLAGS+= -I${RUMPTOP}/../../common/include 31CPPFLAGS+= -I${RUMPTOP}/include 32CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern/opt 33CPPFLAGS+= -nostdinc 34 35.ifdef NEED_ISYSTEM 36CPPFLAGS+= -isystem ${RUMPTOP}/../arch 37CPPFLAGS+= -isystem ${RUMPTOP}/.. 38.else 39CPPFLAGS+= -I${RUMPTOP}/../arch 40CPPFLAGS+= -I${RUMPTOP}/.. 41.endif 42 43LDFLAGS+= -T ${RUMPTOP}/ldscript.rump 44 45RUMP_DIAGNOSTIC?=yes 46.if ${RUMP_DIAGNOSTIC} == "yes" 47CPPFLAGS+= -DDIAGNOSTIC 48.endif 49 50.ifdef RUMP_DEBUG 51CPPFLAGS+= -DDEBUG 52.endif 53 54.ifdef RUMP_LOCKDEBUG 55CPPFLAGS+= -DLOCKDEBUG 56.endif 57 58# kernel libs should not get linked against libc 59# XXX: actually, we would like to enable this but cannot, since it 60# also leaves out libgcc, it causes problems on some platforms. 61# revisit some day. 62#LDFLAGS+= -nodefaultlibs 63 64# make sure __NetBSD__ gets defined (for builds on non-NetBSD) 65# aaand make sure cc doesn't source files any wild ideas 66CPPFLAGS+= -D__NetBSD__ 67CPPFLAGS+= -Ulinux -U__linux -U__linux__ -U__gnu_linux__ 68 69RUMPKERNEL= This is NetBSD and I am the rump. Good evening. 70 71# workaround: evbppc is not a well-defined arch 72.if (${MACHINE} == "evbppc") 73CPPFLAGS+= -DPPC_OEA 74.endif 75 76# If this file changes, we need a full rebuild 77DPSRCS+= ${RUMPTOP}/Makefile.rump 78 79# 80# Rename library symbols before use. If a symbol does not already belong 81# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns". This 82# avoids accidentally linking any kernel symbol against host platform 83# libraries. The only non-renamed symbols are linkset delimiters and 84# the GOT, which are more a property of the compiler than the kernel. 85# 86# Some toolchains generate unresolved symbols which are supposed to be 87# satisfied by the toolchain itself when the program is linked. 88# Unfortunately, we do not know which of the symbols are generated by 89# the toolchain. Worse, they vary from platform to platform and 90# toolchain to toolchain. The good news, however, is that this will 91# be detected by a compile-time failure, so we can fairly easily manage 92# a quirktable here. 93# 94# We also allow calling ourselves externally with e.g.: 95# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj 96# 97.if ${MACHINE_CPU} == "mips" 98_SYMQUIRK='|_gp_disp' 99.elif ${MACHINE_CPU} == "hppa" 100_SYMQUIRK='|\$$\$$' 101.elif ${MACHINE_ARCH} == "powerpc64" 102_SYMQUIRK="|PF_funcs" 103.endif 104 105# 106# Prefix quirks. At least one toolchain generates global 107# symbols with prefixes which really need to remain as prefixes 108# (i.e. the '.' on the front of some ppc64 globals). The 109# way to know if you have the problem is if you get later 110# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH'; 111# the 'X' part was added by the toolchain and will need to 112# be mentioned here. 113# 114.if ${MACHINE_ARCH} == "powerpc64" 115_PQ="\.?" 116.else 117_PQ= 118.endif 119 120rump_symren: __archivebuild 121.if !defined(RUMP_SYMREN) 122 @echo "Must supply RUMP_SYMREN for target rump_symren" 123 @false 124.endif 125 126# if we are called from lib build (RUMP_SYMREN is not specified), 127# build the arrrrchive. otherwise just rename symbols. 128__archivebuild: .USE 129.if defined(RUMP_SYMREN) && defined(RUMPTOP) 130 @echo "ERROR: RUMP_SYMREN can only be used standalone" 131 @false 132.endif 133.if defined(RUMP_SYMREN) 134 ${_MKMSG} " symbol rename " ${RUMP_SYMREN} 135.else 136 ${_MKTARGET_BUILD} 137 rm -f ${.TARGET} 138 ${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}` 139.endif 140 ${NM} -go ${RUMP_SYMREN:U${.TARGET}} | ${TOOL_AWK} ' \ 141 $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \ 142 {s = $$NF; sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}' \ 143 | sort | uniq > renametab.${.TARGET} 144 ${OBJCOPY} --preserve-dates --redefine-syms \ 145 renametab.${.TARGET} ${RUMP_SYMREN:U${.TARGET}} 146 rm -f renametab.${.TARGET} 147.if !defined(RUMP_SYMREN) 148 ${AR} ${_ARRANFL} ${.TARGET} 149.endif 150 151_BSD_IOCONF_MK_USER_=1 152.include <bsd.ioconf.mk> 153 154.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc" 155.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc" 156