1 2.include <bsd.init.mk> 3 4BOOT1?= boot1 5PROG= ${BOOT1}.sym 6INTERNALPROG= 7WARNS?= 6 8 9CFLAGS+= -DEFI_BOOT1 10# We implement a slightly non-standard %S in that it always takes a 11# CHAR16 that's common in UEFI-land instead of a wchar_t. This only 12# seems to matter on arm64 where wchar_t defaults to an int instead 13# of a short. There's no good cast to use here so just ignore the 14# warnings for now. 15CWARNFLAGS.proto.c+= -Wno-format 16CWARNFLAGS.boot1.c+= -Wno-format 17 18# Disable bogus alignment issues 19CWARNFLAGS.ufs_module.c += -Wno-format 20CWARNFLAGS.ufs_module.c += -Wno-cast-align 21 22# Disable warnings that are currently incompatible with the zfs boot code 23CWARNFLAGS.zfs_module.c += -Wno-array-bounds 24CWARNFLAGS.zfs_module.c += -Wno-cast-align 25CWARNFLAGS.zfs_module.c += -Wno-cast-qual 26CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes 27CWARNFLAGS.zfs_module.c += -Wno-sign-compare 28CWARNFLAGS.zfs_module.c += -Wno-unused-parameter 29CWARNFLAGS.zfs_module.c += -Wno-unused-function 30 31# architecture-specific loader code 32SRCS+= boot1.c proto.c self_reloc.c start.S ufs_module.c 33.if ${MK_LOADER_ZFS} != "no" 34SRCS+= zfs_module.c 35CFLAGS.zfs_module.c+= -I${ZFSSRC} 36CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/boot/zfs 37CFLAGS.zfs_module.c+= -I${SYSDIR}/crypto/skein 38CFLAGS.zfs_module.c+= -I${SYSDIR}/contrib/openzfs/include 39CFLAGS.zfs_module.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/spl 40CFLAGS.zfs_module.c+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs 41CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 42CFLAGS.zfs_module.c+= -include ${ZFSOSINC}/spl/sys/ccompile.h 43 44CFLAGS+= -DEFI_ZFS_BOOT 45.endif 46 47CFLAGS+= -I${EFIINC} 48CFLAGS+= -I${EFIINCMD} 49CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include 50CFLAGS+= -DEFI_UFS_BOOT 51.ifdef(EFI_DEBUG) 52CFLAGS+= -DEFI_DEBUG 53.endif 54 55.include "${BOOTSRC}/veriexec.mk" 56 57# Always add MI sources and REGULAR efi loader bits 58.PATH: ${EFISRC}/loader/arch/${MACHINE} 59.PATH: ${EFISRC}/loader 60.PATH: ${LDRSRC} 61CFLAGS+= -I${LDRSRC} 62 63FILES= ${BOOT1}.efi 64FILESMODE_${BOOT1}.efi= ${BINMODE} 65 66LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/${MACHINE}.ldscript 67LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie 68.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400 69LDFLAGS+= -Wl,--no-dynamic-linker 70.endif 71 72.if ${MACHINE_CPUARCH} == "aarch64" 73CFLAGS+= -mgeneral-regs-only 74.endif 75.if ${MACHINE_CPUARCH} == "amd64" 76CFLAGS+= -fPIC 77LDFLAGS+= -Wl,-znocombreloc 78.endif 79 80LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a 81 82# 83# Add libsa for the runtime functions used by the compiler as well as required 84# string and memory functions for all platforms. 85# 86DPADD+= ${LIBEFI} ${LIBSA} 87LDADD+= ${LIBEFI} ${LIBSA} 88 89DPADD+= ${LDSCRIPT} 90 91CLEANFILES+= ${BOOT1}.efi 92 93${BOOT1}.efi: ${PROG} 94 @if ${NM} ${.ALLSRC} | grep ' U '; then \ 95 echo "Undefined symbols in ${.ALLSRC}"; \ 96 exit 1; \ 97 fi 98 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 99 ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 100 -j .dynamic -j .dynsym -j .rel.dyn \ 101 -j .rela.dyn -j .reloc -j .eh_frame \ 102 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 103 104.include <bsd.prog.mk> 105