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