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