Makefile revision 344377
1# $FreeBSD: stable/11/stand/efi/boot1/Makefile 344377 2019-02-20 19:13:09Z kevans $
2
3.include <bsd.init.mk>
4
5PROG=		boot1.sym
6INTERNALPROG=
7WARNS?=		6
8
9# We implement a slightly non-standard %S in that it always takes a
10# CHAR16 that's common in UEFI-land instead of a wchar_t. This only
11# seems to matter on arm64 where wchar_t defaults to an int instead
12# of a short. There's no good cast to use here so just ignore the
13# warnings for now.
14CWARNFLAGS.boot1.c+=	-Wno-format
15
16# Disable warnings that are currently incompatible with the zfs boot code
17CWARNFLAGS.zfs_module.c += -Wno-array-bounds
18CWARNFLAGS.zfs_module.c += -Wno-cast-align
19CWARNFLAGS.zfs_module.c += -Wno-cast-qual
20CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes
21CWARNFLAGS.zfs_module.c += -Wno-sign-compare
22CWARNFLAGS.zfs_module.c += -Wno-unused-parameter
23CWARNFLAGS.zfs_module.c += -Wno-unused-function
24
25# architecture-specific loader code
26SRCS=	boot1.c self_reloc.c start.S ufs_module.c
27.if ${MK_ZFS} != "no"
28SRCS+=		zfs_module.c
29CFLAGS.zfs_module.c+=	-I${ZFSSRC}
30CFLAGS.zfs_module.c+=	-I${SYSDIR}/cddl/boot/zfs
31CFLAGS.zfs_module.c+=	-I${SYSDIR}/crypto/skein
32CFLAGS+=	-DEFI_ZFS_BOOT
33.endif
34
35.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
36CWARNFLAGS.self_reloc.c+=	-Wno-error=maybe-uninitialized
37.endif
38
39CFLAGS+=	-I${EFIINC}
40CFLAGS+=	-I${EFIINCMD}
41CFLAGS+=	-I${SYSDIR}/contrib/dev/acpica/include
42CFLAGS+=	-DEFI_UFS_BOOT
43.ifdef(EFI_DEBUG)
44CFLAGS+=	-DEFI_DEBUG
45.endif
46
47# Always add MI sources and REGULAR efi loader bits
48.PATH:		${EFISRC}/loader/arch/${MACHINE}
49.PATH:		${EFISRC}/loader
50.PATH:		${LDRSRC}
51CFLAGS+=	-I${LDRSRC}
52
53FILES=	boot1.efi boot1.efifat
54FILESMODE_boot1.efi=	${BINMODE}
55
56LDSCRIPT=	${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE}
57LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
58
59.if ${MACHINE_CPUARCH} == "aarch64"
60CFLAGS+=	-mgeneral-regs-only
61.endif
62.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
63CFLAGS+=	-fPIC
64LDFLAGS+=	-Wl,-znocombreloc
65.endif
66
67LIBEFI=		${BOOTOBJ}/efi/libefi/libefi.a
68
69#
70# Add libstand for the runtime functions used by the compiler - for example
71# __aeabi_* (arm) or __divdi3 (i386).
72# as well as required string and memory functions for all platforms.
73#
74DPADD+=		${LIBEFI} ${LIBSA}
75LDADD+=		${LIBEFI} ${LIBSA}
76
77DPADD+=		${LDSCRIPT}
78
79NM?=		nm
80OBJCOPY?=	objcopy
81
82.if ${MACHINE_CPUARCH} == "amd64"
83EFI_TARGET=	efi-app-x86_64
84.elif ${MACHINE_CPUARCH} == "i386"
85EFI_TARGET=	efi-app-ia32
86.else
87EFI_TARGET=	binary
88.endif
89
90# Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00
91# for build reproducibility.
92SOURCE_DATE_EPOCH?=1451606400
93boot1.efi: ${PROG}
94	if ${NM} ${.ALLSRC} | grep ' U '; then \
95		echo "Undefined symbols in ${.ALLSRC}"; \
96		exit 1; \
97	fi
98	SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
99	${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
100		-j .dynamic -j .dynsym -j .rel.dyn \
101		-j .rela.dyn -j .reloc -j .eh_frame \
102		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
103
104# The following inserts our objects into a template FAT file system
105# created by generate-fat.sh
106
107.include "Makefile.fat"
108
109boot1.efifat: boot1.efi
110	@set -- `ls -l ${.ALLSRC}`; \
111	x=$$(($$5-${BOOT1_MAXSIZE})); \
112	if [ $$x -ge 0 ]; then \
113	    echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\
114	    exit 1; \
115	fi
116	echo ${.OBJDIR}
117	xz -d -c ${BOOTSRC}/efi/boot1/fat-${MACHINE}.tmpl.xz > ${.TARGET}
118	${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
119
120CLEANFILES+= boot1.efi boot1.efifat
121
122.include <bsd.prog.mk>
123