1# $FreeBSD$ 2 3.include <src.opts.mk> 4 5WARNS?=1 6 7.if !defined(__BOOT_DEFS_MK__) 8__BOOT_DEFS_MK__=${MFILE} 9 10BOOTSRC= ${SRCTOP}/stand 11EFISRC= ${BOOTSRC}/efi 12EFIINC= ${EFISRC}/include 13EFIINCMD= ${EFIINC}/${MACHINE} 14FDTSRC= ${BOOTSRC}/fdt 15FICLSRC= ${BOOTSRC}/ficl 16LDRSRC= ${BOOTSRC}/common 17SASRC= ${BOOTSRC}/libsa 18SYSDIR= ${SRCTOP}/sys 19UBOOTSRC= ${BOOTSRC}/uboot 20ZFSSRC= ${BOOTSRC}/zfs 21 22BOOTOBJ= ${OBJTOP}/stand 23 24# BINDIR is where we install 25BINDIR?= /boot 26 27# NB: The makefiles depend on these being empty when we don't build forth. 28.if ${MK_FORTH} != "no" 29LIBFICL= ${BOOTOBJ}/ficl/libficl.a 30.if ${MACHINE} == "i386" 31LIBFICL32= ${LIBFICL} 32.else 33LIBFICL32= ${BOOTOBJ}/ficl32/libficl.a 34.endif 35.endif 36LIBSA= ${BOOTOBJ}/libsa/libsa.a 37.if ${MACHINE} == "i386" 38LIBSA32= ${LIBSA} 39.else 40LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a 41.endif 42 43# Standard options: 44CFLAGS+= -nostdinc 45.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 46CFLAGS+= -I${BOOTOBJ}/libsa32 47.else 48CFLAGS+= -I${BOOTOBJ}/libsa 49.endif 50CFLAGS+= -I${SASRC} -D_STANDALONE 51CFLAGS+= -I${SYSDIR} 52 53# Filesystem support 54.if ${LOADER_CD9660_SUPPORT:Uno} == "yes" 55CFLAGS+= -DLOADER_CD9660_SUPPORT 56.endif 57.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes" 58CFLAGS+= -DLOADER_EXT2FS_SUPPORT 59.endif 60.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes" 61CFLAGS+= -DLOADER_MSDOS_SUPPORT 62.endif 63.if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes" 64CFLAGS+= -DLOADER_NANDFS_SUPPORT 65.endif 66.if ${LOADER_UFS_SUPPORT:Uyes} == "yes" 67CFLAGS+= -DLOADER_UFS_SUPPORT 68.endif 69 70# Compression 71.if ${LOADER_GZIP_SUPPORT:Uno} == "yes" 72CFLAGS+= -DLOADER_GZIP_SUPPORT 73.endif 74.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes" 75CFLAGS+= -DLOADER_BZIP2_SUPPORT 76.endif 77 78# Network related things 79.if ${LOADER_NET_SUPPORT:Uno} == "yes" 80CFLAGS+= -DLOADER_NET_SUPPORT 81.endif 82.if ${LOADER_NFS_SUPPORT:Uno} == "yes" 83CFLAGS+= -DLOADER_NFS_SUPPORT 84.endif 85.if ${LOADER_TFTP_SUPPORT:Uno} == "yes" 86CFLAGS+= -DLOADER_TFTP_SUPPORT 87.endif 88 89# Disk and partition support 90.if ${LOADER_DISK_SUPPORT:Uyes} == "yes" 91CFLAGS+= -DLOADER_DISK_SUPPORT 92.if ${LOADER_GPT_SUPPORT:Uyes} == "yes" 93CFLAGS+= -DLOADER_GPT_SUPPORT 94.endif 95.if ${LOADER_MBR_SUPPORT:Uyes} == "yes" 96CFLAGS+= -DLOADER_MBR_SUPPORT 97.endif 98 99# GELI Support, with backward compat hooks (mostly) 100.if defined(HAVE_GELI) 101.if defined(LOADER_NO_GELI_SUPPORT) 102MK_LOADER_GELI=no 103.warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI" 104.endif 105.if defined(LOADER_GELI_SUPPORT) 106MK_LOADER_GELI=yes 107.warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI" 108.endif 109.if ${MK_LOADER_GELI} == "yes" 110CFLAGS+= -DLOADER_GELI_SUPPORT 111CFLAGS+= -I${BOOTSRC}/geli 112LIBGELIBOOT= ${BOOTOBJ}/geli/libgeliboot.a 113.endif 114.endif 115.endif 116 117# Machine specific flags for all builds here 118 119# All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc 120# or powerpc64. 121.if ${MACHINE_ARCH} == "powerpc64" 122CFLAGS+= -m32 -mcpu=powerpc 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 129CFLAGS+= -m32 -mcpu=i386 130# LD_FLAGS is passed directly to ${LD}, not via ${CC}: 131LD_FLAGS+= -m elf_i386_fbsd 132AFLAGS+= --32 133.endif 134 135SSP_CFLAGS= 136 137# Add in the no float / no SIMD stuff and announce we're freestanding 138# aarch64 and riscv don't have -msoft-float, but all others do. riscv 139# currently has no /boot/loader, but may soon. 140CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD} 141.if ${MACHINE_CPUARCH} == "aarch64" 142CFLAGS+= -mgeneral-regs-only 143.elif ${MACHINE_CPUARCH} != "riscv" 144CFLAGS+= -msoft-float 145.endif 146 147.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1) 148CFLAGS+= -march=i386 149CFLAGS.gcc+= -mpreferred-stack-boundary=2 150.endif 151 152 153.if ${MACHINE_CPUARCH} == "arm" 154# Do not generate movt/movw, because the relocation fixup for them does not 155# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). 156# Also, the fpu is not available in a standalone environment. 157.if ${COMPILER_VERSION} < 30800 158CFLAGS.clang+= -mllvm -arm-use-movt=0 159.else 160CFLAGS.clang+= -mno-movt 161.endif 162CFLAGS.clang+= -mfpu=none 163.endif 164 165# The boot loader build uses dd status=none, where possible, for reproducible 166# build output (since performance varies from run to run). Trouble is that 167# option was recently (10.3) added to FreeBSD and is non-standard. Only use it 168# when this test succeeds rather than require dd to be a bootstrap tool. 169DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true 170DD=dd ${DD_NOSTATUS} 171 172.if ${MK_LOADER_FORCE_LE} != "no" 173.if ${MACHINE_ARCH} == "powerpc64" 174CFLAGS+= -mlittle-endian 175.endif 176.endif 177 178# Make sure we use the machine link we're about to create 179CFLAGS+=-I. 180 181_ILINKS=machine 182.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" 183_ILINKS+=${MACHINE_CPUARCH} 184.endif 185.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 186_ILINKS+=x86 187.endif 188CLEANFILES+=${_ILINKS} 189 190all: ${PROG} 191 192beforedepend: ${_ILINKS} 193beforebuild: ${_ILINKS} 194 195# Ensure that the links exist without depending on it when it exists which 196# causes all the modules to be rebuilt when the directory pointed to changes. 197.for _link in ${_ILINKS} 198.if !exists(${.OBJDIR}/${_link}) 199${OBJS}: ${_link} 200.endif 201.endfor 202 203.NOPATH: ${_ILINKS} 204 205${_ILINKS}: 206 @case ${.TARGET} in \ 207 machine) \ 208 if [ ${DO32:U0} -eq 0 ]; then \ 209 path=${SYSDIR}/${MACHINE}/include ; \ 210 else \ 211 path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \ 212 fi ;; \ 213 *) \ 214 path=${SYSDIR}/${.TARGET:T}/include ;; \ 215 esac ; \ 216 path=`(cd $$path && /bin/pwd)` ; \ 217 ${ECHO} ${.TARGET:T} "->" $$path ; \ 218 ln -fhs $$path ${.TARGET:T} 219 220# For loader implementations, we generate a loader.help file. This can be suppressed by 221# setting HELP_FILES to nothing. 222HELP_FILES= ${LDRSRC}/help.common 223 224.endif # __BOOT_DEFS_MK__ 225