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