[BACK]Return to Makefile.rump CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / rump

File: [cvs.NetBSD.org] / src / sys / rump / Makefile.rump (download)

Revision 1.91, Thu Mar 13 01:34:06 2014 UTC (10 years ago) by pooka
Branch: MAIN
Changes since 1.90: +23 -17 lines

Allow multiple "rumpcomp_user" source modules to be specified by
introducing RUMPCOMP_USER_SRCS.  Make RUMPCOMP_USER issue a deprecation
warning, but for compat make it set RUMPCOMP_USER_SRCS=rumpcomp_user.c
for now.

#	$NetBSD: Makefile.rump,v 1.91 2014/03/13 01:34:06 pooka Exp $
#

WARNS?=		3	# XXX: src/sys won't compile with -Wsign-compare yet
NOLINT=		# kernel code

.include <bsd.own.mk>

# Use NetBSD kernel ABI by default on x86 archs.  Performance-related
# compile-time options may override this at a later date.
.if ${MACHINE_ARCH} == "i386" || \
    ${MACHINE_ARCH} == "x86_64"
_RUMP_NATIVEABI= yes
CPPFLAGS+=	-D_RUMP_NATIVE_ABI
.else
_RUMP_NATIVEABI= no
CPPFLAGS:=	-I${RUMPTOP}/include ${CPPFLAGS}
CPPFLAGS+=	-D_RUMPKERNEL
.endif

CPPFLAGS+=	-DMAXUSERS=32
CPPFLAGS+=	-DCOMPAT_50=1 -DCOMPAT_60=1

CPPFLAGS+=	-nostdinc
CFLAGS+=	-ffreestanding -fno-strict-aliasing

CWARNFLAGS+=	-Wno-format-zero-length -Wno-pointer-sign
CPPFLAGS+=	-D_KERNEL -DMULTIPROCESSOR -D_MODULE -DMODULAR
CPPFLAGS+=	-DDEBUGPRINT
CPPFLAGS+=	-I${.CURDIR} -I.
CPPFLAGS+=	-I${RUMPTOP}/../../common/include
CPPFLAGS+=	-I${RUMPTOP}/include
CPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern/opt

.ifdef NEED_ISYSTEM
CPPFLAGS+=	-isystem ${RUMPTOP}/../arch
CPPFLAGS+=	-isystem ${RUMPTOP}/..
.else
CPPFLAGS+=	-I${RUMPTOP}/../arch
CPPFLAGS+=	-I${RUMPTOP}/..
.endif

RUMP_LDSCRIPT?=yes
.if ${RUMP_LDSCRIPT} != "no"
# my ld or yours?
.ifdef HAVE_SUN_LD
LDFLAGS+=	-Wl,-M ${RUMPTOP}/ldscript_sun.rump
SRCS+=		linksyms_sun.c
.PATH:		${RUMPTOP}
.else
LDFLAGS+=	-Wl,-T,${RUMPTOP}/ldscript.rump
.endif
.endif

RUMP_DIAGNOSTIC?=yes
.if ${RUMP_DIAGNOSTIC} == "yes"
CPPFLAGS+=	-DDIAGNOSTIC
.endif

.ifdef RUMP_DEBUG
CPPFLAGS+=	-DDEBUG
.endif

.ifdef RUMP_LOCKDEBUG
CPPFLAGS+=	-DLOCKDEBUG
.endif

RUMP_KTRACE?=yes
.if ${RUMP_KTRACE} == "yes"
CPPFLAGS+=	-DKTRACE
.endif

# kernel libs should not get linked against libc
# XXX: actually, we would like to enable this but cannot, since it
# also leaves out libgcc, it causes problems on some platforms.
# revisit some day.
#LDFLAGS+=	-nodefaultlibs

# make sure __NetBSD__ gets defined (for builds on non-NetBSD)
# also, give those builds a way to undef the local compiler's macros
CPPFLAGS+=	-D__NetBSD__ ${RUMPKERN_UNDEF}

RUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.

# workaround: evbppc is not a well-defined arch
.if (${MACHINE} == "evbppc")
CPPFLAGS+=	-DPPC_OEA
.endif

# If this file changes, we need a full rebuild
DPSRCS+=	${RUMPTOP}/Makefile.rump

#
# Support for component-specific hypercalls
#

# XXX: Warning flags are not in CWARNFLAGS.  Manually add a few important ones.

