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