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