.ifdef RUMPCOMP_USER
.warning RUMPCOMP_USER is deprecated.  Use RUMPCOMP_USER_SRCS
RUMPCOMP_USER_SRCS= rumpcomp_user.c
.endif
.ifdef RUMPCOMP_USER_SRCS && !defined(RUMPKERN_ONLY)
.if empty(DESTDIR)
DESTDIR=/
.endif
BUILDRUMP_CPPFLAGS ?= -isysroot ${DESTDIR}
RUMPCOMP_USER_WERROR = ${${_NOWERROR} == "no" :?-Werror:}
.for rcusrc in ${RUMPCOMP_USER_SRCS:R}
${rcusrc}.d: ${rcusrc}.c
	${_MKTARGET_CREATE}
	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} ${BUILDRUMP_CPPFLAGS} ${RUMPCOMP_USER_CPPFLAGS} ${.ALLSRC:O:u:M*${rcusrc}.c}

${rcusrc}.o: ${rcusrc}.c
	${_MKTARGET_COMPILE}
	${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}

${rcusrc}.pico: ${rcusrc}.c
	${_MKTARGET_COMPILE}
	${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}

${rcusrc}.po: ${rcusrc}.c
	${_MKTARGET_COMPILE}
	${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}

RUMPOBJ_NORENAME+=${rcusrc}.o ${rcusrc}.pico ${rcusrc}.po
SRCS+=${rcusrc}.c
.endfor
.endif

#
# Rename library symbols before use.  If a symbol does not already belong
# to a rump namespace ("rump" or "RUMP"), prefix it with "rumpns".  This
# avoids accidentally linking any kernel symbol against host platform
# libraries.  The only non-renamed symbols are linkset delimiters and
# the GOT, which are more a property of the compiler than the kernel.
#
# Some toolchains generate unresolved symbols which are supposed to be
# satisfied by the toolchain itself when the program is linked.
# Unfortunately, we do not know which of the symbols are generated by
# the toolchain.  Worse, they vary from platform to platform and
# toolchain to toolchain.  The good news, however, is that this will
# be detected by a compile-time failure, so we can fairly easily manage
# a quirktable here.
#
# We also allow calling ourselves externally with e.g.:
# make -f /sys/rump/Makefile.rump RUMP_SYMREN=ffs.kobj
#
.if ${MACHINE_CPU} == "mips"
_SYMQUIRK='|_gp_disp'
.elif ${MACHINE_CPU} == "hppa"
_SYMQUIRK='|\$$\$$'
.elif ${MACHINE_ARCH} == "powerpc64"
_SYMQUIRK="|PF_funcs"
.endif

#
# Prefix quirks.  At least one toolchain generates global
# symbols with prefixes which really need to remain as prefixes
# (i.e. the '.' on the front of some ppc64 globals).  The
# way to know if you have the problem is if you get later
# complaints about symbols like 'rumpns_XrumpBLAH' or 'XrumpBLAH';
# the 'X' part was added by the toolchain and will need to
# be mentioned here.
# 
.if ${MACHINE_ARCH} == "powerpc64"
_PQ="\.?"
.else
_PQ=
.endif

rump_symren: __archivebuild
.if !defined(RUMP_SYMREN)
	@echo "Must supply RUMP_SYMREN for target rump_symren"
	@false
.endif

# if we are called from lib build (RUMP_SYMREN is not specified),
# build the arrrrchive.  otherwise just rename symbols.
__archivebuild: .USE
.if defined(RUMP_SYMREN) && defined(RUMPTOP)
	@echo "ERROR: RUMP_SYMREN can only be used standalone"
	@false
.endif
.if defined(RUMP_SYMREN)
	${_MKMSG} " symbol rename " ${RUMP_SYMREN}
.else
	${_MKTARGET_BUILD}
	rm -f ${.TARGET}
.endif
	for renameobj in ${RUMP_SYMREN:U${.ALLSRC:C/(${RUMPOBJ_NORENAME:ts|})//g}}; do \
		${NM} -go $${renameobj} | ${TOOL_AWK} ' \
		    $$NF!~/^'${_PQ}'(rump|RUMP|__|_GLOBAL_OFFSET_TABLE'${_SYMQUIRK}')/ \
		      {s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
		    | sort | uniq  > renametab.$${renameobj}; \
		${OBJCOPY} --preserve-dates --redefine-syms \
		    renametab.$${renameobj} $${renameobj}; \
		rm -f renametab.$${renameobj}; \
	done
.if !defined(RUMP_SYMREN)
	${AR} ${_ARFL} ${.TARGET} \
	    `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
.endif

_BSD_IOCONF_MK_USER_=1
.include <bsd.ioconf.mk>

.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE_CPU}/include/Makefile.inc"
.-include "${NETBSDSRCDIR}/sys/arch/${MACHINE}/include/Makefile.inc"