xref: /freebsd/stand/efi/loader/Makefile (revision 38effe887ee979f91ad5abf42a2291558e7ff8d1)
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	smbios.c \
26	vers.c
27
28CFLAGS+=	-I${.CURDIR}/../loader
29.if ${MK_LOADER_ZFS} != "no"
30CFLAGS+=	-I${ZFSSRC}
31CFLAGS+=	-DEFI_ZFS_BOOT
32HAVE_ZFS=	yes
33.endif
34
35.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
36CWARNFLAGS.self_reloc.c+=	-Wno-error=maybe-uninitialized
37.endif
38
39# We implement a slightly non-standard %S in that it always takes a
40# CHAR16 that's common in UEFI-land instead of a wchar_t. This only
41# seems to matter on arm64 where wchar_t defaults to an int instead
42# of a short. There's no good cast to use here so just ignore the
43# warnings for now.
44CWARNFLAGS.main.c+=	-Wno-format
45
46.PATH: ${.CURDIR}/../loader
47.PATH: ${.CURDIR}/../loader/arch/${MACHINE}
48# For smbios.c XXX need to abstract properly
49.PATH: ${BOOTSRC}/i386/libi386
50.include "${.CURDIR}/../loader/arch/${MACHINE}/Makefile.inc"
51
52CFLAGS+=	-I${.CURDIR}
53CFLAGS+=	-I${.CURDIR}/arch/${MACHINE}
54CFLAGS+=	-I${EFISRC}/include
55CFLAGS+=	-I${EFISRC}/include/${MACHINE}
56CFLAGS+=	-I${SYSDIR}/contrib/dev/acpica/include
57CFLAGS+=	-I${BOOTSRC}/i386/libi386
58CFLAGS+=	-DEFI
59
60.if !defined(BOOT_HIDE_SERIAL_NUMBERS)
61# Export serial numbers, UUID, and asset tag from loader.
62CFLAGS+= -DSMBIOS_SERIAL_NUMBERS
63.if defined(BOOT_LITTLE_ENDIAN_UUID)
64# Use little-endian UUID format as defined in SMBIOS 2.6.
65CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID
66.elif defined(BOOT_NETWORK_ENDIAN_UUID)
67# Use network-endian UUID format for backward compatibility.
68CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID
69.endif
70.endif
71
72.if defined(HAVE_FDT) && ${MK_FDT} != "no"
73.include	"${BOOTSRC}/fdt.mk"
74LIBEFI_FDT=	${BOOTOBJ}/efi/fdt/libefi_fdt.a
75.endif
76
77# Include bcache code.
78HAVE_BCACHE=    yes
79
80.if defined(EFI_STAGING_SIZE)
81CFLAGS+=	-DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
82.endif
83
84.if ${MK_LOADER_EFI_SECUREBOOT} != "no"
85CFLAGS+= -DEFI_SECUREBOOT
86.endif
87
88NEWVERSWHAT=	"EFI loader" ${MACHINE}
89VERSION_FILE=	${.CURDIR}/../loader/version
90
91# Always add MI sources
92.include	"${BOOTSRC}/loader.mk"
93
94FILES+=	${LOADER}.efi
95FILESMODE_${LOADER}.efi=	${BINMODE}
96
97.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
98LINKS+=		${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi
99.endif
100
101LDSCRIPT=	${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
102LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
103
104CLEANFILES+=	loader.efi
105
106${LOADER}.efi: ${PROG}
107	if ${NM} ${.ALLSRC} | grep ' U '; then \
108		echo "Undefined symbols in ${.ALLSRC}"; \
109		exit 1; \
110	fi
111	SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
112	${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
113		-j .dynamic -j .dynsym -j .rel.dyn \
114		-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
115		-j set_Xficl_compile_set \
116		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
117
118LIBEFI=		${BOOTOBJ}/efi/libefi/libefi.a
119
120DPADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT}
121LDADD=		${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA}
122
123.include <bsd.prog.mk>
124