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 devpath.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} 61.PATH: ${EFISRC}/libefi 62CFLAGS+= -I${LDRSRC} 63 64FILES= ${BOOT1}.efi 65FILESMODE_${BOOT1}.efi= ${BINMODE} 66 67LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/${MACHINE}.ldscript 68LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie 69.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400 70LDFLAGS+= -Wl,--no-dynamic-linker 71.endif 72 73.if ${MACHINE_CPUARCH} == "aarch64" 74CFLAGS+= -mgeneral-regs-only 75.endif 76.if ${MACHINE_CPUARCH} == "amd64" 77CFLAGS+= -fPIC 78LDFLAGS+= -Wl,-znocombreloc 79.endif 80 81LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a 82 83# 84# Add libsa for the runtime functions used by the compiler as well as required 85# string and memory functions for all platforms. 86# 87DPADD+= ${LIBEFI} ${LIBSA} 88LDADD+= ${LIBEFI} ${LIBSA} 89 90DPADD+= ${LDSCRIPT} 91 92CLEANFILES+= ${BOOT1}.efi 93 94${BOOT1}.efi: ${PROG} 95 @if ${NM} ${.ALLSRC} | grep ' U '; then \ 96 echo "Undefined symbols in ${.ALLSRC}"; \ 97 exit 1; \ 98 fi 99 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 100 ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 101 -j .dynamic -j .dynsym -j .rel.dyn \ 102 -j .rela.dyn -j .reloc -j .eh_frame \ 103 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 104 105.include <bsd.prog.mk> 106