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