Makefile revision 319024
1264391Snwhitehorn# $FreeBSD: stable/11/sys/boot/efi/boot1/Makefile 319024 2017-05-28 01:08:46Z ngie $ 2264391Snwhitehorn 3264925SimpMAN= 4264391Snwhitehorn 5294060Ssmh.include <src.opts.mk> 6264391Snwhitehorn 7264391SnwhitehornMK_SSP= no 8264391Snwhitehorn 9287930SjhbPROG= boot1.sym 10264391SnwhitehornINTERNALPROG= 11293724SsmhWARNS?= 6 12264391Snwhitehorn 13294068Ssmh.if ${MK_ZFS} != "no" 14294068Ssmh# Disable warnings that are currently incompatible with the zfs boot code 15294068SsmhCWARNFLAGS.zfs_module.c += -Wno-array-bounds 16294068SsmhCWARNFLAGS.zfs_module.c += -Wno-cast-align 17294068SsmhCWARNFLAGS.zfs_module.c += -Wno-cast-qual 18294068SsmhCWARNFLAGS.zfs_module.c += -Wno-missing-prototypes 19294068SsmhCWARNFLAGS.zfs_module.c += -Wno-sign-compare 20294068SsmhCWARNFLAGS.zfs_module.c += -Wno-unused-parameter 21294068SsmhCWARNFLAGS.zfs_module.c += -Wno-unused-function 22294068Ssmh.endif 23294068Ssmh 24264391Snwhitehorn# architecture-specific loader code 25294060SsmhSRCS= boot1.c self_reloc.c start.S ufs_module.c 26294068Ssmh.if ${MK_ZFS} != "no" 27294068SsmhSRCS+= zfs_module.c 28294068Ssmh.endif 29264391Snwhitehorn 30264391SnwhitehornCFLAGS+= -I. 31280950SandrewCFLAGS+= -I${.CURDIR}/../include 32281524SandrewCFLAGS+= -I${.CURDIR}/../include/${MACHINE} 33264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include 34264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../.. 35294060SsmhCFLAGS+= -DEFI_UFS_BOOT 36294265Ssmh.ifdef(EFI_DEBUG) 37294265SsmhCFLAGS+= -DEFI_DEBUG 38294265Ssmh.endif 39264391Snwhitehorn 40294068Ssmh.if ${MK_ZFS} != "no" 41294068SsmhCFLAGS+= -I${.CURDIR}/../../zfs/ 42294068SsmhCFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs/ 43294068SsmhCFLAGS+= -DEFI_ZFS_BOOT 44294068Ssmh.endif 45294068Ssmh 46264403Snwhitehorn# Always add MI sources and REGULAR efi loader bits 47281524Sandrew.PATH: ${.CURDIR}/../loader/arch/${MACHINE} 48281237Semaste.PATH: ${.CURDIR}/../loader 49281237Semaste.PATH: ${.CURDIR}/../../common 50264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../common 51264391Snwhitehorn 52264975SnwhitehornFILES= boot1.efi boot1.efifat 53264391SnwhitehornFILESMODE_boot1.efi= ${BINMODE} 54264391Snwhitehorn 55281524SandrewLDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} 56296517SemasteLDFLAGS+= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared 57264391Snwhitehorn 58282474Sandrew.if ${MACHINE_CPUARCH} == "aarch64" 59282474SandrewCFLAGS+= -msoft-float -mgeneral-regs-only 60282474Sandrew.endif 61281027Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 62281300SandrewCFLAGS+= -fPIC 63281027SandrewLDFLAGS+= -Wl,-znocombreloc 64281027Sandrew.endif 65281027Sandrew 66281156Sandrew# 67281238Semaste# Add libstand for the runtime functions used by the compiler - for example 68281238Semaste# __aeabi_* (arm) or __divdi3 (i386). 69293460Ssmh# as well as required string and memory functions for all platforms. 70281156Sandrew# 71281156SandrewDPADD+= ${LIBSTAND} 72281156SandrewLDADD+= -lstand 73281156Sandrew 74287930SjhbDPADD+= ${LDSCRIPT} 75264391Snwhitehorn 76296769SemasteNM?= nm 77264391SnwhitehornOBJCOPY?= objcopy 78264391Snwhitehorn 79264391Snwhitehorn.if ${MACHINE_CPUARCH} == "amd64" 80264391SnwhitehornEFI_TARGET= efi-app-x86_64 81280950Sandrew.elif ${MACHINE_CPUARCH} == "i386" 82264391SnwhitehornEFI_TARGET= efi-app-ia32 83281156Sandrew.else 84281156SandrewEFI_TARGET= binary 85264391Snwhitehorn.endif 86264391Snwhitehorn 87305845Semaste# Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00 88305845Semaste# for build reproducibility. 89305845SemasteSOURCE_DATE_EPOCH?=1451606400 90287930Sjhbboot1.efi: ${PROG} 91296769Semaste if ${NM} ${.ALLSRC} | grep ' U '; then \ 92296769Semaste echo "Undefined symbols in ${.ALLSRC}"; \ 93264391Snwhitehorn exit 1; \ 94264391Snwhitehorn fi 95305845Semaste SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 96281156Sandrew ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 97264391Snwhitehorn -j .dynamic -j .dynsym -j .rel.dyn \ 98287930Sjhb -j .rela.dyn -j .reloc -j .eh_frame \ 99276146Semaste --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 100264391Snwhitehorn 101264414Snwhitehornboot1.o: ${.CURDIR}/../../common/ufsread.c 102264414Snwhitehorn 103287930Sjhb# The following inserts our objects into a template FAT file system 104264975Snwhitehorn# created by generate-fat.sh 105264975Snwhitehorn 106264975Snwhitehorn.include "${.CURDIR}/Makefile.fat" 107293425SemasteBOOT1_MAXSIZE?= 131072 108264975Snwhitehorn 109264975Snwhitehornboot1.efifat: boot1.efi 110319024Sngie @set -- `ls -l ${.ALLSRC}`; \ 111293425Semaste x=$$(($$5-${BOOT1_MAXSIZE})); \ 112293425Semaste if [ $$x -ge 0 ]; then \ 113293425Semaste echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 114293425Semaste exit 1; \ 115293425Semaste fi 116264975Snwhitehorn echo ${.OBJDIR} 117281524Sandrew uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu 118281524Sandrew mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 119264975Snwhitehorn bzip2 -f -d ${.TARGET}.bz2 120319024Sngie ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc 121264975Snwhitehorn 122281117SandrewCLEANFILES= boot1.efi boot1.efifat 123264975Snwhitehorn 124264391Snwhitehorn.include <bsd.prog.mk> 125264391Snwhitehorn 126281496Sandrewbeforedepend ${OBJS}: machine 127264391Snwhitehorn 128281496SandrewCLEANFILES+= machine 129264391Snwhitehorn 130296706Sbdrewerymachine: .NOMETA 131281496Sandrew ln -sf ${.CURDIR}/../../../${MACHINE}/include machine 132264391Snwhitehorn 133281496Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 134281496Sandrewbeforedepend ${OBJS}: x86 135281496SandrewCLEANFILES+= x86 136281496Sandrew 137296706Sbdreweryx86: .NOMETA 138264391Snwhitehorn ln -sf ${.CURDIR}/../../../x86/include x86 139281027Sandrew.endif 140