Makefile.rump revision 1.71
1#	$NetBSD: Makefile.rump,v 1.71 2013/03/15 11:15:22 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
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
40LDFLAGS+=	-Wl,-T ${RUMPTOP}/ldscript.rump
41
42RUMP_DIAGNOSTIC?=yes
43.if ${RUMP_DIAGNOSTIC} == "yes"
44CPPFLAGS+=	-DDIAGNOSTIC
45.endif
46
47.ifdef RUMP_DEBUG
48CPPFLAGS+=	-DDEBUG
49.endif
50
51.ifdef RUMP_LOCKDEBUG
52CPPFLAGS+=	-DLOCKDEBUG
53.endif
54
55# kernel libs should not get linked against libc
56# XXX: actually, we would like to enable this but cannot, since it
57# also leaves out libgcc, it causes problems on some platforms.
58# revisit some day.
59#LDFLAGS+=	-nodefaultlibs
60
61# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
62# also, give those builds a way to undef the local compiler's macros
63CPPFLAGS+=	-D__NetBSD__ ${RUMPKERN_UNDEF}
64
65RUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
66
67# workaround: evbppc is not a well-defined arch
68.if (${MACHINE} == "evbppc")
69CPPFLAGS+=	-DPPC_OEA
70.endif
71
72# If this file changes, we need a full rebuild
73DPSRCS+=	${RUMPTOP}/Makefile.rump
74
75#
76# Support for component-specific hypercalls
77#
78
79.ifdef RUMPCOMP_USER
80rumpcomp_user.d: rumpcomp_user.c
81	${_MKTARGET_CREATE}
82	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS:U-isysroot ${DESTDIR}} ${RUMPCOMP_USER_CPPFLAGS} ${.CURDIR}/rumpcomp_user.c
83
84rumpcomp_user.o: rumpcomp_user.c
85	${_MKTARGET_COMPILE}
86	${CC} -o ${.TARGET} ${DBG} ${CWARNFLAGS} ${BUILDRUMP_CPPFLAGS:U-isysroot ${DESTDIR}} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.CURDIR}/rumpcomp_user.c
87
88rumpcomp_user.pico: rumpcomp_user.c
89	${_MKTARGET_COMPILE}
90	${CC} -o ${.TARGET} -fPIC -DPIC ${DBG} ${CWARNFLAGS} ${BUILDRUMP_CPPFLAGS:U-isysroot ${DESTDIR}} ${BUILDRUMP_CFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.CURDIR}/rumpcomp_user.c
91
92rumpcomp_user.po: rumpcomp_user.c
93	${_MKTARGET_COMPILE}
94	${CC} -o ${.TARGET} ${PROFFLAGS} -pg ${DBG} ${CWARNFLAGS} ${BUILDRUMP_CPPFLAGS:U-isysroot ${DESTDIR}} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${RUMPCOMP_USER_CFLAGS} -c ${.CURDIR}/rumpcomp_user.c
95
96RUMPCOMP_USEROBJ=rumpcomp_user.*o
97SRCS+=rumpcomp_user.c
98.endif
99
100#
101# Rename library symbols before use.  If a symbol does not already belong
102# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
103# avoids accidentally linking any kernel symbol against host platform
104# libraries.  The only non-renamed symbols are linkset delimiters and
105# the GOT, which are more a property of the compiler than the kernel.
106#
107# Some toolchains generate unresolved symbols which are supposed to be
108# satisfied by the toolchain itself when the program is linked.
109# Unfortunately, we do not know which of the symbols are generated by
110# the toolchain.  Worse, they vary from platform to platform and
111# toolchain to toolchain.  The good news, however, is that this will
112# be detected by a compile-time failure, so we can fairly easily manage
113# a quirktable here.
114#
115# We also allow calling ourselves externally with e.g.:
116# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
117#
118.if ${MACHINE_CPU} == "mips"
119_SYMQUIRK='|_gp_disp'
120.elif ${MACHINE_CPU} == "hppa"
121_SYMQUIRK='|\$$\$$'
122.elif ${MACHINE_ARCH} == "powerpc64"
123_SYMQUIRK="|PF_funcs"
124.endif
125
126#
127# Prefix quirks.  At least one toolchain generates global
128# symbols with prefixes which really need to remain as prefixes
129# (i.e. the '.' on the front of some ppc64 globals).  The
130# way to know if you have the problem is if you get later
131# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
132# the 'X' part was added by the toolchain and will need to
133# be mentioned here.
134# 
135.if ${MACHINE_ARCH} == "powerpc64"
136_PQ="\.?"
137.else
138_PQ=
139.endif
140
141rump_symren: __archivebuild
142.if !defined(RUMP_SYMREN)
143	@echo "Must supply RUMP_SYMREN for target rump_symren"
144	@false
145.endif
146
147# if we are called from lib build (RUMP_SYMREN is not specified),
148# build the arrrrchive.  otherwise just rename symbols.
149__archivebuild: .USE
150.if defined(RUMP_SYMREN) && defined(RUMPTOP)
151	@echo "ERROR: RUMP_SYMREN can only be used standalone"
152	@false
153.endif
154.if defined(RUMP_SYMREN)
155	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
156.else
157	${_MKTARGET_BUILD}
158	rm -f ${.TARGET}
159.endif
160	for obj in ${RUMP_SYMREN:U${.ALLSRC:N${RUMPCOMP_USEROBJ}}}; do \
161		${NM} -go $${obj} | ${TOOL_AWK} ' \
162		    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
163		      {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
164		    | sort | uniq  > renametab.$${obj}; \
165		${OBJCOPY} --preserve-dates --redefine-syms \
166		    renametab.$${obj} $${obj}; \
167		rm -f renametab.$${obj}; \
168	done
169.if !defined(RUMP_SYMREN)
170	${AR} ${_ARFL} ${.TARGET} \
171	    `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
172.endif
173
174_BSD_IOCONF_MK_USER_=1
175.include <bsd.ioconf.mk>
176
177.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
178.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"
179