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