2014-04-13 01:14:25 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
2017-10-29 05:26:59 +00:00
|
|
|
.include <bsd.init.mk>
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2015-09-17 18:32:51 +00:00
|
|
|
PROG= boot1.sym
|
2014-04-13 01:14:25 +00:00
|
|
|
INTERNALPROG=
|
2017-10-17 23:38:27 +00:00
|
|
|
WARNS?= 6
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2018-08-27 11:14:49 +00:00
|
|
|
CFLAGS+= -DEFI_BOOT1
|
2017-09-07 07:30:24 +00:00
|
|
|
# We implement a slightly non-standard %S in that it always takes a
|
|
|
|
# CHAR16 that's common in UEFI-land instead of a wchar_t. This only
|
|
|
|
# seems to matter on arm64 where wchar_t defaults to an int instead
|
|
|
|
# of a short. There's no good cast to use here so just ignore the
|
|
|
|
# warnings for now.
|
|
|
|
CWARNFLAGS.boot1.c+= -Wno-format
|
|
|
|
|
2016-01-15 02:33:47 +00:00
|
|
|
# Disable warnings that are currently incompatible with the zfs boot code
|
2017-10-17 23:38:27 +00:00
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-array-bounds
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-cast-align
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-cast-qual
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-sign-compare
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-unused-parameter
|
|
|
|
CWARNFLAGS.zfs_module.c += -Wno-unused-function
|
2016-01-15 02:33:47 +00:00
|
|
|
|
2014-04-13 01:14:25 +00:00
|
|
|
# architecture-specific loader code
|
2017-10-17 23:38:27 +00:00
|
|
|
SRCS= boot1.c self_reloc.c start.S ufs_module.c
|
2016-01-15 02:33:47 +00:00
|
|
|
.if ${MK_ZFS} != "no"
|
2017-10-17 23:38:27 +00:00
|
|
|
SRCS+= zfs_module.c
|
2017-12-05 21:37:59 +00:00
|
|
|
CFLAGS.zfs_module.c+= -I${ZFSSRC}
|
|
|
|
CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/boot/zfs
|
|
|
|
CFLAGS.zfs_module.c+= -I${SYSDIR}/crypto/skein
|
2017-12-08 19:57:26 +00:00
|
|
|
CFLAGS+= -DEFI_ZFS_BOOT
|
2016-01-15 02:33:47 +00:00
|
|
|
.endif
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2017-03-28 23:56:02 +00:00
|
|
|
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
|
|
|
|
CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized
|
|
|
|
.endif
|
|
|
|
|
2017-10-29 05:26:59 +00:00
|
|
|
CFLAGS+= -I${EFIINC}
|
|
|
|
CFLAGS+= -I${EFIINCMD}
|
|
|
|
CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include
|
2016-01-15 01:22:36 +00:00
|
|
|
CFLAGS+= -DEFI_UFS_BOOT
|
2016-01-18 12:02:05 +00:00
|
|
|
.ifdef(EFI_DEBUG)
|
|
|
|
CFLAGS+= -DEFI_DEBUG
|
|
|
|
.endif
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2014-04-13 06:24:01 +00:00
|
|
|
# Always add MI sources and REGULAR efi loader bits
|
2017-10-29 05:26:59 +00:00
|
|
|
.PATH: ${EFISRC}/loader/arch/${MACHINE}
|
|
|
|
.PATH: ${EFISRC}/loader
|
|
|
|
.PATH: ${LDRSRC}
|
|
|
|
CFLAGS+= -I${LDRSRC}
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2014-04-26 16:34:22 +00:00
|
|
|
FILES= boot1.efi boot1.efifat
|
2014-04-13 01:14:25 +00:00
|
|
|
FILESMODE_boot1.efi= ${BINMODE}
|
|
|
|
|
2017-10-29 05:26:59 +00:00
|
|
|
LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE}
|
2017-07-01 18:48:15 +00:00
|
|
|
LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
|
2015-04-03 15:25:59 +00:00
|
|
|
|
2015-05-05 11:00:50 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "aarch64"
|
2017-04-07 22:58:25 +00:00
|
|
|
CFLAGS+= -mgeneral-regs-only
|
2015-05-05 11:00:50 +00:00
|
|
|
.endif
|
2015-04-03 15:25:59 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
|
2015-04-09 10:08:10 +00:00
|
|
|
CFLAGS+= -fPIC
|
2015-04-03 15:25:59 +00:00
|
|
|
LDFLAGS+= -Wl,-znocombreloc
|
|
|
|
.endif
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2017-10-29 05:26:59 +00:00
|
|
|
LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a
|
2017-08-26 18:30:14 +00:00
|
|
|
|
2015-04-06 15:50:20 +00:00
|
|
|
#
|
2015-04-07 21:41:26 +00:00
|
|
|
# Add libstand for the runtime functions used by the compiler - for example
|
|
|
|
# __aeabi_* (arm) or __divdi3 (i386).
|
2016-01-09 03:20:01 +00:00
|
|
|
# as well as required string and memory functions for all platforms.
|
2015-04-06 15:50:20 +00:00
|
|
|
#
|
2018-07-08 07:42:49 +00:00
|
|
|
DPADD+= ${LIBEFI} ${LIBSA}
|
|
|
|
LDADD+= ${LIBEFI} ${LIBSA}
|
2015-04-06 15:50:20 +00:00
|
|
|
|
2015-09-17 18:32:51 +00:00
|
|
|
DPADD+= ${LDSCRIPT}
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2015-09-17 18:32:51 +00:00
|
|
|
boot1.efi: ${PROG}
|
2016-03-12 21:44:33 +00:00
|
|
|
if ${NM} ${.ALLSRC} | grep ' U '; then \
|
|
|
|
echo "Undefined symbols in ${.ALLSRC}"; \
|
2014-04-13 01:14:25 +00:00
|
|
|
exit 1; \
|
|
|
|
fi
|
2016-08-31 21:35:38 +00:00
|
|
|
SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
|
2015-04-06 15:50:20 +00:00
|
|
|
${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
|
2014-04-13 01:14:25 +00:00
|
|
|
-j .dynamic -j .dynsym -j .rel.dyn \
|
2017-10-17 23:38:27 +00:00
|
|
|
-j .rela.dyn -j .reloc -j .eh_frame \
|
2014-12-23 15:58:45 +00:00
|
|
|
--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
|
2014-04-13 01:14:25 +00:00
|
|
|
|
2015-09-17 18:32:51 +00:00
|
|
|
# The following inserts our objects into a template FAT file system
|
2014-04-26 16:34:22 +00:00
|
|
|
# created by generate-fat.sh
|
|
|
|
|
2018-01-12 17:21:48 +00:00
|
|
|
.include "Makefile.fat"
|
2014-04-26 16:34:22 +00:00
|
|
|
|
|
|
|
boot1.efifat: boot1.efi
|
2017-03-28 21:35:18 +00:00
|
|
|
@set -- `ls -l ${.ALLSRC}`; \
|
2016-01-08 16:37:22 +00:00
|
|
|
x=$$(($$5-${BOOT1_MAXSIZE})); \
|
|
|
|
if [ $$x -ge 0 ]; then \
|
|
|
|
echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2014-04-26 16:34:22 +00:00
|
|
|
echo ${.OBJDIR}
|
2018-01-12 17:21:48 +00:00
|
|
|
xz -d -c ${BOOTSRC}/efi/boot1/fat-${MACHINE}.tmpl.xz > ${.TARGET}
|
2017-03-28 21:35:18 +00:00
|
|
|
${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
|
2014-04-26 16:34:22 +00:00
|
|
|
|
2017-11-10 23:54:58 +00:00
|
|
|
CLEANFILES+= boot1.efi boot1.efifat
|
2014-04-26 16:34:22 +00:00
|
|
|
|
2014-04-13 01:14:25 +00:00
|
|
|
.include <bsd.prog.mk>
|