357f0b10bc1973f3f8c5d51602cf498066fa98b8
[dragonfly.git] / sys / conf / kern.pre.mk
1 # $DragonFly: src/sys/conf/kern.pre.mk,v 1.8 2008/11/17 11:55:19 swildner Exp $
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
7 KERNEL?=        kernel
8
9 # build this target if none is specified on the command line
10 .MAIN:  all
11
12 # Set the platform and machine architectures
13 #
14 P=      ${MACHINE_PLATFORM}
15 M=      ${MACHINE_ARCH}
16
17 SIZE?=          size
18 OBJCOPY?=       objcopy
19
20 COPTFLAGS?=-O -pipe
21 #COPTFLAGS?=-O -fthread-jumps -fcse-follow-jumps -fcrossjumping -frerun-cse-after-loop -fno-guess-branch-probability --param min-crossjump-insns=1 -pipe
22 #COPTFLAGS?=-O -fcrossjumping -pipe
23 #COPTFLAGS?=-Os -fno-strict-aliasing -pipe
24 #COPTFLAGS?=-O2 -fno-strict-aliasing -pipe
25 .if !defined(NO_CPU_COPTFLAGS)
26 COPTFLAGS+= ${_CPUCFLAGS}
27 .endif
28 # don't use -I- so we can use proper source-relative locality for local 
29 # includes.
30 #
31 # -I.  - this is to access the opt_*.h and use_*.h header files generated
32 #        in the kernel build directory.
33 #
34 # -Iinclude
35 #       - this is used to access forwarding header files for
36 #         <machine/*.h> that exist in the cpu architecture but do not
37 #         exist in the platform (machine/) architecture.  This allows
38 #         the platform to trivially override the cpu header files.
39 #
40 INCLUDES= -nostdinc -I. -Iinclude -I$S
41 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
42 .if exists($S/../include)
43 INCLUDES+= -I$S/../include
44 .else
45 INCLUDES+= -I/usr/include
46 .endif
47
48 # This hack lets us use the Intel ACPICA code without spamming a new
49 # include path into 100+ source files.
50 .include "$S/conf/acpi.mk"
51 INCLUDES+= -I${.OBJDIR} -I"$S/${OSACPI_MI_DIR}" -I"$S/${ACPICA_DIR}/include"
52
53 # This hack lets us use the ipfilter code without spamming a new
54 # include path into 100+ source files.
55 INCLUDES+= -I$S/contrib/ipfilter
56
57 # ... and the same for Atheros HAL
58 INCLUDES+= -I$S/dev/netif/ath/hal -I$S/dev/netif/ath/hal/ath_hal
59
60 COPTS=  ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
61 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
62
63 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
64 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
65
66 DEFINED_PROF=   ${PROF}
67 .if defined(PROF)
68 CFLAGS+=        -falign-functions=16
69 .if ${PROFLEVEL} >= 2
70 IDENT+= -DGPROF4 -DGUPROF
71 PROF+=  -mprofiler-epilogue
72 .endif
73 .endif
74
75 # Put configuration-specific C flags last (except for ${PROF}) so that they
76 # can override the others.
77 CFLAGS+=        ${CONF_CFLAGS}
78
79 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
80 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
81 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
82 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
83
84 NORMAL_M= awk -f $S/tools/makeobjops.awk -- -c $<; \
85         ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
86
87 .if !defined(NO_WERROR) && ${CCVER} == "gcc41"
88 WERROR=-Werror
89 .endif
90
91 GEN_CFILES= $S/platform/$P/$M/genassym.c
92 SYSTEM_CFILES= ioconf.c config.c
93 SYSTEM_SFILES= $S/platform/$P/$M/locore.s
94 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
95 SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
96 SYSTEM_LD= @${LD} -Bdynamic -T $S/platform/$P/conf/ldscript.$M \
97         -export-dynamic -dynamic-linker /red/herring \
98         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
99 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
100         ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
101 SYSTEM_DEP+= $S/platform/$P/conf/ldscript.$M
102
103 # Normalize output files to make it absolutely crystal clear to
104 # anyone examining the build directory.
105 #
106 .if defined(DEBUG)
107 FULLKERNEL=     ${KERNEL}.debug
108 .if defined(INSTALLSTRIPPED)
109 SELECTEDKERNEL= ${KERNEL}.stripped
110 .else
111 SELECTEDKERNEL= ${KERNEL}.debug
112 .endif
113 .else
114 FULLKERNEL=     ${KERNEL}.nodebug
115 SELECTEDKERNEL= ${KERNEL}.stripped
116 .endif
117
118
119 MKMODULESENV=   MAKEOBJDIRPREFIX=${.OBJDIR} BUILDING_WITH_KERNEL=${.OBJDIR}
120 .if defined(MODULES_OVERRIDE)
121 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
122 .endif
123 .if defined(DEBUG)
124 MKMODULESENV+=  DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
125 .endif
126 .if defined(INSTALLSTRIPPED) || defined(INSTALLSTRIPPEDMODULES)
127 MKMODULESENV+=  INSTALLSTRIPPEDMODULES=1
128 .endif
129 MKMODULESENV+=  MACHINE_ARCH=${MACHINE_ARCH} MACHINE=${MACHINE} MACHINE_PLATFORM=${MACHINE_PLATFORM}
130