Makefile revision 329129
134192Sjdp# $FreeBSD: stable/11/sys/boot/efi/boot1/Makefile 329129 2018-02-11 19:29:58Z kevans $
255687Sjdp
334192SjdpMAN=
434192Sjdp
534192Sjdp.include <src.opts.mk>
634192Sjdp
734192SjdpMK_SSP=		no
834192Sjdp
934192SjdpPROG=		boot1.sym
1034192SjdpINTERNALPROG=
1134192SjdpWARNS?=		6
1234192Sjdp
1334192Sjdp# We implement a slightly non-standard %S in that it always takes a
1434192Sjdp# CHAR16 that's common in UEFI-land instead of a wchar_t. This only
1534192Sjdp# seems to matter on arm64 where wchar_t defaults to an int instead
1634192Sjdp# of a short. There's no good cast to use here so just ignore the
1734192Sjdp# warnings for now.
1834192SjdpCWARNFLAGS.boot1.c+=	-Wno-format
1934192Sjdp
2034192Sjdp# Disable warnings that are currently incompatible with the zfs boot code
2134192SjdpCWARNFLAGS.zfs_module.c += -Wno-array-bounds
2234192SjdpCWARNFLAGS.zfs_module.c += -Wno-cast-align
2334192SjdpCWARNFLAGS.zfs_module.c += -Wno-cast-qual
2434192SjdpCWARNFLAGS.zfs_module.c += -Wno-missing-prototypes
2550476SpeterCWARNFLAGS.zfs_module.c += -Wno-sign-compare
2634192SjdpCWARNFLAGS.zfs_module.c += -Wno-unused-parameter
2734192SjdpCWARNFLAGS.zfs_module.c += -Wno-unused-function
2834192SjdpCWARNFLAGS.skein.c += -Wno-cast-align
2934192Sjdp.if ${COMPILER_TYPE} == "clang"
3034192SjdpCWARNFLAGS.skein.c += -Wno-missing-variable-declarations
3176224Sobrien.else if ${COMPILER_TYPE} == "gcc"
3234192SjdpCWARNFLAGS.skein.c += -Wno-missing-declarations
3350608Sjdp.endif
3434192Sjdp
3576224Sobrien# architecture-specific loader code
3635529SdfrSRCS=	boot1.c self_reloc.c start.S ufs_module.c
3734192Sjdp.if ${MK_ZFS} != "no"
3834192SjdpSRCS+=		zfs_module.c
39115396SkanSRCS+=		skein.c skein_block.c
4045501Sjdp# Do not unroll skein loops, reduce code size
4145501SjdpCFLAGS+=	-DSKEIN_LOOP=111
4234192Sjdp.PATH:		${.CURDIR}/../../../crypto/skein
43119013Sgordon.endif
4434192Sjdp
4534192Sjdp.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201
4634192SjdpCWARNFLAGS.self_reloc.c+=	-Wno-error=maybe-uninitialized
4734192Sjdp.endif
4834192Sjdp
4934192SjdpCFLAGS+=	-I.
5034192SjdpCFLAGS+=	-I${.CURDIR}/../include
5134192SjdpCFLAGS+=	-I${.CURDIR}/../include/${MACHINE}
5234192SjdpCFLAGS+=	-I${.CURDIR}/../../../contrib/dev/acpica/include
5334192SjdpCFLAGS+=	-I${.CURDIR}/../../..
5450609SjdpCFLAGS+=	-DEFI_UFS_BOOT
5534192Sjdp.ifdef(EFI_DEBUG)
5634192SjdpCFLAGS+=	-DEFI_DEBUG
5755687Sjdp.endif
5850608Sjdp
5960938Sjake.if ${MK_ZFS} != "no"
6050608SjdpCFLAGS+=	-I${.CURDIR}/../../zfs/
6150608SjdpCFLAGS+=	-I${.CURDIR}/../../../cddl/boot/zfs/
6250608SjdpCFLAGS+=	-I${.CURDIR}/../../../crypto/skein
6360938SjakeCFLAGS+=	-DEFI_ZFS_BOOT
6450608Sjdp.endif
6563870Sjdp
6655687Sjdp# Always add MI sources and REGULAR efi loader bits
6755687Sjdp.PATH:		${.CURDIR}/../loader/arch/${MACHINE}
6855687Sjdp.PATH:		${.CURDIR}/../loader
6934192Sjdp.PATH:		${.CURDIR}/../../common
7034192SjdpCFLAGS+=	-I${.CURDIR}/../../common
7134192Sjdp
7234192SjdpFILES=	boot1.efi boot1.efifat
7334192SjdpFILESMODE_boot1.efi=	${BINMODE}
7434192Sjdp
7562801SjdpLDSCRIPT=	${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
7662801SjdpLDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
7762801Sjdp
7862801Sjdp.if ${MACHINE_CPUARCH} == "aarch64"
7962801SjdpCFLAGS+=	-mgeneral-regs-only
8062801Sjdp.endif
8162801Sjdp.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
8262801SjdpCFLAGS+=	-fPIC
8362801SjdpLDFLAGS+=	-Wl,-znocombreloc
8462801Sjdp.endif
8562801Sjdp
8662801SjdpLIBEFI=		${.OBJDIR}/../libefi/libefi.a
8762801Sjdp
8862801Sjdp#
8962801Sjdp# Add libstand for the runtime functions used by the compiler - for example
9062801Sjdp# __aeabi_* (arm) or __divdi3 (i386).
9162801Sjdp# as well as required string and memory functions for all platforms.
9234192Sjdp#
9334192SjdpDPADD+=		${LIBEFI} ${LIBSA}
9434192SjdpLDADD+=		${LIBEFI} ${LIBSA}
9534192Sjdp
9634192SjdpDPADD+=		${LDSCRIPT}
9750977Sjdp
9850977SjdpNM?=		nm
9950977SjdpOBJCOPY?=	objcopy
10050977Sjdp
10134192Sjdp.if ${MACHINE_CPUARCH} == "amd64"
10234192SjdpEFI_TARGET=	efi-app-x86_64
10334192Sjdp.elif ${MACHINE_CPUARCH} == "i386"
10434192SjdpEFI_TARGET=	efi-app-ia32
10534192Sjdp.else
10634192SjdpEFI_TARGET=	binary
10738467Sjb.endif
10838467Sjb
10934192Sjdp# Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00
11034192Sjdp# for build reproducibility.
11134192SjdpSOURCE_DATE_EPOCH?=1451606400
112116511Smdoddboot1.efi: ${PROG}
11334192Sjdp	if ${NM} ${.ALLSRC} | grep ' U '; then \
11434192Sjdp		echo "Undefined symbols in ${.ALLSRC}"; \
11534192Sjdp		exit 1; \
11634192Sjdp	fi
11734192Sjdp	SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
11834192Sjdp	${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
11934192Sjdp		-j .dynamic -j .dynsym -j .rel.dyn \
12038467Sjb		-j .rela.dyn -j .reloc -j .eh_frame \
12134192Sjdp		--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
12238467Sjb
12334192Sjdpboot1.o: ${.CURDIR}/../../common/ufsread.c
12438467Sjb
12534192Sjdp# The following inserts our objects into a template FAT file system
12650610Sjdp# created by generate-fat.sh
12734192Sjdp
12834192Sjdp.include "${.CURDIR}/Makefile.fat"
12945501Sjdp
13038467Sjbboot1.efifat: boot1.efi
13134192Sjdp	@set -- `ls -l ${.ALLSRC}`; \
13238816Sdfr	x=$$(($$5-${BOOT1_MAXSIZE})); \
13338816Sdfr	if [ $$x -ge 0 ]; then \
13438467Sjb	    echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\
13534192Sjdp	    exit 1; \
13638816Sdfr	fi
13738816Sdfr	echo ${.OBJDIR}
13838467Sjb	xz -d -c ${.CURDIR}/fat-${MACHINE}.tmpl.xz > ${.TARGET}
13934192Sjdp	${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc
14034192Sjdp
14134192SjdpCLEANFILES= boot1.efi boot1.efifat
14285004Sdfr
14334192Sjdp.include <bsd.prog.mk>
14485004Sdfr
14534192Sjdpbeforedepend ${OBJS}: machine
14634192Sjdp
14734192SjdpCLEANFILES+=   machine
14834192Sjdp
14934192Sjdpmachine: .NOMETA
15085677Speter	ln -sf ${.CURDIR}/../../../${MACHINE}/include machine
15185677Speter
15234192Sjdp.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
15334192Sjdpbeforedepend ${OBJS}: x86
15434192SjdpCLEANFILES+=   x86
15534192Sjdp
15634192Sjdpx86: .NOMETA
157116511Smdodd	ln -sf ${.CURDIR}/../../../x86/include x86
15838740Sjdp.endif
15956780Sjdp