kern.pre.mk revision 91002
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 91002 2002-02-20 23:35:56Z peter $
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
16NM?=		nm
17OBJCOPY?=	objcopy
18SIZE?=		size
19
20COPTFLAGS?=-O -pipe
21.if !defined(NO_CPU_COPTFLAGS)
22COPTFLAGS+= ${_CPUCFLAGS}
23.endif
24INCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev
25
26# This hack lets us use the Intel ACPICA code without spamming a new 
27# include path into 100+ source files.
28INCLUDES+= -I$S/contrib/dev/acpica
29
30# ... and the same for ipfilter
31INCLUDES+= -I$S/contrib/ipfilter
32
33# This hack is to allow kernel compiles to succeed on machines w/out srcdist
34.if exists($S/../include)
35INCLUDES+= -I$S/../include
36.else
37INCLUDES+= -I/usr/include
38.endif
39
40COPTS=	${INCLUDES} ${IDENT} -D_KERNEL -ffreestanding -include opt_global.h
41CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} -fno-common
42
43# XXX LOCORE means "don't declare C stuff" not "for locore.s".
44ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
45
46# Select the correct set of tools. Can't set OBJFORMAT here because it
47# doesn't get exported into the environment, and if it were exported
48# then it might break building of utilities.
49FMT?=		-elf
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)
62#WERROR=
63#.else
64#WERROR?=	-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= perl5 $S/kern/makeobjops.pl -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