xref: /freebsd/stand/efi/loader/Makefile (revision d9a42747950146bf03cda7f6e25d219253f8a57a)
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.main.c += -I$(SRCTOP)/sys/teken
43CFLAGS.main.c += -I${SRCTOP}/contrib/pnglite
44CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken
45CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
46CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite
47CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
48
49# We implement a slightly non-standard %S in that it always takes a
50# CHAR16 that's common in UEFI-land instead of a wchar_t. This only
51# seems to matter on arm64 where wchar_t defaults to an int instead
52# of a short. There's no good cast to use here so just ignore the
53# warnings for now.
54CWARNFLAGS.main.c+=	-Wno-format
55
56.PATH: ${.CURDIR}/../loader
57.PATH: ${.CURDIR}/../loader/arch/${MACHINE}
58.include "${.CURDIR}/../loader/arch/${MACHINE}/Makefile.inc"
59
60CFLAGS+=	-I${.CURDIR}
61CFLAGS+=	-I${.CURDIR}/arch/${MACHINE}
62CFLAGS+=	-I${EFISRC}/include
63CFLAGS+=	-I${EFISRC}/include/${MACHINE}
64CFLAGS+=	-I${SYSDIR}/contrib/dev/acpica/include
65CFLAGS+=	-I${BOOTSRC}/i386/libi386
66CFLAGS+=	-DEFI
67
68.if defined(HAVE_FDT) && ${MK_FDT} != "no"
69.include	"${BOOTSRC}/fdt.mk"
70LIBEFI_FDT=	${BOOTOBJ}/efi/fdt/libefi_fdt.a
71HELP_FILES+=	${FDTSRC}/help.fdt
72.endif
73
74# Include bcache code.
75HAVE_BCACHE=    yes
76
77.if defined(EFI_STAGING_SIZE)
78CFLAGS+=	-DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
79.endif
80
81.if ${MK_LOADER_EFI_SECUREBOOT} != "no"
82CFLAGS+= -DEFI_SECUREBOOT
83.endif
84
85NEWVERSWHAT=	"EFI loader" ${MACHINE}
86VERSION_FILE=	${.CURDIR}/../loader/version
87HELP_FILENAME=	loader.help.efi
88
89# Always add MI sources
90.include	"${BOOTSRC}/loader.mk"
91
92CLEANFILES+=	8x16.c
93
948x16.c:		${SRCTOP}/contrib/terminus/ter-u16b.bdf
95	vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC}
96
97FILES+=	${LOADER}.efi
98FILESMODE_${LOADER}.efi=	${BINMODE}
99
100.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
101LINKS+=		${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi
102.endif
103
104LDSCRIPT=	${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
105LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
106.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400
107LDFLAGS+=	-Wl,--no-dynamic-linker
108.endif
109
110CLEANFILES+=	${LOADER}.efi
111
112${LOADER}.efi: ${PROG}
113	if ${NM} ${.ALLSRC} | grep ' U '; then \
114		echo "Undefined symbols in ${.ALLSRC}"; \
115		exit 1; \
116	fi
117	SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
118	${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
119		-j .dynamic -j .dynsym -j .rel.dyn \
120		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
121		-j set_Xficl_compile_set \
122		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
123
124LIBEFI=		${BOOTOBJ}/efi/libefi/libefi.a
125
126DPADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT}
127LDADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA}
128
129.include <bsd.prog.mk>
130