* Move /kernel to /boot/kernel and /modules to /boot/modules.
[dragonfly.git] / sys / conf / kern.pre.mk
CommitLineData
f4e821f3 1# $DragonFly: src/sys/conf/kern.pre.mk,v 1.6 2008/09/01 19:39:47 dillon Exp $
edbe133c
SS
2#
3# This Makefile covers the top part of the MI kernel build instructions
4#
5
6# Can be overridden by makeoptions or /etc/make.conf
7KERNEL?= kernel
8
9# build this target if none is specified on the command line
10.MAIN: all
11
a9295349
MD
12# Set the platform and machine architectures
13#
0955fd91 14P= ${MACHINE_PLATFORM}
edbe133c
SS
15M= ${MACHINE_ARCH}
16
17SIZE?= size
18OBJCOPY?= objcopy
19
20COPTFLAGS?=-O -pipe
21.if !defined(NO_CPU_COPTFLAGS)
22COPTFLAGS+= ${_CPUCFLAGS}
23.endif
24# don't use -I- so we can use proper source-relative locality for local
a9295349
MD
25# includes.
26#
27# -I. - this is to access the opt_*.h and use_*.h header files generated
28# in the kernel build directory.
29#
30# -Iinclude
31# - this is used to access forwarding header files for
32# <machine/*.h> that exist in the cpu architecture but do not
33# exist in the platform (machine/) architecture. This allows
34# the platform to trivially override the cpu header files.
35#
36INCLUDES= -nostdinc -I. -Iinclude -I$S
edbe133c
SS
37# This hack is to allow kernel compiles to succeed on machines w/out srcdist
38.if exists($S/../include)
39INCLUDES+= -I$S/../include
40.else
41INCLUDES+= -I/usr/include
42.endif
43
44# This hack lets us use the Intel ACPICA code without spamming a new
45# include path into 100+ source files.
46.include "$S/conf/acpi.mk"
47INCLUDES+= -I${.OBJDIR} -I"$S/${OSACPI_MI_DIR}" -I"$S/${ACPICA_DIR}/include"
48
49# This hack lets us use the ipfilter code without spamming a new
50# include path into 100+ source files.
51INCLUDES+= -I$S/contrib/ipfilter
52
53COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
54CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
55
56# XXX LOCORE means "don't declare C stuff" not "for locore.s".
57ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
58
59DEFINED_PROF= ${PROF}
60.if defined(PROF)
61CFLAGS+= -falign-functions=16
62.if ${PROFLEVEL} >= 2
63IDENT+= -DGPROF4 -DGUPROF
64PROF+= -mprofiler-epilogue
65.endif
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} ${PROF} ${.IMPSRC}
73NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
74NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
75PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
76
77NORMAL_M= awk -f $S/tools/makeobjops.awk -- -c $<; \
78 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
79
0955fd91 80GEN_CFILES= $S/platform/$P/$M/genassym.c
edbe133c 81SYSTEM_CFILES= ioconf.c config.c
0955fd91 82SYSTEM_SFILES= $S/platform/$P/$M/locore.s
edbe133c
SS
83SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
84SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
0955fd91 85SYSTEM_LD= @${LD} -Bdynamic -T $S/platform/$P/conf/ldscript.$M \
edbe133c
SS
86 -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} ${.TARGET} ; chmod 755 ${.TARGET}
0955fd91 90SYSTEM_DEP+= $S/platform/$P/conf/ldscript.$M
edbe133c
SS
91
92# Normalize output files to make it absolutely crystal clear to
93# anyone examining the build directory.
94#
95.if defined(DEBUG)
96FULLKERNEL= ${KERNEL}.debug
97.if defined(INSTALLSTRIPPED)
98SELECTEDKERNEL= ${KERNEL}.stripped
99.else
100SELECTEDKERNEL= ${KERNEL}.debug
101.endif
102.else
103FULLKERNEL= ${KERNEL}.nodebug
104SELECTEDKERNEL= ${KERNEL}.stripped
105.endif
f4e821f3
MD
106DESTKERNNAME?= boot/${KERNEL}
107CHECKKERNNAME?= ${KERNEL}
edbe133c
SS
108
109
110MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR} BUILDING_WITH_KERNEL=${.OBJDIR}
111.if defined(MODULES_OVERRIDE)
112MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
113.endif
114.if defined(DEBUG)
115MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
116.endif
117.if defined(INSTALLSTRIPPED) || defined(INSTALLSTRIPPEDMODULES)
118MKMODULESENV+= INSTALLSTRIPPEDMODULES=1
119.endif
120