9 # We implement a slightly non-standard %S in that it always takes a
10 # CHAR16 that's common in UEFI-land instead of a wchar_t. This only
11 # seems to matter on arm64 where wchar_t defaults to an int instead
12 # of a short. There's no good cast to use here so just ignore the
14 CWARNFLAGS.boot1.c+= -Wno-format
16 # Disable warnings that are currently incompatible with the zfs boot code
17 CWARNFLAGS.zfs_module.c += -Wno-array-bounds
18 CWARNFLAGS.zfs_module.c += -Wno-cast-align
19 CWARNFLAGS.zfs_module.c += -Wno-cast-qual
20 CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes
21 CWARNFLAGS.zfs_module.c += -Wno-sign-compare
22 CWARNFLAGS.zfs_module.c += -Wno-unused-parameter
23 CWARNFLAGS.zfs_module.c += -Wno-unused-function
25 # architecture-specific loader code
26 SRCS= boot1.c self_reloc.c start.S ufs_module.c
29 CFLAGS.zfs_module.c+= -I${ZFSSRC}
30 CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/boot/zfs
31 CFLAGS.zfs_module.c+= -I${SYSDIR}/crypto/skein
32 CFLAGS+= -DEFI_ZFS_BOOT
35 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
36 CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized
40 CFLAGS+= -I${EFIINCMD}
41 CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include
42 CFLAGS+= -DEFI_UFS_BOOT
47 # Always add MI sources and REGULAR efi loader bits
48 .PATH: ${EFISRC}/loader/arch/${MACHINE}
49 .PATH: ${EFISRC}/loader
53 FILES= boot1.efi boot1.efifat
54 FILESMODE_boot1.efi= ${BINMODE}
56 LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE}
57 LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
59 .if ${MACHINE_CPUARCH} == "aarch64"
60 CFLAGS+= -mgeneral-regs-only
62 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
64 LDFLAGS+= -Wl,-znocombreloc
67 LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a
70 # Add libstand for the runtime functions used by the compiler - for example
71 # __aeabi_* (arm) or __divdi3 (i386).
72 # as well as required string and memory functions for all platforms.
74 DPADD+= ${LIBEFI} ${LIBSA}
75 LDADD+= ${LIBEFI} ${LIBSA}
82 .if ${MACHINE_CPUARCH} == "amd64"
83 EFI_TARGET= efi-app-x86_64
84 .elif ${MACHINE_CPUARCH} == "i386"
85 EFI_TARGET= efi-app-ia32
90 # Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00
91 # for build reproducibility.
92 SOURCE_DATE_EPOCH?=1451606400
94 if ${NM} ${.ALLSRC} | grep ' U '; then \
95 echo "Undefined symbols in ${.ALLSRC}"; \
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}
104 # The following inserts our objects into a template FAT file system
105 # created by generate-fat.sh
107 .include "Makefile.fat"
109 boot1.efifat: boot1.efi
110 @set -- `ls -l ${.ALLSRC}`; \
111 x=$$(($$5-${BOOT1_MAXSIZE})); \
112 if [ $$x -ge 0 ]; then \
113 echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\
117 xz -d -c ${BOOTSRC}/efi/boot1/fat-${MACHINE}.tmpl.xz > ${.TARGET}
118 ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
120 CLEANFILES+= boot1.efi boot1.efifat
122 .include <bsd.prog.mk>