1# kern.pre.mk 2# 3# Unified Makefile for building kernels. This includes all the definitions 4# that need to be included before %BEFORE_DEPEND 5# 6# $FreeBSD$ 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 34COPTS= ${INCLUDES} -D_KERNEL -include opt_global.h 35CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} -fno-common 36 37# XXX LOCORE means "don't declare C stuff" not "for locore.s". 38ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 39 40.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1 41CFLAGS+= -DGPROF -falign-functions=16 42.if ${PROFLEVEL} >= 2 43CFLAGS+= -DGPROF4 -DGUPROF 44# XXX -Wno-inline is to break some warnings. 45PROF= -finstrument-functions -Wno-inline 46.else 47PROF= -pg 48.endif 49.endif 50DEFINED_PROF= ${PROF} 51WERROR?= -Werror 52 53# Put configuration-specific C flags last (except for ${PROF}) so that they 54# can override the others. 55CFLAGS+= ${CONF_CFLAGS} 56 57NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 58NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} 59PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} 60NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 61 62NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ 63 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c 64 65GEN_CFILES= $S/$M/$M/genassym.c 66SYSTEM_CFILES= config.c env.c hints.c majors.c vnode_if.c 67SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 68SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS} 69SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o} 70SYSTEM_OBJS+= hack.So 71SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \ 72 -warn-common -export-dynamic -dynamic-linker /red/herring \ 73 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 74SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 75 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET} 76SYSTEM_DEP+= $S/conf/ldscript.$M 77 78# MKMODULESENV is set here so that port makefiles can augment 79# them. 80 81MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 82.if (${KERN_IDENT} == LINT) 83MKMODULESENV+= ALL_MODULES=LINT 84.endif 85.if defined(MODULES_OVERRIDE) 86MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 87.endif 88.if defined(DEBUG) 89MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}" 90.endif 91