1ca987d46SWarner Losh# $FreeBSD$ 2ca987d46SWarner Losh 3ca987d46SWarner Losh.include <src.opts.mk> 4ca987d46SWarner Losh 5a9839149SWarner LoshWARNS?=1 61227a4f4SWarner Losh 7ca987d46SWarner Losh.if !defined(__BOOT_DEFS_MK__) 8ca987d46SWarner Losh__BOOT_DEFS_MK__=${MFILE} 9ca987d46SWarner Losh 10ca987d46SWarner LoshBOOTSRC= ${SRCTOP}/stand 11ca987d46SWarner LoshEFISRC= ${BOOTSRC}/efi 12ca987d46SWarner LoshEFIINC= ${EFISRC}/include 13ca987d46SWarner LoshEFIINCMD= ${EFIINC}/${MACHINE} 14ca987d46SWarner LoshFDTSRC= ${BOOTSRC}/fdt 15ca987d46SWarner LoshFICLSRC= ${BOOTSRC}/ficl 16ca987d46SWarner LoshLDRSRC= ${BOOTSRC}/common 17ca987d46SWarner LoshSASRC= ${BOOTSRC}/libsa 18ca987d46SWarner LoshSYSDIR= ${SRCTOP}/sys 19ca987d46SWarner LoshUBOOTSRC= ${BOOTSRC}/uboot 20ca987d46SWarner LoshZFSSRC= ${BOOTSRC}/zfs 21ca987d46SWarner Losh 22ca987d46SWarner LoshBOOTOBJ= ${OBJTOP}/stand 23ca987d46SWarner Losh 24ca987d46SWarner Losh# BINDIR is where we install 25ca987d46SWarner LoshBINDIR?= /boot 26ca987d46SWarner Losh 27ca987d46SWarner Losh# NB: The makefiles depend on these being empty when we don't build forth. 28ca987d46SWarner Losh.if ${MK_FORTH} != "no" 29ca987d46SWarner LoshLIBFICL= ${BOOTOBJ}/ficl/libficl.a 30ca987d46SWarner Losh.if ${MACHINE} == "i386" 31ca987d46SWarner LoshLIBFICL32= ${LIBFICL} 32ca987d46SWarner Losh.else 33ca987d46SWarner LoshLIBFICL32= ${BOOTOBJ}/ficl32/libficl.a 34ca987d46SWarner Losh.endif 35ca987d46SWarner Losh.endif 36ca987d46SWarner LoshLIBSA= ${BOOTOBJ}/libsa/libsa.a 37ca987d46SWarner Losh.if ${MACHINE} == "i386" 38ca987d46SWarner LoshLIBSA32= ${LIBSA} 39ca987d46SWarner Losh.else 40ca987d46SWarner LoshLIBSA32= ${BOOTOBJ}/libsa32/libsa32.a 41ca987d46SWarner Losh.endif 42ca987d46SWarner Losh 43ca987d46SWarner Losh# Standard options: 4405f37f4dSWarner LoshCFLAGS+= -nostdinc 4505f37f4dSWarner Losh.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 4605f37f4dSWarner LoshCFLAGS+= -I${BOOTOBJ}/libsa32 4705f37f4dSWarner Losh.else 4805f37f4dSWarner LoshCFLAGS+= -I${BOOTOBJ}/libsa 4905f37f4dSWarner Losh.endif 50b65d7763SWarner LoshCFLAGS+= -I${SASRC} -D_STANDALONE 514f6b2874SWarner LoshCFLAGS+= -I${SYSDIR} 52ca987d46SWarner Losh 535ba722feSWarner Losh# GELI Support, with backward compat hooks (mostly) 54ca987d46SWarner Losh.if defined(HAVE_GELI) 55ca987d46SWarner Losh.if defined(LOADER_NO_GELI_SUPPORT) 56ca987d46SWarner LoshMK_LOADER_GELI=no 57ca987d46SWarner Losh.warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI" 58ca987d46SWarner Losh.endif 59ca987d46SWarner Losh.if defined(LOADER_GELI_SUPPORT) 60ca987d46SWarner LoshMK_LOADER_GELI=yes 61ca987d46SWarner Losh.warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI" 62ca987d46SWarner Losh.endif 63ca987d46SWarner Losh.if ${MK_LOADER_GELI} == "yes" 64ca987d46SWarner LoshCFLAGS+= -DLOADER_GELI_SUPPORT 65ca987d46SWarner LoshCFLAGS+= -I${BOOTSRC}/geli 66ca987d46SWarner LoshLIBGELIBOOT= ${BOOTOBJ}/geli/libgeliboot.a 67*4927bbceSWarner Losh.endif # MK_LOADER_GELI 68*4927bbceSWarner Losh.endif # HAVE_GELI 69ca987d46SWarner Losh 704f6b2874SWarner Losh# Machine specific flags for all builds here 71ca987d46SWarner Losh 72ca987d46SWarner Losh# All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc 73ca987d46SWarner Losh# or powerpc64. 74ca987d46SWarner Losh.if ${MACHINE_ARCH} == "powerpc64" 75ca987d46SWarner LoshCFLAGS+= -m32 -mcpu=powerpc 76ca987d46SWarner Losh.endif 77ca987d46SWarner Losh 78ca987d46SWarner Losh# For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is 79ca987d46SWarner Losh# build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here 80ca987d46SWarner Losh# and activate it when DO32 is explicitly defined to be 1. 81ca987d46SWarner Losh.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 82ca987d46SWarner LoshCFLAGS+= -m32 -mcpu=i386 83ca987d46SWarner Losh# LD_FLAGS is passed directly to ${LD}, not via ${CC}: 84ca987d46SWarner LoshLD_FLAGS+= -m elf_i386_fbsd 85ca987d46SWarner LoshAFLAGS+= --32 86ca987d46SWarner Losh.endif 87ca987d46SWarner Losh 884f6b2874SWarner LoshSSP_CFLAGS= 894f6b2874SWarner Losh 904f6b2874SWarner Losh# Add in the no float / no SIMD stuff and announce we're freestanding 914f6b2874SWarner Losh# aarch64 and riscv don't have -msoft-float, but all others do. riscv 924f6b2874SWarner Losh# currently has no /boot/loader, but may soon. 934f6b2874SWarner LoshCFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD} 944f6b2874SWarner Losh.if ${MACHINE_CPUARCH} == "aarch64" 954f6b2874SWarner LoshCFLAGS+= -mgeneral-regs-only 964f6b2874SWarner Losh.elif ${MACHINE_CPUARCH} != "riscv" 974f6b2874SWarner LoshCFLAGS+= -msoft-float 984f6b2874SWarner Losh.endif 994f6b2874SWarner Losh 1004f6b2874SWarner Losh.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1) 1014f6b2874SWarner LoshCFLAGS+= -march=i386 1024f6b2874SWarner LoshCFLAGS.gcc+= -mpreferred-stack-boundary=2 1034f6b2874SWarner Losh.endif 1044f6b2874SWarner Losh 1054f6b2874SWarner Losh 1064f6b2874SWarner Losh.if ${MACHINE_CPUARCH} == "arm" 1074f6b2874SWarner Losh# Do not generate movt/movw, because the relocation fixup for them does not 1084f6b2874SWarner Losh# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). 1094f6b2874SWarner Losh# Also, the fpu is not available in a standalone environment. 1104f6b2874SWarner Losh.if ${COMPILER_VERSION} < 30800 1114f6b2874SWarner LoshCFLAGS.clang+= -mllvm -arm-use-movt=0 1124f6b2874SWarner Losh.else 1134f6b2874SWarner LoshCFLAGS.clang+= -mno-movt 1144f6b2874SWarner Losh.endif 1154f6b2874SWarner LoshCFLAGS.clang+= -mfpu=none 1164f6b2874SWarner Losh.endif 1174f6b2874SWarner Losh 1184f6b2874SWarner Losh# The boot loader build uses dd status=none, where possible, for reproducible 1194f6b2874SWarner Losh# build output (since performance varies from run to run). Trouble is that 1204f6b2874SWarner Losh# option was recently (10.3) added to FreeBSD and is non-standard. Only use it 1214f6b2874SWarner Losh# when this test succeeds rather than require dd to be a bootstrap tool. 1224f6b2874SWarner LoshDD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true 1234f6b2874SWarner LoshDD=dd ${DD_NOSTATUS} 1244f6b2874SWarner Losh 1254f6b2874SWarner Losh.if ${MK_LOADER_FORCE_LE} != "no" 1264f6b2874SWarner Losh.if ${MACHINE_ARCH} == "powerpc64" 1274f6b2874SWarner LoshCFLAGS+= -mlittle-endian 1284f6b2874SWarner Losh.endif 1294f6b2874SWarner Losh.endif 1304f6b2874SWarner Losh 131ca987d46SWarner Losh# Make sure we use the machine link we're about to create 132ca987d46SWarner LoshCFLAGS+=-I. 133ca987d46SWarner Losh 134ca987d46SWarner Losh_ILINKS=machine 135ca987d46SWarner Losh.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" 136ca987d46SWarner Losh_ILINKS+=${MACHINE_CPUARCH} 137ca987d46SWarner Losh.endif 138ca987d46SWarner Losh.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 139ca987d46SWarner Losh_ILINKS+=x86 140ca987d46SWarner Losh.endif 141ca987d46SWarner LoshCLEANFILES+=${_ILINKS} 142ca987d46SWarner Losh 143ca987d46SWarner Loshall: ${PROG} 144ca987d46SWarner Losh 145ca987d46SWarner Loshbeforedepend: ${_ILINKS} 146ca987d46SWarner Loshbeforebuild: ${_ILINKS} 147ca987d46SWarner Losh 148ca987d46SWarner Losh# Ensure that the links exist without depending on it when it exists which 149ca987d46SWarner Losh# causes all the modules to be rebuilt when the directory pointed to changes. 150ca987d46SWarner Losh.for _link in ${_ILINKS} 151ca987d46SWarner Losh.if !exists(${.OBJDIR}/${_link}) 152ca987d46SWarner Losh${OBJS}: ${_link} 153ca987d46SWarner Losh.endif 154ca987d46SWarner Losh.endfor 155ca987d46SWarner Losh 156ca987d46SWarner Losh.NOPATH: ${_ILINKS} 157ca987d46SWarner Losh 158ca987d46SWarner Losh${_ILINKS}: 159ca987d46SWarner Losh @case ${.TARGET} in \ 160ca987d46SWarner Losh machine) \ 161ca987d46SWarner Losh if [ ${DO32:U0} -eq 0 ]; then \ 162ca987d46SWarner Losh path=${SYSDIR}/${MACHINE}/include ; \ 163ca987d46SWarner Losh else \ 164ca987d46SWarner Losh path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \ 165ca987d46SWarner Losh fi ;; \ 166ca987d46SWarner Losh *) \ 167ca987d46SWarner Losh path=${SYSDIR}/${.TARGET:T}/include ;; \ 168ca987d46SWarner Losh esac ; \ 169ca987d46SWarner Losh path=`(cd $$path && /bin/pwd)` ; \ 170ca987d46SWarner Losh ${ECHO} ${.TARGET:T} "->" $$path ; \ 171ca987d46SWarner Losh ln -fhs $$path ${.TARGET:T} 172ca987d46SWarner Losh 173ca987d46SWarner Losh# For loader implementations, we generate a loader.help file. This can be suppressed by 174ca987d46SWarner Losh# setting HELP_FILES to nothing. 175ca987d46SWarner LoshHELP_FILES= ${LDRSRC}/help.common 176ca987d46SWarner Losh 177ca987d46SWarner Losh.endif # __BOOT_DEFS_MK__ 178