kern.pre.mk revision 91002
185909Simp# kern.pre.mk
285909Simp#
385909Simp# Unified Makefile for building kenrels.  This includes all the definitions
485909Simp# that need to be included before %BEFORE_DEPEND
585909Simp#
685909Simp# $FreeBSD: head/sys/conf/kern.pre.mk 91002 2002-02-20 23:35:56Z peter $
785909Simp#
885909Simp
985909Simp# Can be overridden by makeoptions or /etc/make.conf
1085909SimpKERNEL_KO?=	kernel
1185909SimpKERNEL?=	kernel
1285909SimpKODIR?=		/boot/${KERNEL}
1385909Simp
1485909SimpM=	${MACHINE_ARCH}
1585909Simp
1685909SimpNM?=		nm
1785909SimpOBJCOPY?=	objcopy
1885909SimpSIZE?=		size
1985909Simp
2085909SimpCOPTFLAGS?=-O -pipe
2185909Simp.if !defined(NO_CPU_COPTFLAGS)
2285909SimpCOPTFLAGS+= ${_CPUCFLAGS}
2385909Simp.endif
2485909SimpINCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev
2585909Simp
2685909Simp# This hack lets us use the Intel ACPICA code without spamming a new 
2785909Simp# include path into 100+ source files.
2885909SimpINCLUDES+= -I$S/contrib/dev/acpica
2985909Simp
3085909Simp# ... and the same for ipfilter
3185909SimpINCLUDES+= -I$S/contrib/ipfilter
3285909Simp
3385909Simp# This hack is to allow kernel compiles to succeed on machines w/out srcdist
3485909Simp.if exists($S/../include)
3585909SimpINCLUDES+= -I$S/../include
3685909Simp.else
3785909SimpINCLUDES+= -I/usr/include
3885909Simp.endif
3985909Simp
4087451SobrienCOPTS=	${INCLUDES} ${IDENT} -D_KERNEL -ffreestanding -include opt_global.h
4189180SmsmithCFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} -fno-common
4285909Simp
4385909Simp# XXX LOCORE means "don't declare C stuff" not "for locore.s".
4485909SimpASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
4585909Simp
4685909Simp# Select the correct set of tools. Can't set OBJFORMAT here because it
4785909Simp# doesn't get exported into the environment, and if it were exported
4885909Simp# then it might break building of utilities.
4985909SimpFMT?=		-elf
5085909SimpCFLAGS+=	${FMT}
5185909Simp
5285909SimpDEFINED_PROF=	${PROF}
5385909Simp.if defined(PROF)
5485909SimpCFLAGS+=	-malign-functions=4
5585909Simp.if ${PROFLEVEL} >= 2
5685909SimpIDENT+=	-DGPROF4 -DGUPROF
5785909SimpPROF+=	-mprofiler-epilogue
5885909Simp.endif
5985909Simp.endif
6085909Simp
6191002Speter#.if defined(NO_WERROR)
6291002Speter#WERROR=
6391002Speter#.else
6491002Speter#WERROR?=	-Werror
6591002Speter#.endif
6691002Speter
6785909Simp# Put configuration-specific C flags last (except for ${PROF}) so that they
6885909Simp# can override the others.
6985909SimpCFLAGS+=	${CONF_CFLAGS}
7085909Simp
7191002SpeterNORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
7291002SpeterNORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
7391002SpeterPROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
7491002SpeterNORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
7585909Simp
7685909SimpNORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \
7785909Simp	  ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
7885909Simp
7985909SimpGEN_CFILES= $S/$M/$M/genassym.c
8085909SimpSYSTEM_CFILES= vnode_if.c hints.c env.c config.c
8185909SimpSYSTEM_SFILES= $S/$M/$M/locore.s
8285909SimpSYSTEM_DEP= Makefile ${SYSTEM_OBJS}
8385909SimpSYSTEM_OBJS= locore.o vnode_if.o ${OBJS} hints.o env.o config.o hack.So
8485909SimpSYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \
8589180Smsmith	-warn-common -export-dynamic -dynamic-linker /red/herring \
8685909Simp	-o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
8785909SimpSYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
8885909Simp	${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET}
8985909SimpSYSTEM_DEP+= $S/conf/ldscript.$M
9085909Simp
9188893Simp# MKMODULESENV is set here so that port makefiles can augment
9288893Simp# them.
9388893Simp
9488893SimpMKMODULESENV=	MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
9590789Sphk.if (${KERN_IDENT} == LINT)
9690789SphkMKMODULESENV+=	ALL_MODULES=LINT
9790789Sphk.endif
9888893Simp.if defined(MODULES_OVERRIDE)
9988893SimpMKMODULESENV+=	MODULES_OVERRIDE="${MODULES_OVERRIDE}"
10088893Simp.endif
10188893Simp.if defined(DEBUG)
10288893SimpMKMODULESENV+=	DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
10388893Simp.endif
10488893Simp
10586253Simpall:	${KERNEL_KO}
106