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