Makefile revision 296769
1264391Snwhitehorn# $FreeBSD: head/sys/boot/efi/boot1/Makefile 296769 2016-03-12 21:44:33Z emaste $ 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 87287930Sjhbboot1.efi: ${PROG} 88296769Semaste if ${NM} ${.ALLSRC} | grep ' U '; then \ 89296769Semaste echo "Undefined symbols in ${.ALLSRC}"; \ 90264391Snwhitehorn exit 1; \ 91264391Snwhitehorn fi 92281156Sandrew ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 93264391Snwhitehorn -j .dynamic -j .dynsym -j .rel.dyn \ 94287930Sjhb -j .rela.dyn -j .reloc -j .eh_frame \ 95276146Semaste --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 96264391Snwhitehorn 97264414Snwhitehornboot1.o: ${.CURDIR}/../../common/ufsread.c 98264414Snwhitehorn 99287930Sjhb# The following inserts our objects into a template FAT file system 100264975Snwhitehorn# created by generate-fat.sh 101264975Snwhitehorn 102264975Snwhitehorn.include "${.CURDIR}/Makefile.fat" 103293425SemasteBOOT1_MAXSIZE?= 131072 104264975Snwhitehorn 105264975Snwhitehornboot1.efifat: boot1.efi 106293425Semaste @set -- `ls -l boot1.efi`; \ 107293425Semaste x=$$(($$5-${BOOT1_MAXSIZE})); \ 108293425Semaste if [ $$x -ge 0 ]; then \ 109293425Semaste echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 110293425Semaste exit 1; \ 111293425Semaste fi 112264975Snwhitehorn echo ${.OBJDIR} 113281524Sandrew uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu 114281524Sandrew mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 115264975Snwhitehorn bzip2 -f -d ${.TARGET}.bz2 116295757Semaste dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc \ 117295757Semaste status=none 118264975Snwhitehorn 119281117SandrewCLEANFILES= boot1.efi boot1.efifat 120264975Snwhitehorn 121264391Snwhitehorn.include <bsd.prog.mk> 122264391Snwhitehorn 123281496Sandrewbeforedepend ${OBJS}: machine 124264391Snwhitehorn 125281496SandrewCLEANFILES+= machine 126264391Snwhitehorn 127296706Sbdrewerymachine: .NOMETA 128281496Sandrew ln -sf ${.CURDIR}/../../../${MACHINE}/include machine 129264391Snwhitehorn 130281496Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 131281496Sandrewbeforedepend ${OBJS}: x86 132281496SandrewCLEANFILES+= x86 133281496Sandrew 134296706Sbdreweryx86: .NOMETA 135264391Snwhitehorn ln -sf ${.CURDIR}/../../../x86/include x86 136281027Sandrew.endif 137