xref: /dragonfly/sys/conf/kern.pre.mk (revision bcb3e04d)
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
7KERNEL?=	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#
14P=	${MACHINE_PLATFORM}
15M=	${MACHINE_ARCH}
16
17SIZE?=		size
18OBJCOPY?=	objcopy
19
20COPTFLAGS?=-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)
26COPTFLAGS+= ${_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#
40INCLUDES= -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)
43INCLUDES+= -I$S/../include
44.else
45INCLUDES+= -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"
51INCLUDES+= -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.
55INCLUDES+= -I$S/contrib/ipfilter
56
57# ... and the same for Atheros HAL
58INCLUDES+= -I$S/dev/netif/ath/hal -I$S/dev/netif/ath/hal/ath_hal
59
60COPTS=	${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
61CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
62
63# XXX LOCORE means "don't declare C stuff" not "for locore.s".
64ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
65
66DEFINED_PROF=	${PROF}
67.if defined(PROF)
68CFLAGS+=	-falign-functions=16
69.if ${PROFLEVEL} >= 2
70IDENT+=	-DGPROF4 -DGUPROF
71PROF+=	-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.
77CFLAGS+=	${CONF_CFLAGS}
78
79NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
80NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
81NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
82PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
83
84NORMAL_M= awk -f $S/tools/makeobjops.awk -- -c $<; \
85	${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
86
87.if !defined(NO_WERROR) && ${CCVER} == "gcc41"
88WERROR=-Werror
89.endif
90
91GEN_CFILES= $S/platform/$P/$M/genassym.c
92SYSTEM_CFILES= ioconf.c config.c
93SYSTEM_SFILES= $S/platform/$P/$M/locore.s
94SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
95SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
96SYSTEM_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
99SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
100	${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
101SYSTEM_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)
107FULLKERNEL=	${KERNEL}.debug
108.if defined(INSTALLSTRIPPED)
109SELECTEDKERNEL= ${KERNEL}.stripped
110.else
111SELECTEDKERNEL= ${KERNEL}.debug
112.endif
113.else
114FULLKERNEL=	${KERNEL}.nodebug
115SELECTEDKERNEL= ${KERNEL}.stripped
116.endif
117
118
119MKMODULESENV=	MAKEOBJDIRPREFIX=${.OBJDIR} BUILDING_WITH_KERNEL=${.OBJDIR}
120.if defined(MODULES_OVERRIDE)
121MKMODULESENV+=	MODULES_OVERRIDE="${MODULES_OVERRIDE}"
122.endif
123.if defined(DEBUG)
124MKMODULESENV+=	DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
125.endif
126.if defined(INSTALLSTRIPPED) || defined(INSTALLSTRIPPEDMODULES)
127MKMODULESENV+=	INSTALLSTRIPPEDMODULES=1
128.endif
129MKMODULESENV+=  MACHINE_ARCH=${MACHINE_ARCH} MACHINE=${MACHINE} MACHINE_PLATFORM=${MACHINE_PLATFORM}
130
131