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