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