Makefile revision 323485
1264391Snwhitehorn# $FreeBSD: stable/11/sys/boot/efi/boot1/Makefile 323485 2017-09-12 06:21:43Z rlibby $ 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 30323485Srlibby.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 31323485SrlibbyCWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized 32323485Srlibby.endif 33323485Srlibby 34264391SnwhitehornCFLAGS+= -I. 35280950SandrewCFLAGS+= -I${.CURDIR}/../include 36281524SandrewCFLAGS+= -I${.CURDIR}/../include/${MACHINE} 37264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include 38264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../.. 39294060SsmhCFLAGS+= -DEFI_UFS_BOOT 40294265Ssmh.ifdef(EFI_DEBUG) 41294265SsmhCFLAGS+= -DEFI_DEBUG 42294265Ssmh.endif 43264391Snwhitehorn 44294068Ssmh.if ${MK_ZFS} != "no" 45294068SsmhCFLAGS+= -I${.CURDIR}/../../zfs/ 46294068SsmhCFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs/ 47294068SsmhCFLAGS+= -DEFI_ZFS_BOOT 48294068Ssmh.endif 49294068Ssmh 50264403Snwhitehorn# Always add MI sources and REGULAR efi loader bits 51281524Sandrew.PATH: ${.CURDIR}/../loader/arch/${MACHINE} 52281237Semaste.PATH: ${.CURDIR}/../loader 53281237Semaste.PATH: ${.CURDIR}/../../common 54264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../common 55264391Snwhitehorn 56264975SnwhitehornFILES= boot1.efi boot1.efifat 57264391SnwhitehornFILESMODE_boot1.efi= ${BINMODE} 58264391Snwhitehorn 59281524SandrewLDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} 60296517SemasteLDFLAGS+= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared 61264391Snwhitehorn 62282474Sandrew.if ${MACHINE_CPUARCH} == "aarch64" 63282474SandrewCFLAGS+= -msoft-float -mgeneral-regs-only 64282474Sandrew.endif 65281027Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 66281300SandrewCFLAGS+= -fPIC 67281027SandrewLDFLAGS+= -Wl,-znocombreloc 68281027Sandrew.endif 69281027Sandrew 70281156Sandrew# 71281238Semaste# Add libstand for the runtime functions used by the compiler - for example 72281238Semaste# __aeabi_* (arm) or __divdi3 (i386). 73293460Ssmh# as well as required string and memory functions for all platforms. 74281156Sandrew# 75281156SandrewDPADD+= ${LIBSTAND} 76281156SandrewLDADD+= -lstand 77281156Sandrew 78287930SjhbDPADD+= ${LDSCRIPT} 79264391Snwhitehorn 80296769SemasteNM?= nm 81264391SnwhitehornOBJCOPY?= objcopy 82264391Snwhitehorn 83264391Snwhitehorn.if ${MACHINE_CPUARCH} == "amd64" 84264391SnwhitehornEFI_TARGET= efi-app-x86_64 85280950Sandrew.elif ${MACHINE_CPUARCH} == "i386" 86264391SnwhitehornEFI_TARGET= efi-app-ia32 87281156Sandrew.else 88281156SandrewEFI_TARGET= binary 89264391Snwhitehorn.endif 90264391Snwhitehorn 91305845Semaste# Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00 92305845Semaste# for build reproducibility. 93305845SemasteSOURCE_DATE_EPOCH?=1451606400 94287930Sjhbboot1.efi: ${PROG} 95296769Semaste if ${NM} ${.ALLSRC} | grep ' U '; then \ 96296769Semaste echo "Undefined symbols in ${.ALLSRC}"; \ 97264391Snwhitehorn exit 1; \ 98264391Snwhitehorn fi 99305845Semaste SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 100281156Sandrew ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 101264391Snwhitehorn -j .dynamic -j .dynsym -j .rel.dyn \ 102287930Sjhb -j .rela.dyn -j .reloc -j .eh_frame \ 103276146Semaste --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 104264391Snwhitehorn 105264414Snwhitehornboot1.o: ${.CURDIR}/../../common/ufsread.c 106264414Snwhitehorn 107287930Sjhb# The following inserts our objects into a template FAT file system 108264975Snwhitehorn# created by generate-fat.sh 109264975Snwhitehorn 110264975Snwhitehorn.include "${.CURDIR}/Makefile.fat" 111293425SemasteBOOT1_MAXSIZE?= 131072 112264975Snwhitehorn 113264975Snwhitehornboot1.efifat: boot1.efi 114319024Sngie @set -- `ls -l ${.ALLSRC}`; \ 115293425Semaste x=$$(($$5-${BOOT1_MAXSIZE})); \ 116293425Semaste if [ $$x -ge 0 ]; then \ 117293425Semaste echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 118293425Semaste exit 1; \ 119293425Semaste fi 120264975Snwhitehorn echo ${.OBJDIR} 121281524Sandrew uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu 122281524Sandrew mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 123264975Snwhitehorn bzip2 -f -d ${.TARGET}.bz2 124319024Sngie ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc 125264975Snwhitehorn 126281117SandrewCLEANFILES= boot1.efi boot1.efifat 127264975Snwhitehorn 128264391Snwhitehorn.include <bsd.prog.mk> 129264391Snwhitehorn 130281496Sandrewbeforedepend ${OBJS}: machine 131264391Snwhitehorn 132281496SandrewCLEANFILES+= machine 133264391Snwhitehorn 134296706Sbdrewerymachine: .NOMETA 135281496Sandrew ln -sf ${.CURDIR}/../../../${MACHINE}/include machine 136264391Snwhitehorn 137281496Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 138281496Sandrewbeforedepend ${OBJS}: x86 139281496SandrewCLEANFILES+= x86 140281496Sandrew 141296706Sbdreweryx86: .NOMETA 142264391Snwhitehorn ln -sf ${.CURDIR}/../../../x86/include x86 143281027Sandrew.endif 144