xref: /freebsd/stand/efi/loader/Makefile (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
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	gfx_fb.c \
27	8x16.c
28
29CFLAGS+=	-I${.CURDIR}/../loader
30.if ${MK_LOADER_ZFS} != "no"
31CFLAGS+=	-I${ZFSSRC}
32CFLAGS+=        -I${SYSDIR}/contrib/openzfs/include
33CFLAGS+=        -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs
34CFLAGS+=	-DEFI_ZFS_BOOT
35HAVE_ZFS=	yes
36.endif
37
38CFLAGS.bootinfo.c += -I$(SRCTOP)/sys/teken
39CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite
40CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken
41CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite
42CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken
43CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
44CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite
45CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
46
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
51# warnings for now.
52CWARNFLAGS.main.c+=	-Wno-format
53
54.PATH: ${.CURDIR}/../loader
55.PATH: ${.CURDIR}/../loader/arch/${MACHINE}
56.include "${.CURDIR}/../loader/arch/${MACHINE}/Makefile.inc"
57
58CFLAGS+=	-I${.CURDIR}
59CFLAGS+=	-I${.CURDIR}/arch/${MACHINE}
60CFLAGS+=	-I${EFISRC}/include
61CFLAGS+=	-I${EFISRC}/include/${MACHINE}
62CFLAGS+=	-I${SYSDIR}/contrib/dev/acpica/include
63CFLAGS+=	-I${BOOTSRC}/i386/libi386
64CFLAGS+=	-DEFI
65
66.if defined(HAVE_FDT) && ${MK_FDT} != "no"
67.include	"${BOOTSRC}/fdt.mk"
68LIBEFI_FDT=	${BOOTOBJ}/efi/fdt/libefi_fdt.a
69.endif
70
71# Include bcache code.
72HAVE_BCACHE=    yes
73
74.if defined(EFI_STAGING_SIZE)
75CFLAGS+=	-DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
76.endif
77
78.if ${MK_LOADER_EFI_SECUREBOOT} != "no"
79CFLAGS+= -DEFI_SECUREBOOT
80.endif
81
82NEWVERSWHAT=	"EFI loader" ${MACHINE}
83VERSION_FILE=	${.CURDIR}/../loader/version
84
85# Always add MI sources
86.include	"${BOOTSRC}/loader.mk"
87
88CLEANFILES+=	8x16.c
89
908x16.c:		${SRCTOP}/contrib/terminus/ter-u16b.bdf
91	vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC}
92
93FILES+=	${LOADER}.efi
94FILESMODE_${LOADER}.efi=	${BINMODE}
95
96.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
97LINKS+=		${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi
98.endif
99
100LDSCRIPT=	${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
101LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
102.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400
103LDFLAGS+=	-Wl,--no-dynamic-linker
104.endif
105
106CLEANFILES+=	loader.efi
107
108${LOADER}.efi: ${PROG}
109	if ${NM} ${.ALLSRC} | grep ' U '; then \
110		echo "Undefined symbols in ${.ALLSRC}"; \
111		exit 1; \
112	fi
113	SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
114	${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
115		-j .dynamic -j .dynsym -j .rel.dyn \
116		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
117		-j set_Xficl_compile_set \
118		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
119
120LIBEFI=		${BOOTOBJ}/efi/libefi/libefi.a
121
122DPADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT}
123LDADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA}
124
125.include <bsd.prog.mk>
126