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 27LIBSA= ${BOOTOBJ}/libsa/libsa.a 28.if ${MACHINE} == "i386" 29LIBSA32= ${LIBSA} 30.else 31LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a 32.endif 33 34# Standard options: 35CFLAGS+= -nostdinc 36.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 37CFLAGS+= -I${BOOTOBJ}/libsa32 38.else 39CFLAGS+= -I${BOOTOBJ}/libsa 40.endif 41CFLAGS+= -I${SASRC} -D_STANDALONE 42CFLAGS+= -I${SYSDIR} 43 44# GELI Support, with backward compat hooks (mostly) 45.if defined(HAVE_GELI) 46.if defined(LOADER_NO_GELI_SUPPORT) 47MK_LOADER_GELI=no 48.warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI" 49.endif 50.if defined(LOADER_GELI_SUPPORT) 51MK_LOADER_GELI=yes 52.warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI" 53.endif 54.if ${MK_LOADER_GELI} == "yes" 55CFLAGS+= -DLOADER_GELI_SUPPORT 56CFLAGS+= -I${BOOTSRC}/geli 57LIBGELIBOOT= ${BOOTOBJ}/geli/libgeliboot.a 58.endif # MK_LOADER_GELI 59.endif # HAVE_GELI 60 61# Machine specific flags for all builds here 62 63# All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc 64# or powerpc64. 65.if ${MACHINE_ARCH} == "powerpc64" 66CFLAGS+= -m32 -mcpu=powerpc 67.endif 68 69# For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is 70# build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here 71# and activate it when DO32 is explicitly defined to be 1. 72.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 73CFLAGS+= -m32 -mcpu=i386 74# LD_FLAGS is passed directly to ${LD}, not via ${CC}: 75LD_FLAGS+= -m elf_i386_fbsd 76AFLAGS+= --32 77.endif 78 79SSP_CFLAGS= 80 81# Add in the no float / no SIMD stuff and announce we're freestanding 82# aarch64 and riscv don't have -msoft-float, but all others do. riscv 83# currently has no /boot/loader, but may soon. 84CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD} 85.if ${MACHINE_CPUARCH} == "aarch64" 86CFLAGS+= -mgeneral-regs-only 87.elif ${MACHINE_CPUARCH} != "riscv" 88CFLAGS+= -msoft-float 89.endif 90 91.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1) 92CFLAGS+= -march=i386 93CFLAGS.gcc+= -mpreferred-stack-boundary=2 94.endif 95 96 97.if ${MACHINE_CPUARCH} == "arm" 98# Do not generate movt/movw, because the relocation fixup for them does not 99# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). 100# Also, the fpu is not available in a standalone environment. 101.if ${COMPILER_VERSION} < 30800 102CFLAGS.clang+= -mllvm -arm-use-movt=0 103.else 104CFLAGS.clang+= -mno-movt 105.endif 106CFLAGS.clang+= -mfpu=none 107.endif 108 109# The boot loader build uses dd status=none, where possible, for reproducible 110# build output (since performance varies from run to run). Trouble is that 111# option was recently (10.3) added to FreeBSD and is non-standard. Only use it 112# when this test succeeds rather than require dd to be a bootstrap tool. 113DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true 114DD=dd ${DD_NOSTATUS} 115 116.if ${MK_LOADER_FORCE_LE} != "no" 117.if ${MACHINE_ARCH} == "powerpc64" 118CFLAGS+= -mlittle-endian 119.endif 120.endif 121 122# Make sure we use the machine link we're about to create 123CFLAGS+=-I. 124 125_ILINKS=machine 126.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" 127_ILINKS+=${MACHINE_CPUARCH} 128.endif 129.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 130_ILINKS+=x86 131.endif 132CLEANFILES+=${_ILINKS} 133 134all: ${PROG} 135 136beforedepend: ${_ILINKS} 137beforebuild: ${_ILINKS} 138 139# Ensure that the links exist without depending on it when it exists which 140# causes all the modules to be rebuilt when the directory pointed to changes. 141.for _link in ${_ILINKS} 142.if !exists(${.OBJDIR}/${_link}) 143${OBJS}: ${_link} 144.endif 145.endfor 146 147.NOPATH: ${_ILINKS} 148 149${_ILINKS}: 150 @case ${.TARGET} in \ 151 machine) \ 152 if [ ${DO32:U0} -eq 0 ]; then \ 153 path=${SYSDIR}/${MACHINE}/include ; \ 154 else \ 155 path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \ 156 fi ;; \ 157 *) \ 158 path=${SYSDIR}/${.TARGET:T}/include ;; \ 159 esac ; \ 160 path=`(cd $$path && /bin/pwd)` ; \ 161 ${ECHO} ${.TARGET:T} "->" $$path ; \ 162 ln -fhs $$path ${.TARGET:T} 163 164.endif # __BOOT_DEFS_MK__ 165