xref: /freebsd/stand/efi/loader/Makefile (revision 78adacd4eab39a3508bd8c65f0aba94fc6b907ce)
1# $FreeBSD$
2
3LOADER_NET_SUPPORT?=	yes
4LOADER_MSDOS_SUPPORT?=	yes
5LOADER_UFS_SUPPORT?=	yes
6LOADER_CD9660_SUPPORT?=	no
7LOADER_EXT2FS_SUPPORT?=	no
8
9.include <bsd.init.mk>
10
11LOADER?=	loader_${LOADER_INTERP}
12PROG=		${LOADER}.sym
13INTERNALPROG=
14WARNS?=		3
15
16# architecture-specific loader code
17SRCS=	autoload.c \
18	bootinfo.c \
19	conf.c \
20	copy.c \
21	efi_main.c \
22	framebuffer.c \
23	main.c \
24	self_reloc.c \
25	vers.c
26
27CFLAGS+=	-I${.CURDIR}/../loader
28.if ${MK_LOADER_ZFS} != "no"
29CFLAGS+=	-I${ZFSSRC}
30CFLAGS+=        -I${SYSDIR}/contrib/openzfs/include
31CFLAGS+=        -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs
32CFLAGS+=	-DEFI_ZFS_BOOT
33HAVE_ZFS=	yes
34.endif
35
36# We implement a slightly non-standard %S in that it always takes a
37# CHAR16 that's common in UEFI-land instead of a wchar_t. This only
38# seems to matter on arm64 where wchar_t defaults to an int instead
39# of a short. There's no good cast to use here so just ignore the
40# warnings for now.
41CWARNFLAGS.main.c+=	-Wno-format
42
43.PATH: ${.CURDIR}/../loader
44.PATH: ${.CURDIR}/../loader/arch/${MACHINE}
45.include "${.CURDIR}/../loader/arch/${MACHINE}/Makefile.inc"
46
47CFLAGS+=	-I${.CURDIR}
48CFLAGS+=	-I${.CURDIR}/arch/${MACHINE}
49CFLAGS+=	-I${EFISRC}/include
50CFLAGS+=	-I${EFISRC}/include/${MACHINE}
51CFLAGS+=	-I${SYSDIR}/contrib/dev/acpica/include
52CFLAGS+=	-I${BOOTSRC}/i386/libi386
53CFLAGS+=	-DEFI
54
55.if defined(HAVE_FDT) && ${MK_FDT} != "no"
56.include	"${BOOTSRC}/fdt.mk"
57LIBEFI_FDT=	${BOOTOBJ}/efi/fdt/libefi_fdt.a
58.endif
59
60# Include bcache code.
61HAVE_BCACHE=    yes
62
63.if defined(EFI_STAGING_SIZE)
64CFLAGS+=	-DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
65.endif
66
67.if ${MK_LOADER_EFI_SECUREBOOT} != "no"
68CFLAGS+= -DEFI_SECUREBOOT
69.endif
70
71NEWVERSWHAT=	"EFI loader" ${MACHINE}
72VERSION_FILE=	${.CURDIR}/../loader/version
73
74# Always add MI sources
75.include	"${BOOTSRC}/loader.mk"
76
77FILES+=	${LOADER}.efi
78FILESMODE_${LOADER}.efi=	${BINMODE}
79
80.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
81LINKS+=		${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi
82.endif
83
84LDSCRIPT=	${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
85LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
86
87CLEANFILES+=	loader.efi
88
89${LOADER}.efi: ${PROG}
90	if ${NM} ${.ALLSRC} | grep ' U '; then \
91		echo "Undefined symbols in ${.ALLSRC}"; \
92		exit 1; \
93	fi
94	SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
95	${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
96		-j .dynamic -j .dynsym -j .rel.dyn \
97		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
98		-j set_Xficl_compile_set \
99		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
100
101LIBEFI=		${BOOTOBJ}/efi/libefi/libefi.a
102
103DPADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT}
104LDADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA}
105
106.include <bsd.prog.mk>
107