]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - stand/defs.mk
Extend the VMM stats interface to support a dynamic count of statistics.
[FreeBSD/FreeBSD.git] / stand / defs.mk
1 # $FreeBSD$
2
3 .if !defined(__BOOT_DEFS_MK__)
4 __BOOT_DEFS_MK__=${MFILE}
5
6 # We need to define all the MK_ options before including src.opts.mk
7 # because it includes bsd.own.mk which needs the right MK_ values,
8 # espeically MK_CTF.
9
10 MK_CTF=         no
11 MK_SSP=         no
12 MK_PROFILE=     no
13 MK_PIE=         no
14 MAN=
15 .if !defined(PIC)
16 NO_PIC=
17 INTERNALLIB=
18 .endif
19 # Should be NO_CPU_FLAGS, but bsd.cpu.mk is included too early in bsd.init.mk
20 # via the early include of bsd.opts.mk. Moving Makefile.inc include earlier in
21 # that file causes weirdness, so this is the next best thing. We need to do this
22 # because the loader needs very specific flags to work right, and things like
23 # CPUTYPE?=native prevent that, and introduce an endless game of whack-a-mole
24 # to disable more and more features. Boot loader performance is never improved
25 # enough to make that hassle worth chasing.
26 _CPUCFLAGS=
27
28 .include <src.opts.mk>
29 .include <bsd.linker.mk>
30
31 WARNS?=         1
32
33 BOOTSRC=        ${SRCTOP}/stand
34 EFISRC=         ${BOOTSRC}/efi
35 EFIINC=         ${EFISRC}/include
36 EFIINCMD=       ${EFIINC}/${MACHINE}
37 FDTSRC=         ${BOOTSRC}/fdt
38 FICLSRC=        ${BOOTSRC}/ficl
39 LDRSRC=         ${BOOTSRC}/common
40 LIBLUASRC=      ${BOOTSRC}/liblua
41 LIBOFWSRC=      ${BOOTSRC}/libofw
42 LUASRC=         ${SRCTOP}/contrib/lua/src
43 SASRC=          ${BOOTSRC}/libsa
44 SYSDIR=         ${SRCTOP}/sys
45 UBOOTSRC=       ${BOOTSRC}/uboot
46 ZFSSRC=         ${SASRC}/zfs
47 OZFS=           ${SRCTOP}/sys/contrib/openzfs
48 ZFSOSSRC=       ${OZFS}/module/os/freebsd/
49 ZFSOSINC=       ${OZFS}/include/os/freebsd
50 LIBCSRC=        ${SRCTOP}/lib/libc
51
52 BOOTOBJ=        ${OBJTOP}/stand
53
54 # BINDIR is where we install
55 BINDIR?=        /boot
56
57 # LUAPATH is where we search for and install lua scripts.
58 LUAPATH?=       /boot/lua
59 FLUASRC?=       ${SRCTOP}/libexec/flua
60
61 LIBSA=          ${BOOTOBJ}/libsa/libsa.a
62 .if ${MACHINE} == "i386"
63 LIBSA32=        ${LIBSA}
64 .else
65 LIBSA32=        ${BOOTOBJ}/libsa32/libsa32.a
66 .endif
67
68 # Standard options:
69 CFLAGS+=        -nostdinc
70 # Allow CFLAGS_EARLY.file/target so that code that needs specific stack
71 # of include paths can set them up before our include paths. Normally
72 # the only thing that should be there are -I directives, and as few of
73 # those as possible.
74 CFLAGS+=        ${CFLAGS_EARLY} ${CFLAGS_EARLY.${.IMPSRC:T}} ${CFLAGS_EARLY.${.TARGET:T}}
75 .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
76 CFLAGS+=        -I${BOOTOBJ}/libsa32
77 .else
78 CFLAGS+=        -I${BOOTOBJ}/libsa
79 .endif
80 CFLAGS+=        -I${SASRC} -D_STANDALONE
81 CFLAGS+=        -I${SYSDIR}
82 # Spike the floating point interfaces
83 CFLAGS+=        -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface
84 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
85 # Slim down the image. This saves about 15% in size with clang 6 on x86
86 # Our most constrained /boot/loader env is BIOS booting on x86, where
87 # our text + data + BTX have to fit into 640k below the ISA hole.
88 # Experience has shown that problems arise between ~520k to ~530k.
89 CFLAGS.clang+=  -Oz
90 CFLAGS.gcc+=    -Os
91 CFLAGS+=        -ffunction-sections -fdata-sections
92 .endif
93
94 # GELI Support, with backward compat hooks (mostly)
95 .if defined(LOADER_NO_GELI_SUPPORT)
96 MK_LOADER_GELI=no
97 .warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI"
98 .endif
99 .if defined(LOADER_GELI_SUPPORT)
100 MK_LOADER_GELI=yes
101 .warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI"
102 .endif
103 .if ${MK_LOADER_GELI} == "yes"
104 CFLAGS+=        -DLOADER_GELI_SUPPORT
105 CFLAGS+=        -I${SASRC}/geli
106 .endif # MK_LOADER_GELI
107
108 # These should be confined to loader.mk, but can't because uboot/lib
109 # also uses it. It's part of loader, but isn't a loader so we can't
110 # just include loader.mk
111 .if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
112 CFLAGS+= -DLOADER_DISK_SUPPORT
113 .endif
114
115 # Machine specific flags for all builds here
116
117 # Ensure PowerPC64 and PowerPC64LE boot loaders are compiled as 32 bit.
118 # PowerPC64LE boot loaders are 32-bit little-endian.
119 .if ${MACHINE_ARCH} == "powerpc64"
120 CFLAGS+=        -m32 -mcpu=powerpc -mbig-endian
121 .elif ${MACHINE_ARCH} == "powerpc64le"
122 CFLAGS+=        -m32 -mcpu=powerpc -mlittle-endian
123 .endif
124
125 # For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is
126 # build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here
127 # and activate it when DO32 is explicitly defined to be 1.
128 .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
129 CFLAGS+=        -m32
130 # LD_FLAGS is passed directly to ${LD}, not via ${CC}:
131 LD_FLAGS+=      -m elf_i386_fbsd
132 AFLAGS+=        --32
133 .endif
134
135 # Add in the no float / no SIMD stuff and announce we're freestanding
136 # aarch64 and riscv don't have -msoft-float, but all others do.
137 CFLAGS+=        -ffreestanding ${CFLAGS_NO_SIMD}
138 .if ${MACHINE_CPUARCH} == "aarch64"
139 CFLAGS+=        -mgeneral-regs-only -ffixed-x18 -fPIC
140 .elif ${MACHINE_CPUARCH} == "riscv"
141 CFLAGS+=        -march=rv64imac -mabi=lp64 -fPIC
142 CFLAGS.clang+=  -mcmodel=medium
143 CFLAGS.gcc+=    -mcmodel=medany
144 .else
145 CFLAGS+=        -msoft-float
146 .endif
147
148 # -msoft-float seems to be insufficient for powerpcspe
149 .if ${MACHINE_ARCH} == "powerpcspe"
150 CFLAGS+=        -mno-spe
151 .endif
152
153 .if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1)
154 CFLAGS+=        -march=i386
155 CFLAGS.gcc+=    -mpreferred-stack-boundary=2
156 .endif
157 .if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0
158 CFLAGS+=        -fPIC -mno-red-zone
159 .endif
160
161 .if ${MACHINE_CPUARCH} == "arm"
162 # Do not generate movt/movw, because the relocation fixup for them does not
163 # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
164 # Also, the fpu is not available in a standalone environment.
165 CFLAGS.clang+=  -mno-movt
166 CFLAGS.clang+=  -mfpu=none
167 CFLAGS+=        -fPIC
168 .endif
169
170 # Some RISC-V linkers have support for relaxations, while some (lld) do not
171 # yet. If this is the case we inhibit the compiler from emitting relaxations.
172 .if ${LINKER_FEATURES:Mriscv-relaxations} == ""
173 CFLAGS+=        -mno-relax
174 .endif
175
176 # The boot loader build uses dd status=none, where possible, for reproducible
177 # build output (since performance varies from run to run). Trouble is that
178 # option was recently (10.3) added to FreeBSD and is non-standard. Only use it
179 # when this test succeeds rather than require dd to be a bootstrap tool.
180 DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true
181 DD=dd ${DD_NOSTATUS}
182
183 .if ${MACHINE_CPUARCH} == "mips"
184 CFLAGS+=        -G0 -fno-pic -mno-abicalls
185 .endif
186
187 #
188 # Have a sensible default
189 #
190 .if ${MK_LOADER_LUA} == "yes"
191 LOADER_DEFAULT_INTERP?=lua
192 .elif ${MK_FORTH} == "yes"
193 LOADER_DEFAULT_INTERP?=4th
194 .else
195 LOADER_DEFAULT_INTERP?=simp
196 .endif
197 LOADER_INTERP?=${LOADER_DEFAULT_INTERP}
198
199 # Make sure we use the machine link we're about to create
200 CFLAGS+=-I.
201
202 all: ${PROG}
203
204 CLEANFILES+= teken_state.h
205 teken.c: teken_state.h
206
207 teken_state.h: ${SYSDIR}/teken/sequences
208         awk -f ${SYSDIR}/teken/gensequences \
209                 ${SYSDIR}/teken/sequences > teken_state.h
210
211 .if !defined(NO_OBJ)
212 _ILINKS=include/machine
213 .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64"
214 _ILINKS+=include/${MACHINE_CPUARCH}
215 .endif
216 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
217 _ILINKS+=include/x86
218 .endif
219 CFLAGS+= -Iinclude
220 CLEANDIRS+= include
221
222 beforedepend: ${_ILINKS}
223 beforebuild: ${_ILINKS}
224
225 # Ensure that the links exist without depending on it when it exists which
226 # causes all the modules to be rebuilt when the directory pointed to changes.
227 .for _link in ${_ILINKS}
228 .if !exists(${.OBJDIR}/${_link})
229 ${OBJS}:       ${_link}
230 .endif # _link exists
231 .endfor
232
233 .NOPATH: ${_ILINKS}
234
235 ${_ILINKS}: .NOMETA
236         @case ${.TARGET:T} in \
237         machine) \
238                 if [ ${DO32:U0} -eq 0 ]; then \
239                         path=${SYSDIR}/${MACHINE}/include ; \
240                 else \
241                         path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \
242                 fi ;; \
243         *) \
244                 path=${SYSDIR}/${.TARGET:T}/include ;; \
245         esac ; \
246         case ${.TARGET} in \
247         */*) mkdir -p ${.TARGET:H};; \
248         esac ; \
249         path=`(cd $$path && /bin/pwd)` ; \
250         ${ECHO} ${.TARGET} "->" $$path ; \
251         ln -fns $$path ${.TARGET}
252 .endif # !NO_OBJ
253 .endif # __BOOT_DEFS_MK__