xref: /freebsd/stand/efi/loader/Makefile (revision e9ac41698b2f322d55ccf9da50a3596edb2c1800)
1LOADER_NET_SUPPORT?=	yes
2LOADER_MSDOS_SUPPORT?=	yes
3LOADER_UFS_SUPPORT?=	yes
4LOADER_CD9660_SUPPORT?=	no
5LOADER_EXT2FS_SUPPORT?=	no
6
7.include <bsd.init.mk>
8
9LOADER?=	loader_${LOADER_INTERP}
10PROG=		${LOADER}.sym
11INTERNALPROG=
12WARNS?=		3
13
14# architecture-specific loader code
15SRCS=	autoload.c \
16	bootinfo.c \
17	conf.c \
18	copy.c \
19	efi_main.c \
20	framebuffer.c \
21	main.c \
22	self_reloc.c \
23	vers.c \
24	gfx_fb.c \
25	8x16.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
36CFLAGS.bootinfo.c += -I$(SRCTOP)/sys/teken
37CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite
38CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken
39CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite
40CFLAGS.main.c += -I$(SRCTOP)/sys/teken
41CFLAGS.main.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
69HELP_FILES+=	${FDTSRC}/help.fdt
70.endif
71
72# Include bcache code.
73HAVE_BCACHE=    yes
74
75.if defined(EFI_STAGING_SIZE)
76CFLAGS+=	-DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
77.endif
78
79.if ${MK_LOADER_EFI_SECUREBOOT} != "no"
80CFLAGS+= -DEFI_SECUREBOOT
81.endif
82
83NEWVERSWHAT?=	"EFI loader" ${MACHINE}
84VERSION_FILE=	${.CURDIR}/../loader/version
85HELP_FILENAME=	loader.help.efi
86
87# Always add MI sources
88.include	"${BOOTSRC}/loader.mk"
89
90CLEANFILES+=	8x16.c
91
928x16.c:		${SRCTOP}/contrib/terminus/ter-u16b.bdf
93	vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC}
94
95FILES+=	${LOADER}.efi
96FILESMODE_${LOADER}.efi=	${BINMODE}
97
98.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
99LINKS+=		${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi
100.endif
101
102LDSCRIPT=	${.CURDIR}/../loader/arch/${MACHINE}/${MACHINE}.ldscript
103LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
104.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400
105LDFLAGS+=	-Wl,--no-dynamic-linker
106.endif
107
108CLEANFILES+=	${LOADER}.efi
109
110${LOADER}.efi: ${PROG}
111	@if ${NM} ${.ALLSRC} | grep ' U '; then \
112		echo "Undefined symbols in ${.ALLSRC}"; \
113		exit 1; \
114	fi
115	SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
116	${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
117		-j .dynamic -j .dynsym -j .rel.dyn \
118		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
119		-j set_X${LOADER_INTERP}_compile_set \
120		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
121
122LIBEFI=		${BOOTOBJ}/efi/libefi/libefi.a
123
124DPADD=		${LDR_INTERP} ${LIBEFI} ${LIBSAFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT}
125LDADD=		${LDR_INTERP} ${LIBEFI} ${LIBSAFDT} ${LIBEFI_FDT} ${LIBSA}
126
127.include <bsd.prog.mk>
128