Reorganize the way machine architectures are handled. Consolidate the
[dragonfly.git] / sys / conf / kern.pre.mk
1 # $DragonFly: src/sys/conf/kern.pre.mk,v 1.2 2006/10/22 16:09:19 dillon 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 M=      ${MACHINE_ARCH}
13
14 SIZE?=          size
15 OBJCOPY?=       objcopy
16
17 COPTFLAGS?=-O -pipe
18 .if !defined(NO_CPU_COPTFLAGS)
19 COPTFLAGS+= ${_CPUCFLAGS}
20 .endif
21 # don't use -I- so we can use proper source-relative locality for local 
22 # includes
23 INCLUDES= -nostdinc -I. -I$S -I$S/arch
24 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
25 .if exists($S/../include)
26 INCLUDES+= -I$S/../include
27 .else
28 INCLUDES+= -I/usr/include
29 .endif
30
31 # This hack lets us use the Intel ACPICA code without spamming a new
32 # include path into 100+ source files.
33 .include "$S/conf/acpi.mk"
34 INCLUDES+= -I${.OBJDIR} -I"$S/${OSACPI_MI_DIR}" -I"$S/${ACPICA_DIR}/include"
35
36 # This hack lets us use the ipfilter code without spamming a new
37 # include path into 100+ source files.
38 INCLUDES+= -I$S/contrib/ipfilter
39
40 COPTS=  ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
41 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
42
43 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
44 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
45
46 DEFINED_PROF=   ${PROF}
47 .if defined(PROF)
48 CFLAGS+=        -falign-functions=16
49 .if ${PROFLEVEL} >= 2
50 IDENT+= -DGPROF4 -DGUPROF
51 PROF+=  -mprofiler-epilogue
52 .endif
53 .endif
54
55 # Put configuration-specific C flags last (except for ${PROF}) so that they
56 # can override the others.
57 CFLAGS+=        ${CONF_CFLAGS}
58
59 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
60 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
61 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
62 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
63
64 NORMAL_M= awk -f $S/tools/makeobjops.awk -- -c $<; \
65         ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
66
67 GEN_CFILES= $S/arch/$M/$M/genassym.c
68 SYSTEM_CFILES= ioconf.c config.c
69 SYSTEM_SFILES= $S/arch/$M/$M/locore.s
70 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
71 SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
72 SYSTEM_LD= @${LD} -Bdynamic -T $S/arch/$M/conf/ldscript.$M \
73         -export-dynamic -dynamic-linker /red/herring \
74         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
75 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
76         ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
77 SYSTEM_DEP+= $S/arch/$M/conf/ldscript.$M
78
79
80 # Normalize output files to make it absolutely crystal clear to
81 # anyone examining the build directory.
82 #
83 .if defined(DEBUG)
84 FULLKERNEL=     ${KERNEL}.debug
85 .if defined(INSTALLSTRIPPED)
86 SELECTEDKERNEL= ${KERNEL}.stripped
87 .else
88 SELECTEDKERNEL= ${KERNEL}.debug
89 .endif
90 .else
91 FULLKERNEL=     ${KERNEL}.nodebug
92 SELECTEDKERNEL= ${KERNEL}.stripped
93 .endif
94
95
96 MKMODULESENV=   MAKEOBJDIRPREFIX=${.OBJDIR} BUILDING_WITH_KERNEL=${.OBJDIR}
97 .if defined(MODULES_OVERRIDE)
98 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
99 .endif
100 .if defined(DEBUG)
101 MKMODULESENV+=  DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
102 .endif
103 .if defined(INSTALLSTRIPPED) || defined(INSTALLSTRIPPEDMODULES)
104 MKMODULESENV+=  INSTALLSTRIPPEDMODULES=1
105 .endif
106