kern.pre.mk revision 91512
1# kern.pre.mk 2# 3# Unified Makefile for building kenrels. This includes all the definitions 4# that need to be included before %BEFORE_DEPEND 5# 6# $FreeBSD: head/sys/conf/kern.pre.mk 91512 2002-03-01 01:21:29Z obrien $ 7# 8 9# Can be overridden by makeoptions or /etc/make.conf 10KERNEL_KO?= kernel 11KERNEL?= kernel 12KODIR?= /boot/${KERNEL} 13 14M= ${MACHINE_ARCH} 15 16AWK?= awk 17NM?= nm 18OBJCOPY?= objcopy 19SIZE?= size 20 21COPTFLAGS?=-O -pipe 22.if !defined(NO_CPU_COPTFLAGS) 23COPTFLAGS+= ${_CPUCFLAGS} 24.endif 25INCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev 26 27# This hack lets us use the Intel ACPICA code without spamming a new 28# include path into 100+ source files. 29INCLUDES+= -I$S/contrib/dev/acpica 30 31# ... and the same for ipfilter 32INCLUDES+= -I$S/contrib/ipfilter 33 34# This hack is to allow kernel compiles to succeed on machines w/out srcdist 35.if exists($S/../include) 36INCLUDES+= -I$S/../include 37.else 38INCLUDES+= -I/usr/include 39.endif 40 41COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -ffreestanding -include opt_global.h 42CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} -fno-common 43 44# XXX LOCORE means "don't declare C stuff" not "for locore.s". 45ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 46 47# Select the correct set of tools. Can't set OBJFORMAT here because it 48# doesn't get exported into the environment, and if it were exported 49# then it might break building of utilities. 50FMT?= -elf 51CFLAGS+= ${FMT} 52 53DEFINED_PROF= ${PROF} 54.if defined(PROF) 55CFLAGS+= -malign-functions=4 56.if ${PROFLEVEL} >= 2 57IDENT+= -DGPROF4 -DGUPROF 58PROF+= -mprofiler-epilogue 59.endif 60.endif 61 62.if defined(NO_WERROR) 63WERROR= 64.else 65WERROR?= -Werror 66.endif 67 68# Put configuration-specific C flags last (except for ${PROF}) so that they 69# can override the others. 70CFLAGS+= ${CONF_CFLAGS} 71 72NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 73NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} 74PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} 75NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 76 77NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \ 78 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c 79 80GEN_CFILES= $S/$M/$M/genassym.c 81SYSTEM_CFILES= vnode_if.c hints.c env.c config.c 82SYSTEM_SFILES= $S/$M/$M/locore.s 83SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 84SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} hints.o env.o config.o hack.So 85SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \ 86 -warn-common -export-dynamic -dynamic-linker /red/herring \ 87 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 88SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 89 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET} 90SYSTEM_DEP+= $S/conf/ldscript.$M 91 92# MKMODULESENV is set here so that port makefiles can augment 93# them. 94 95MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 96.if (${KERN_IDENT} == LINT) 97MKMODULESENV+= ALL_MODULES=LINT 98.endif 99.if defined(MODULES_OVERRIDE) 100MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 101.endif 102.if defined(DEBUG) 103MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}" 104.endif 105 106all: ${KERNEL_KO} 107