Makefile revision 305845
1# $FreeBSD: stable/11/sys/boot/efi/boot1/Makefile 305845 2016-09-15 17:30:01Z emaste $ 2 3MAN= 4 5.include <src.opts.mk> 6 7MK_SSP= no 8 9PROG= boot1.sym 10INTERNALPROG= 11WARNS?= 6 12 13.if ${MK_ZFS} != "no" 14# Disable warnings that are currently incompatible with the zfs boot code 15CWARNFLAGS.zfs_module.c += -Wno-array-bounds 16CWARNFLAGS.zfs_module.c += -Wno-cast-align 17CWARNFLAGS.zfs_module.c += -Wno-cast-qual 18CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes 19CWARNFLAGS.zfs_module.c += -Wno-sign-compare 20CWARNFLAGS.zfs_module.c += -Wno-unused-parameter 21CWARNFLAGS.zfs_module.c += -Wno-unused-function 22.endif 23 24# architecture-specific loader code 25SRCS= boot1.c self_reloc.c start.S ufs_module.c 26.if ${MK_ZFS} != "no" 27SRCS+= zfs_module.c 28.endif 29 30CFLAGS+= -I. 31CFLAGS+= -I${.CURDIR}/../include 32CFLAGS+= -I${.CURDIR}/../include/${MACHINE} 33CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include 34CFLAGS+= -I${.CURDIR}/../../.. 35CFLAGS+= -DEFI_UFS_BOOT 36.ifdef(EFI_DEBUG) 37CFLAGS+= -DEFI_DEBUG 38.endif 39 40.if ${MK_ZFS} != "no" 41CFLAGS+= -I${.CURDIR}/../../zfs/ 42CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs/ 43CFLAGS+= -DEFI_ZFS_BOOT 44.endif 45 46# Always add MI sources and REGULAR efi loader bits 47.PATH: ${.CURDIR}/../loader/arch/${MACHINE} 48.PATH: ${.CURDIR}/../loader 49.PATH: ${.CURDIR}/../../common 50CFLAGS+= -I${.CURDIR}/../../common 51 52FILES= boot1.efi boot1.efifat 53FILESMODE_boot1.efi= ${BINMODE} 54 55LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} 56LDFLAGS+= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared 57 58.if ${MACHINE_CPUARCH} == "aarch64" 59CFLAGS+= -msoft-float -mgeneral-regs-only 60.endif 61.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 62CFLAGS+= -fPIC 63LDFLAGS+= -Wl,-znocombreloc 64.endif 65 66# 67# Add libstand for the runtime functions used by the compiler - for example 68# __aeabi_* (arm) or __divdi3 (i386). 69# as well as required string and memory functions for all platforms. 70# 71DPADD+= ${LIBSTAND} 72LDADD+= -lstand 73 74DPADD+= ${LDSCRIPT} 75 76NM?= nm 77OBJCOPY?= objcopy 78 79.if ${MACHINE_CPUARCH} == "amd64" 80EFI_TARGET= efi-app-x86_64 81.elif ${MACHINE_CPUARCH} == "i386" 82EFI_TARGET= efi-app-ia32 83.else 84EFI_TARGET= binary 85.endif 86 87# Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00 88# for build reproducibility. 89SOURCE_DATE_EPOCH?=1451606400 90boot1.efi: ${PROG} 91 if ${NM} ${.ALLSRC} | grep ' U '; then \ 92 echo "Undefined symbols in ${.ALLSRC}"; \ 93 exit 1; \ 94 fi 95 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 96 ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 97 -j .dynamic -j .dynsym -j .rel.dyn \ 98 -j .rela.dyn -j .reloc -j .eh_frame \ 99 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 100 101boot1.o: ${.CURDIR}/../../common/ufsread.c 102 103# The following inserts our objects into a template FAT file system 104# created by generate-fat.sh 105 106.include "${.CURDIR}/Makefile.fat" 107BOOT1_MAXSIZE?= 131072 108 109boot1.efifat: boot1.efi 110 @set -- `ls -l boot1.efi`; \ 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 uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu 118 mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 119 bzip2 -f -d ${.TARGET}.bz2 120 dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc \ 121 status=none 122 123CLEANFILES= boot1.efi boot1.efifat 124 125.include <bsd.prog.mk> 126 127beforedepend ${OBJS}: machine 128 129CLEANFILES+= machine 130 131machine: .NOMETA 132 ln -sf ${.CURDIR}/../../../${MACHINE}/include machine 133 134.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 135beforedepend ${OBJS}: x86 136CLEANFILES+= x86 137 138x86: .NOMETA 139 ln -sf ${.CURDIR}/../../../x86/include x86 140.endif 141