Makefile.rump revision 1.54
1#	$NetBSD: Makefile.rump,v 1.54 2010/03/22 05:39:00 mrg 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}
13.endif
14
15CFLAGS+=	-ffreestanding -fno-strict-aliasing
16CWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
17CPPFLAGS+=	-D_RUMPKERNEL
18CPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
19CPPFLAGS+=	-DMAXUSERS=32
20CPPFLAGS+=	-DDIAGNOSTIC
21CPPFLAGS+=	-DCOMPAT_50
22CPPFLAGS+=	-DDEBUGPRINT
23CPPFLAGS+=	-I${.CURDIR} -I.
24CPPFLAGS+=	-I${RUMPTOP}/../../common/include -I${RUMPTOP}/../arch
25CPPFLAGS+=	-I${RUMPTOP}/include
26CPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt
27CPPFLAGS+=	-nostdinc -I${RUMPTOP}/..
28LDFLAGS+=	-T ${RUMPTOP}/ldscript.rump
29#CPPFLAGS+=	-DDEBUG
30
31# kernel libs should not get linked against libc
32# XXX: actually, we would like to enable this but cannot, since it
33# also leaves out libgcc, it causes problems on some platforms.
34# revisit some day.
35#LDFLAGS+=	-nodefaultlibs
36
37# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
38CPPFLAGS+=	-D__NetBSD__
39
40RUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
41
42# workaround: evbppc is not a well-defined arch
43.if (${MACHINE} == "evbppc")
44CPPFLAGS+=	-DPPC_OEA
45.endif
46
47# If this file changes, we need a full rebuild
48DPSRCS+=	${RUMPTOP}/Makefile.rump
49
50#
51# Rename library symbols before use.  If a symbol does not already belong
52# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
53# avoids accidentally linking any kernel symbol against host platform
54# libraries.  The only non-renamed symbols are linkset delimiters and
55# the GOT, which are more a property of the compiler than the kernel.
56#
57# Some toolchains generate unresolved symbols which are supposed to be
58# satisfied by the toolchain itself when the program is linked.
59# Unfortunately, we do not know which of the symbols are generated by
60# the toolchain.  Worse, they vary from platform to platform and
61# toolchain to toolchain.  The good news, however, is that this will
62# be detected by a compile-time failure, so we can fairly easily manage
63# a quirktable here.
64#
65# We also allow calling ourselves externally with e.g.:
66# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
67#
68.if ${MACHINE_CPU} == "mips"
69_SYMQUIRK='|_gp_disp'
70.elif ${MACHINE_CPU} == "hppa"
71_SYMQUIRK='|\$$\$$'
72.elif ${MACHINE_ARCH} == "powerpc64"
73_SYMQUIRK='|\.(rump|RUMP)'
74.endif
75
76rump_symren: __archivebuild
77.if !defined(RUMP_SYMREN)
78	@echo "Must supply RUMP_SYMREN for target rump_symren"
79	@false
80.endif
81
82# if we are called from lib build (RUMP_SYMREN is not specified),
83# build the arrrrchive.  otherwise just rename symbols.
84__archivebuild: .USE
85.if defined(RUMP_SYMREN) && defined(RUMPTOP)
86	@echo "ERROR: RUMP_SYMREN can only be used standalone"
87	@false
88.endif
89.if defined(RUMP_SYMREN)
90	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
91.else
92	${_MKTARGET_BUILD}
93	rm -f ${.TARGET}
94	${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
95.endif
96	${NM} -go ${RUMP_SYMREN:U${.TARGET}} | ${TOOL_AWK} '	\
97	    $$NF!~/^(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
98	      {printf "%s rumpns_%s\n", $$NF, $$NF}' \
99	    | sort | uniq  > renametab.${.TARGET}
100	${OBJCOPY} --preserve-dates --redefine-syms \
101	    renametab.${.TARGET} ${RUMP_SYMREN:U${.TARGET}}
102	rm -f renametab.${.TARGET}
103.if !defined(RUMP_SYMREN)
104	${AR} ${_ARRANFL} ${.TARGET}
105.endif
106
107_BSD_IOCONF_MK_USER_=1
108.include <bsd.ioconf.mk>
109
110.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
111.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
112