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