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