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