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