7 .if !defined(__BOOT_DEFS_MK__)
8 __BOOT_DEFS_MK__=${MFILE}
17 BOOTSRC= ${SRCTOP}/stand
18 EFISRC= ${BOOTSRC}/efi
19 EFIINC= ${EFISRC}/include
20 EFIINCMD= ${EFIINC}/${MACHINE}
21 FDTSRC= ${BOOTSRC}/fdt
22 FICLSRC= ${BOOTSRC}/ficl
23 LDRSRC= ${BOOTSRC}/common
24 SASRC= ${BOOTSRC}/libsa
26 UBOOTSRC= ${BOOTSRC}/uboot
27 ZFSSRC= ${BOOTSRC}/zfs
29 BOOTOBJ= ${OBJTOP}/stand
31 # BINDIR is where we install
34 LIBSA= ${BOOTOBJ}/libsa/libsa.a
35 .if ${MACHINE} == "i386"
38 LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a
43 .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
44 CFLAGS+= -I${BOOTOBJ}/libsa32
46 CFLAGS+= -I${BOOTOBJ}/libsa
48 CFLAGS+= -I${SASRC} -D_STANDALONE
51 # GELI Support, with backward compat hooks (mostly)
52 .if defined(HAVE_GELI)
53 .if defined(LOADER_NO_GELI_SUPPORT)
55 .warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI"
57 .if defined(LOADER_GELI_SUPPORT)
59 .warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI"
61 .if ${MK_LOADER_GELI} == "yes"
62 CFLAGS+= -DLOADER_GELI_SUPPORT
63 CFLAGS+= -I${BOOTSRC}/geli
64 LIBGELIBOOT= ${BOOTOBJ}/geli/libgeliboot.a
65 .endif # MK_LOADER_GELI
68 # These should be confined to loader.mk, but can't because uboot/lib
69 # also uses it. It's part of loader, but isn't a loader so we can't
70 # just include loader.mk
71 .if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
72 CFLAGS+= -DLOADER_DISK_SUPPORT
75 # Machine specific flags for all builds here
77 # All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc
79 .if ${MACHINE_ARCH} == "powerpc64"
80 CFLAGS+= -m32 -mcpu=powerpc
83 # For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is
84 # build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here
85 # and activate it when DO32 is explicitly defined to be 1.
86 .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
87 CFLAGS+= -m32 -mcpu=i386
88 # LD_FLAGS is passed directly to ${LD}, not via ${CC}:
89 LD_FLAGS+= -m elf_i386_fbsd
95 # Add in the no float / no SIMD stuff and announce we're freestanding
96 # aarch64 and riscv don't have -msoft-float, but all others do. riscv
97 # currently has no /boot/loader, but may soon.
98 CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD}
99 .if ${MACHINE_CPUARCH} == "aarch64"
100 CFLAGS+= -mgeneral-regs-only
101 .elif ${MACHINE_CPUARCH} != "riscv"
102 CFLAGS+= -msoft-float
105 .if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1)
107 CFLAGS.gcc+= -mpreferred-stack-boundary=2
111 .if ${MACHINE_CPUARCH} == "arm"
112 # Do not generate movt/movw, because the relocation fixup for them does not
113 # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
114 # Also, the fpu is not available in a standalone environment.
115 .if ${COMPILER_VERSION} < 30800
116 CFLAGS.clang+= -mllvm -arm-use-movt=0
118 CFLAGS.clang+= -mno-movt
120 CFLAGS.clang+= -mfpu=none
123 # The boot loader build uses dd status=none, where possible, for reproducible
124 # build output (since performance varies from run to run). Trouble is that
125 # option was recently (10.3) added to FreeBSD and is non-standard. Only use it
126 # when this test succeeds rather than require dd to be a bootstrap tool.
127 DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true
130 .if ${MK_LOADER_FORCE_LE} != "no"
131 .if ${MACHINE_ARCH} == "powerpc64"
132 CFLAGS+= -mlittle-endian
136 # Make sure we use the machine link we're about to create
140 .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64"
141 _ILINKS+=${MACHINE_CPUARCH}
143 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
146 CLEANFILES+=${_ILINKS}
150 beforedepend: ${_ILINKS}
151 beforebuild: ${_ILINKS}
153 # Ensure that the links exist without depending on it when it exists which
154 # causes all the modules to be rebuilt when the directory pointed to changes.
155 .for _link in ${_ILINKS}
156 .if !exists(${.OBJDIR}/${_link})
164 @case ${.TARGET} in \
166 if [ ${DO32:U0} -eq 0 ]; then \
167 path=${SYSDIR}/${MACHINE}/include ; \
169 path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \
172 path=${SYSDIR}/${.TARGET:T}/include ;; \
174 path=`(cd $$path && /bin/pwd)` ; \
175 ${ECHO} ${.TARGET:T} "->" $$path ; \
176 ln -fhs $$path ${.TARGET:T}
178 .endif # __BOOT_DEFS_MK__