13 # architecture-specific loader code
26 .PATH: ${.CURDIR}/../../zfs
27 SRCS+= skein.c skein_block.c
28 # Do not unroll skein loops, reduce code size
29 CFLAGS+= -DSKEIN_LOOP=111
30 .PATH: ${.CURDIR}/../../../crypto/skein
32 # Disable warnings that are currently incompatible with the zfs boot code
33 CWARNFLAGS.zfs.c+= -Wno-sign-compare
34 CWARNFLAGS.zfs.c+= -Wno-array-bounds
35 CWARNFLAGS.zfs.c+= -Wno-missing-prototypes
38 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
39 CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized
42 # We implement a slightly non-standard %S in that it always takes a
43 # CHAR16 that's common in UEFI-land instead of a wchar_t. This only
44 # seems to matter on arm64 where wchar_t defaults to an int instead
45 # of a short. There's no good cast to use here so just ignore the
47 CWARNFLAGS.main.c+= -Wno-format
49 .PATH: ${.CURDIR}/arch/${MACHINE}
51 .PATH: ${.CURDIR}/../../i386/libi386
52 .include "${.CURDIR}/arch/${MACHINE}/Makefile.inc"
55 CFLAGS+= -I${.CURDIR}/arch/${MACHINE}
56 CFLAGS+= -I${.CURDIR}/../include
57 CFLAGS+= -I${.CURDIR}/../include/${MACHINE}
58 CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include
59 CFLAGS+= -I${.CURDIR}/../../..
60 CFLAGS+= -I${.CURDIR}/../../i386/libi386
62 CFLAGS+= -I${.CURDIR}/../../zfs
63 CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs
64 CFLAGS+= -I${.CURDIR}/../../../crypto/skein
65 CFLAGS+= -DEFI_ZFS_BOOT
67 CFLAGS+= -DNO_PCI -DEFI
69 # make buildenv doesn't set DESTDIR, this means LIBSTAND
70 # will be wrong when crossbuilding.
71 .if exists(${.OBJDIR}/../../../../lib/libstand/libstand.a)
72 LIBSTAND= ${.OBJDIR}/../../../../lib/libstand/libstand.a
75 .if !defined(BOOT_HIDE_SERIAL_NUMBERS)
76 # Export serial numbers, UUID, and asset tag from loader.
77 CFLAGS+= -DSMBIOS_SERIAL_NUMBERS
78 .if defined(BOOT_LITTLE_ENDIAN_UUID)
79 # Use little-endian UUID format as defined in SMBIOS 2.6.
80 CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID
81 .elif defined(BOOT_NETWORK_ENDIAN_UUID)
82 # Use network-endian UUID format for backward compatibility.
83 CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID
87 .if ${MK_FORTH} != "no"
90 CFLAGS+= -I${.CURDIR}/../../ficl
91 CFLAGS+= -I${.CURDIR}/../../ficl/${MACHINE_CPUARCH}
92 LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
95 LOADER_FDT_SUPPORT?= no
96 .if ${MK_FDT} != "no" && ${LOADER_FDT_SUPPORT} != "no"
97 CFLAGS+= -I${.CURDIR}/../../fdt
98 CFLAGS+= -I${.OBJDIR}/../../fdt
99 CFLAGS+= -DLOADER_FDT_SUPPORT
100 LIBEFI_FDT= ${.OBJDIR}/../../efi/fdt/libefi_fdt.a
101 LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a
104 # Include bcache code.
107 .if defined(EFI_STAGING_SIZE)
108 CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
111 # Always add MI sources
112 .PATH: ${.CURDIR}/../../common
113 .include "${.CURDIR}/../../common/Makefile.inc"
114 CFLAGS+= -I${.CURDIR}/../../common
117 FILESMODE_loader.efi= ${BINMODE}
119 LDSCRIPT= ${.CURDIR}/arch/${MACHINE}/ldscript.${MACHINE}
120 LDFLAGS+= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared
122 CLEANFILES+= loader.efi
124 NEWVERSWHAT= "EFI loader" ${MACHINE}
129 .if ${MACHINE_CPUARCH} == "amd64"
130 EFI_TARGET= efi-app-x86_64
131 .elif ${MACHINE_CPUARCH} == "i386"
132 EFI_TARGET= efi-app-ia32
137 # Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00
138 # for build reproducibility.
139 SOURCE_DATE_EPOCH?=1451606400
141 if ${NM} ${.ALLSRC} | grep ' U '; then \
142 echo "Undefined symbols in ${.ALLSRC}"; \
145 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
146 ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
147 -j .dynamic -j .dynsym -j .rel.dyn \
148 -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
149 -j set_Xficl_compile_set \
150 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
152 LIBEFI= ${.OBJDIR}/../libefi/libefi.a
154 DPADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSTAND} \
156 LDADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSTAND}
158 .include <bsd.prog.mk>
160 beforedepend ${OBJS}: machine
165 ln -sf ${.CURDIR}/../../../${MACHINE}/include machine
167 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
168 beforedepend ${OBJS}: x86
172 ln -sf ${.CURDIR}/../../../x86/include x86