2017-10-16 03:59:38 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
|
|
|
.if !defined(__BOOT_DEFS_MK__)
|
|
|
|
__BOOT_DEFS_MK__=${MFILE}
|
|
|
|
|
2018-12-03 17:51:10 +00:00
|
|
|
# We need to define all the MK_ options before including src.opts.mk
|
|
|
|
# because it includes bsd.own.mk which needs the right MK_ values,
|
|
|
|
# espeically MK_CTF.
|
|
|
|
|
2018-02-02 06:32:26 +00:00
|
|
|
MK_CTF= no
|
|
|
|
MK_SSP= no
|
|
|
|
MK_PROFILE= no
|
|
|
|
MAN=
|
2018-02-08 22:59:51 +00:00
|
|
|
.if !defined(PIC)
|
|
|
|
NO_PIC=
|
2018-02-02 06:32:26 +00:00
|
|
|
INTERNALLIB=
|
2018-02-08 22:59:51 +00:00
|
|
|
.endif
|
2018-02-02 06:32:26 +00:00
|
|
|
|
2018-12-03 17:51:10 +00:00
|
|
|
.include <src.opts.mk>
|
|
|
|
|
|
|
|
WARNS?= 1
|
|
|
|
|
2017-11-14 23:02:19 +00:00
|
|
|
BOOTSRC= ${SRCTOP}/stand
|
2017-10-29 05:26:59 +00:00
|
|
|
EFISRC= ${BOOTSRC}/efi
|
|
|
|
EFIINC= ${EFISRC}/include
|
|
|
|
EFIINCMD= ${EFIINC}/${MACHINE}
|
2017-10-22 22:50:08 +00:00
|
|
|
FDTSRC= ${BOOTSRC}/fdt
|
|
|
|
FICLSRC= ${BOOTSRC}/ficl
|
|
|
|
LDRSRC= ${BOOTSRC}/common
|
Add Lua as a scripting langauge to /boot/loader
liblua glues the lua run time into the boot loader. It implements all
the runtime routines that lua expects. In addition, it has a few
standard 'C' headers that nueter various aspects of the LUA build that
are too specific to lua to be in libsa. Many refinements from the
original code to improve implementation and the number of included lua
libraries. Use int64_t for lua_Number. Have "/boot/lua" be the default
module path. Numerous cleanups from the original GSoC project,
including hacking libsa to allow lua to be built with only one change
outside luaconf.h.
Add the final bit of lua glue to bring in liblua and plug into the
multiple interpreter framework, previously committed.
Add LOADER_LUA option, currently off by default.
Presently, this is an experimental option. One must opt-in to using
this by defining WITH_LOADER_LUA and WITHOUT_FORTH. It's been
lightly tested, so keep a backup copy of your old loader handy.
The menu code, coming in the next commit, hasn't been exhaustively
tested. A LUA boot loader is 60k larger than a FORTH one, which is
80k larger than a no-interpreter one. Subtle changes in size
may tip things past some subtle limit (the binary is ~430k now
when built with LUA). A future version may offer coexistance.
Bump FreeBSD version to 1200058 to mark the milestone.
Pedro Souza's 2014 Summer of Code project. Rui Paulo, Pedro Arthur,
Zakary Nafziger and Wojciech A. Koszek also contributed. Warner Losh
reworked it extensively into its current form.
Obtained from: https://wiki.freebsd.org/SummerOfCode2014/LuaLoader
Sponsored by: Google Summer of Code
Relnotes: Yes
MFC After: 1 month
Differential Review: https://reviews.freebsd.org/D14295
2018-02-12 15:31:53 +00:00
|
|
|
LIBLUASRC= ${BOOTSRC}/liblua
|
|
|
|
LUASRC= ${SRCTOP}/contrib/lua/src
|
2017-10-22 22:50:08 +00:00
|
|
|
SASRC= ${BOOTSRC}/libsa
|
2017-10-16 03:59:38 +00:00
|
|
|
SYSDIR= ${SRCTOP}/sys
|
2017-10-22 22:50:08 +00:00
|
|
|
UBOOTSRC= ${BOOTSRC}/uboot
|
2018-07-08 07:42:49 +00:00
|
|
|
ZFSSRC= ${SASRC}/zfs
|
2019-08-16 13:22:57 +00:00
|
|
|
LIBCSRC= ${SRCTOP}/lib/libc
|
2017-10-16 03:59:38 +00:00
|
|
|
|
2017-11-14 23:02:19 +00:00
|
|
|
BOOTOBJ= ${OBJTOP}/stand
|
2017-10-22 03:52:08 +00:00
|
|
|
|
2017-10-25 15:27:58 +00:00
|
|
|
# BINDIR is where we install
|
|
|
|
BINDIR?= /boot
|
|
|
|
|
2017-10-22 03:52:08 +00:00
|
|
|
LIBSA= ${BOOTOBJ}/libsa/libsa.a
|
2017-10-22 07:25:28 +00:00
|
|
|
.if ${MACHINE} == "i386"
|
|
|
|
LIBSA32= ${LIBSA}
|
|
|
|
.else
|
2017-10-22 03:52:08 +00:00
|
|
|
LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a
|
2017-10-22 07:25:28 +00:00
|
|
|
.endif
|
2017-10-16 03:59:38 +00:00
|
|
|
|
2017-10-16 03:59:52 +00:00
|
|
|
# Standard options:
|
2017-12-05 21:38:19 +00:00
|
|
|
CFLAGS+= -nostdinc
|
|
|
|
.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
|
|
|
|
CFLAGS+= -I${BOOTOBJ}/libsa32
|
|
|
|
.else
|
|
|
|
CFLAGS+= -I${BOOTOBJ}/libsa
|
|
|
|
.endif
|
2017-12-02 00:07:04 +00:00
|
|
|
CFLAGS+= -I${SASRC} -D_STANDALONE
|
2017-12-02 00:06:58 +00:00
|
|
|
CFLAGS+= -I${SYSDIR}
|
2018-02-23 04:04:25 +00:00
|
|
|
# Spike the floating point interfaces
|
2018-02-23 04:06:15 +00:00
|
|
|
CFLAGS+= -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface
|
2018-09-05 20:02:23 +00:00
|
|
|
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
|
2018-08-15 20:31:11 +00:00
|
|
|
# Slim down the image. This saves about 15% in size with clang 6 on x86
|
|
|
|
# Our most constrained /boot/loader env is BIOS booting on x86, where
|
|
|
|
# our text + data + BTX have to fit into 640k below the ISA hole.
|
|
|
|
# Experience has shown that problems arise between ~520k to ~530k.
|
|
|
|
CFLAGS.clang+= -Oz
|
|
|
|
CFLAGS.gcc+= -Os
|
2018-09-05 20:02:23 +00:00
|
|
|
.endif
|
2017-10-16 03:59:52 +00:00
|
|
|
|
2017-12-11 14:47:23 +00:00
|
|
|
# GELI Support, with backward compat hooks (mostly)
|
2017-11-10 23:54:48 +00:00
|
|
|
.if defined(LOADER_NO_GELI_SUPPORT)
|
|
|
|
MK_LOADER_GELI=no
|
|
|
|
.warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI"
|
|
|
|
.endif
|
|
|
|
.if defined(LOADER_GELI_SUPPORT)
|
|
|
|
MK_LOADER_GELI=yes
|
|
|
|
.warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI"
|
|
|
|
.endif
|
|
|
|
.if ${MK_LOADER_GELI} == "yes"
|
|
|
|
CFLAGS+= -DLOADER_GELI_SUPPORT
|
2018-06-18 16:24:42 +00:00
|
|
|
CFLAGS+= -I${SASRC}/geli
|
2017-12-16 21:33:21 +00:00
|
|
|
.endif # MK_LOADER_GELI
|
2017-11-10 23:54:48 +00:00
|
|
|
|
2017-12-29 18:08:35 +00:00
|
|
|
# These should be confined to loader.mk, but can't because uboot/lib
|
|
|
|
# also uses it. It's part of loader, but isn't a loader so we can't
|
|
|
|
# just include loader.mk
|
|
|
|
.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
|
|
|
|
CFLAGS+= -DLOADER_DISK_SUPPORT
|
|
|
|
.endif
|
|
|
|
|
2017-12-02 00:06:58 +00:00
|
|
|
# Machine specific flags for all builds here
|
2017-10-16 03:59:52 +00:00
|
|
|
|
2017-11-06 15:21:39 +00:00
|
|
|
# All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc
|
|
|
|
# or powerpc64.
|
|
|
|
.if ${MACHINE_ARCH} == "powerpc64"
|
|
|
|
CFLAGS+= -m32 -mcpu=powerpc
|
|
|
|
.endif
|
|
|
|
|
2017-11-06 15:22:24 +00:00
|
|
|
# For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is
|
|
|
|
# build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here
|
|
|
|
# and activate it when DO32 is explicitly defined to be 1.
|
|
|
|
.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
|
2018-05-31 14:38:13 +00:00
|
|
|
CFLAGS+= -m32
|
2017-11-06 15:22:24 +00:00
|
|
|
# LD_FLAGS is passed directly to ${LD}, not via ${CC}:
|
|
|
|
LD_FLAGS+= -m elf_i386_fbsd
|
|
|
|
AFLAGS+= --32
|
|
|
|
.endif
|
|
|
|
|
2017-12-02 00:06:58 +00:00
|
|
|
SSP_CFLAGS=
|
|
|
|
|
|
|
|
# Add in the no float / no SIMD stuff and announce we're freestanding
|
|
|
|
# aarch64 and riscv don't have -msoft-float, but all others do. riscv
|
|
|
|
# currently has no /boot/loader, but may soon.
|
|
|
|
CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD}
|
|
|
|
.if ${MACHINE_CPUARCH} == "aarch64"
|
2018-02-16 00:17:32 +00:00
|
|
|
CFLAGS+= -mgeneral-regs-only -fPIC
|
|
|
|
.elif ${MACHINE_CPUARCH} == "riscv"
|
2018-09-03 14:43:16 +00:00
|
|
|
CFLAGS+= -march=rv64imac -mabi=lp64
|
2018-02-16 00:17:32 +00:00
|
|
|
.else
|
2017-12-02 00:06:58 +00:00
|
|
|
CFLAGS+= -msoft-float
|
|
|
|
.endif
|
|
|
|
|
2018-11-28 01:47:01 +00:00
|
|
|
# -msoft-float seems to be insufficient for powerpcspe
|
|
|
|
.if ${MACHINE_ARCH} == "powerpcspe"
|
|
|
|
CFLAGS+= -mno-spe
|
|
|
|
.endif
|
|
|
|
|
2017-12-02 00:06:58 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1)
|
|
|
|
CFLAGS+= -march=i386
|
|
|
|
CFLAGS.gcc+= -mpreferred-stack-boundary=2
|
|
|
|
.endif
|
2018-02-16 00:17:32 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0
|
|
|
|
CFLAGS+= -fPIC -mno-red-zone
|
|
|
|
.endif
|
2017-12-02 00:06:58 +00:00
|
|
|
|
|
|
|
.if ${MACHINE_CPUARCH} == "arm"
|
|
|
|
# Do not generate movt/movw, because the relocation fixup for them does not
|
|
|
|
# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
|
|
|
|
# Also, the fpu is not available in a standalone environment.
|
|
|
|
.if ${COMPILER_VERSION} < 30800
|
|
|
|
CFLAGS.clang+= -mllvm -arm-use-movt=0
|
|
|
|
.else
|
|
|
|
CFLAGS.clang+= -mno-movt
|
|
|
|
.endif
|
|
|
|
CFLAGS.clang+= -mfpu=none
|
2018-02-16 00:17:32 +00:00
|
|
|
CFLAGS+= -fPIC
|
2017-12-02 00:06:58 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# The boot loader build uses dd status=none, where possible, for reproducible
|
|
|
|
# build output (since performance varies from run to run). Trouble is that
|
|
|
|
# option was recently (10.3) added to FreeBSD and is non-standard. Only use it
|
|
|
|
# when this test succeeds rather than require dd to be a bootstrap tool.
|
|
|
|
DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true
|
|
|
|
DD=dd ${DD_NOSTATUS}
|
|
|
|
|
2018-02-16 00:17:32 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "mips"
|
|
|
|
CFLAGS+= -G0 -fno-pic -mno-abicalls
|
|
|
|
.endif
|
|
|
|
|
2017-12-02 00:06:58 +00:00
|
|
|
.if ${MK_LOADER_FORCE_LE} != "no"
|
|
|
|
.if ${MACHINE_ARCH} == "powerpc64"
|
|
|
|
CFLAGS+= -mlittle-endian
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2018-08-14 18:44:41 +00:00
|
|
|
#
|
|
|
|
# Have a sensible default
|
|
|
|
#
|
2018-08-19 14:26:33 +00:00
|
|
|
.if ${MK_LOADER_LUA} == "yes"
|
2018-08-14 18:44:41 +00:00
|
|
|
LOADER_DEFAULT_INTERP?=lua
|
2018-08-19 14:26:33 +00:00
|
|
|
.elif ${MK_FORTH} == "yes"
|
|
|
|
LOADER_DEFAULT_INTERP?=4th
|
2018-08-14 18:44:41 +00:00
|
|
|
.else
|
|
|
|
LOADER_DEFAULT_INTERP?=simp
|
|
|
|
.endif
|
|
|
|
LOADER_INTERP?=${LOADER_DEFAULT_INTERP}
|
|
|
|
|
2017-11-10 23:54:58 +00:00
|
|
|
# Make sure we use the machine link we're about to create
|
|
|
|
CFLAGS+=-I.
|
|
|
|
|
2018-03-18 18:50:48 +00:00
|
|
|
all: ${PROG}
|
|
|
|
|
2019-09-05 22:15:50 +00:00
|
|
|
CLEANFILES+= teken_state.h
|
|
|
|
teken.c: teken_state.h
|
|
|
|
|
|
|
|
teken_state.h: ${SYSDIR}/teken/sequences
|
|
|
|
awk -f ${SYSDIR}/teken/gensequences \
|
|
|
|
${SYSDIR}/teken/sequences > teken_state.h
|
|
|
|
|
2018-03-18 18:50:48 +00:00
|
|
|
.if !defined(NO_OBJ)
|
2017-11-06 15:22:04 +00:00
|
|
|
_ILINKS=machine
|
|
|
|
.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64"
|
|
|
|
_ILINKS+=${MACHINE_CPUARCH}
|
|
|
|
.endif
|
|
|
|
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
|
|
|
|
_ILINKS+=x86
|
|
|
|
.endif
|
|
|
|
CLEANFILES+=${_ILINKS}
|
|
|
|
|
|
|
|
beforedepend: ${_ILINKS}
|
|
|
|
beforebuild: ${_ILINKS}
|
|
|
|
|
|
|
|
# Ensure that the links exist without depending on it when it exists which
|
|
|
|
# causes all the modules to be rebuilt when the directory pointed to changes.
|
|
|
|
.for _link in ${_ILINKS}
|
|
|
|
.if !exists(${.OBJDIR}/${_link})
|
|
|
|
${OBJS}: ${_link}
|
2018-03-18 18:50:48 +00:00
|
|
|
.endif # _link exists
|
2017-11-06 15:22:04 +00:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
.NOPATH: ${_ILINKS}
|
|
|
|
|
|
|
|
${_ILINKS}:
|
|
|
|
@case ${.TARGET} in \
|
|
|
|
machine) \
|
|
|
|
if [ ${DO32:U0} -eq 0 ]; then \
|
|
|
|
path=${SYSDIR}/${MACHINE}/include ; \
|
|
|
|
else \
|
|
|
|
path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \
|
|
|
|
fi ;; \
|
|
|
|
*) \
|
|
|
|
path=${SYSDIR}/${.TARGET:T}/include ;; \
|
|
|
|
esac ; \
|
|
|
|
path=`(cd $$path && /bin/pwd)` ; \
|
|
|
|
${ECHO} ${.TARGET:T} "->" $$path ; \
|
|
|
|
ln -fhs $$path ${.TARGET:T}
|
2018-03-18 18:50:48 +00:00
|
|
|
.endif # !NO_OBJ
|
2017-10-16 03:59:38 +00:00
|
|
|
.endif # __BOOT_DEFS_MK__
|