xref: /freebsd/stand/efi/loader/Makefile (revision 0078721898754f6e71063e1f566c8671288a2218)
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
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
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}/ldscript.${MACHINE}
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_Xficl_compile_set \
120		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
121
122LIBEFI=		${BOOTOBJ}/efi/libefi/libefi.a
123
124DPADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT}
125LDADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA}
126
127.include <bsd.prog.mk>
128