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