sys/vfs/hammer2: Fix comment on bmradix in freemap
[dragonfly.git] / sys / conf / kern.pre.mk
blobbde3a2c9417610d90ac141b34be2e4dd5fdbf7af
2 # This Makefile covers the top part of the MI kernel build instructions
5 # Can be overridden by makeoptions or /etc/make.conf
6 KERNEL?= kernel
8 # If a different binutils is installed in /usr/local it probably
9 # won't recognize LDVER or use the default, creating an incompatibility
10 # between buildkernel and nativekernel as well as between buildkernel and
11 # manual make's inside /usr/obj/usr/src/sys/KERNEL_CONFIG.
13 # /usr/local/bin must be removed from the path.
15 RMLDPATH=/usr/local/bin
16 PATH:=${PATH:C/${RMLDPATH}//g}
17 .export PATH
19 fubar:
20 echo ${PATH}
22 # build this target if none is specified on the command line
23 .MAIN: all
25 # Set the platform and machine architectures
27 P= ${MACHINE_PLATFORM}
28 M= ${MACHINE_ARCH}
30 SIZE?= size
31 OBJCOPY?= objcopy
33 COPTFLAGS?=-O2 -pipe
34 #COPTFLAGS?=-O -pipe -flto -fno-fat-lto-objects
35 #COPTFLAGS?=-O -fthread-jumps -fcse-follow-jumps -fcrossjumping -frerun-cse-after-loop -fno-guess-branch-probability --param min-crossjump-insns=1 -pipe
36 #COPTFLAGS?=-O -fcrossjumping -pipe
37 #COPTFLAGS?=-Os -fno-strict-aliasing -pipe
38 #COPTFLAGS?=-O2 -fno-strict-aliasing -pipe
40 # always use external as(1)
41 .if ${CCVER:Mclang*}
42 COPTFLAGS+= -no-integrated-as
43 .endif
45 .if !defined(NO_CPU_COPTFLAGS)
46 COPTFLAGS+= ${_CPUCFLAGS}
47 .endif
49 # don't use -I- so we can use proper source-relative locality for local
50 # includes.
52 # -I. - this is to access the opt_*.h and use_*.h header files generated
53 # in the kernel build directory.
55 # -Iinclude
56 # - this is used to access forwarding header files for
57 # <machine/*.h> that exist in the cpu architecture but do not
58 # exist in the platform (machine/) architecture. This allows
59 # the platform to trivially override the cpu header files.
61 INCLUDES= -nostdinc -I. -Iinclude -I$S
62 # Real kernel builds do not need /usr/include, but vkernel builds do.
64 .if ${MACHINE_PLATFORM} == "vkernel64"
65 .if exists($S/../include)
66 INCLUDES+= -I$S/../include
67 .else
68 INCLUDES+= -I/usr/include
69 .endif
70 .endif
72 # This hack lets us use the Intel ACPICA code without spamming a new
73 # include path into 100+ source files.
74 .include "$S/conf/acpi.mk"
75 INCLUDES+= -I${.OBJDIR} -I$S/${OSACPI_MI_DIR} -I$S/${ACPICA_DIR}/include
77 # ... and the same for Atheros HAL
78 INCLUDES+= -I$S/dev/netif/ath/ath_hal -I$S/contrib/dev/ath/ath_hal
80 # Same thing for drm includes
81 INCLUDES+= -I$S/dev/drm/include
82 INCLUDES+= -I$S/dev/drm/include/drm
83 INCLUDES+= -I$S/dev/drm/include/uapi
84 INCLUDES+= -I$S/dev/drm/amd/include
86 COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
87 CFLAGS= ${COPTFLAGS} ${KCFLAGS} ${CWARNFLAGS} -std=${CSTD} ${DEBUG} ${COPTS}
89 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
90 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS:N-flto}
92 # Put configuration-specific C flags last so that they
93 # can override the others.
94 CFLAGS+= ${CONF_CFLAGS}
96 # XXX handle this explicitly, fw wrappers use implicit .c.o: rule (LINT64)
97 .if defined(FASTER_DEPEND)
98 CFLAGS+= -MD
99 .endif
101 NORMAL_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
102 NORMAL_C_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
103 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
105 NORMAL_M= awk -f $S/tools/makeobjops.awk -- -c $<; \
106 ${CC} -c ${CFLAGS} ${.PREFIX}.c
108 NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
109 NORMAL_FWO= ${LD} -b binary -d -warn-common -r -o ${.TARGET} ${.ALLSRC:M*.fw}
111 .if !defined(NO_WERROR) && (${CCVER} == "gcc47" || ${CCVER} == "gcc80")
112 WERROR=-Werror
113 .endif
115 GEN_CFILES= $S/platform/$P/$M/genassym.c
116 SYSTEM_CFILES= ioconf.c config.c
117 SYSTEM_SFILES= $S/platform/$P/$M/locore.s
118 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
119 SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
120 SYSTEM_LD= @${CC} -nostdlib -ffreestanding -Wl,--hash-style=sysv \
121 -Wl,-Bdynamic -Wl,-T,$S/platform/$P/conf/ldscript.$M \
122 -Wl,--export-dynamic -Wl,--dynamic-linker,/red/herring \
123 -o ${.TARGET} -Wl,-X ${SYSTEM_OBJS} vers.o
125 # In case of LTO provide all standard CFLAGS!
126 .if ${CFLAGS:M-flto}
127 SYSTEM_LD+= ${CFLAGS}
128 ## This one eats a lot of ram, may be needed to correctly link the kernel.
129 ## Default "balanced" might create kernel that "Fatal trap 12" on boot!!!
130 #. if !${CFLAGS:M-flto-partition=*}
131 #SYSTEM_LD+= -flto-partition=one -flto-report-wpa
132 #. endif
133 .endif
135 # The max-page-size for gnu ld is 0x200000 on x86_64
136 # For the gold linker, it is only 0x1000 on both x86_64
137 # The penalty for changing the gold default for x86_64 is larger binaries
138 # and shared libraries, and forcing them to use more address space than
139 # required. The only application that needs such a large page size is the
140 # kernel itself, so leave the gold default alone and treat the kernel
141 # page size as an exception.
143 .if ${P} == "pc64"
144 SYSTEM_LD+= -Wl,-z,max-page-size=0x200000
145 .endif
147 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
148 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
149 SYSTEM_DEP+= $S/platform/$P/conf/ldscript.$M
151 # Normalize output files to make it absolutely crystal clear to
152 # anyone examining the build directory.
154 .if defined(DEBUG)
155 FULLKERNEL= ${KERNEL}.debug
156 .if defined(INSTALLSTRIPPED)
157 SELECTEDKERNEL= ${KERNEL}.stripped
158 .else
159 SELECTEDKERNEL= ${KERNEL}.debug
160 .endif
161 .else
162 FULLKERNEL= ${KERNEL}.nodebug
163 SELECTEDKERNEL= ${KERNEL}.stripped
164 .endif
167 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR} KERNBUILDDIR=${.OBJDIR}
168 .if defined(MODULES_OVERRIDE)
169 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
170 .endif
171 .if defined(DEBUG)
172 MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
173 .endif
174 .if defined(INSTALLSTRIPPED) || defined(INSTALLSTRIPPEDMODULES)
175 MKMODULESENV+= INSTALLSTRIPPEDMODULES=1
176 .endif
177 MKMODULESENV+= MACHINE_ARCH=${MACHINE_ARCH} MACHINE=${MACHINE} MACHINE_PLATFORM=${MACHINE_PLATFORM}