xref: /freebsd/stand/efi/boot1/Makefile (revision 4e99f45480598189d49d45a825533a6c9e12f02c)
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}/cddl/contrib/opensolaris/uts/common
40CFLAGS.zfs_module.c+=	-I${SYSDIR}/cddl/contrib/opensolaris/common/lz4
41
42CFLAGS+=	-DEFI_ZFS_BOOT
43.endif
44
45CFLAGS+=	-I${EFIINC}
46CFLAGS+=	-I${EFIINCMD}
47CFLAGS+=	-I${SYSDIR}/contrib/dev/acpica/include
48CFLAGS+=	-DEFI_UFS_BOOT
49.ifdef(EFI_DEBUG)
50CFLAGS+=	-DEFI_DEBUG
51.endif
52
53# Always add MI sources and REGULAR efi loader bits
54.PATH:		${EFISRC}/loader/arch/${MACHINE}
55.PATH:		${EFISRC}/loader
56.PATH:		${LDRSRC}
57.PATH:		${EFISRC}/libefi
58CFLAGS+=	-I${LDRSRC}
59
60FILES=	${BOOT1}.efi
61FILESMODE_${BOOT1}.efi=	${BINMODE}
62
63LDSCRIPT=	${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE}
64LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
65
66.if ${MACHINE_CPUARCH} == "aarch64"
67CFLAGS+=	-mgeneral-regs-only
68.endif
69.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
70CFLAGS+=	-fPIC
71LDFLAGS+=	-Wl,-znocombreloc
72.endif
73
74LIBEFI=		${BOOTOBJ}/efi/libefi/libefi.a
75
76#
77# Add libstand for the runtime functions used by the compiler - for example
78# __aeabi_* (arm) or __divdi3 (i386).
79# as well as required string and memory functions for all platforms.
80#
81DPADD+=		${LIBEFI} ${LIBSA}
82LDADD+=		${LIBEFI} ${LIBSA}
83
84DPADD+=		${LDSCRIPT}
85
86${BOOT1}.efi: ${PROG}
87	if ${NM} ${.ALLSRC} | grep ' U '; then \
88		echo "Undefined symbols in ${.ALLSRC}"; \
89		exit 1; \
90	fi
91	SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
92	${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
93		-j .dynamic -j .dynsym -j .rel.dyn \
94		-j .rela.dyn -j .reloc -j .eh_frame \
95		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
96
97.include <bsd.prog.mk>
98