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