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$ 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. 50CFLAGS+= ${FMT} 51 52DEFINED_PROF= ${PROF} 53.if defined(PROF) 54CFLAGS+= -malign-functions=4 55.if ${PROFLEVEL} >= 2 56IDENT+= -DGPROF4 -DGUPROF 57PROF+= -mprofiler-epilogue 58.endif 59.endif 60 61.if defined(NO_WERROR) 62WERROR= 63.else 64WERROR?= -Werror 65.endif 66 67# Put configuration-specific C flags last (except for ${PROF}) so that they 68# can override the others. 69CFLAGS+= ${CONF_CFLAGS} 70 71NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 72NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} 73PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} 74NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 75 76NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk $< -c ; \ 77 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c 78 79GEN_CFILES= $S/$M/$M/genassym.c 80SYSTEM_CFILES= vnode_if.c hints.c env.c config.c 81SYSTEM_SFILES= $S/$M/$M/locore.s 82SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 83SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} hints.o env.o config.o hack.So 84SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \ 85 -warn-common -export-dynamic -dynamic-linker /red/herring \ 86 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 87SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 88 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET} 89SYSTEM_DEP+= $S/conf/ldscript.$M 90 91# MKMODULESENV is set here so that port makefiles can augment 92# them. 93 94MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 95.if (${KERN_IDENT} == LINT) 96MKMODULESENV+= ALL_MODULES=LINT 97.endif 98.if defined(MODULES_OVERRIDE) 99MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 100.endif 101.if defined(DEBUG) 102MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}" 103.endif 104 105all: ${KERNEL_KO} 106