Makefile revision 294068
1264391Snwhitehorn# $FreeBSD: head/sys/boot/efi/boot1/Makefile 294068 2016-01-15 02:33:47Z smh $ 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 36264391Snwhitehorn 37294068Ssmh.if ${MK_ZFS} != "no" 38294068SsmhCFLAGS+= -I${.CURDIR}/../../zfs/ 39294068SsmhCFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs/ 40294068SsmhCFLAGS+= -DEFI_ZFS_BOOT 41294068Ssmh.endif 42294068Ssmh 43264403Snwhitehorn# Always add MI sources and REGULAR efi loader bits 44281524Sandrew.PATH: ${.CURDIR}/../loader/arch/${MACHINE} 45281237Semaste.PATH: ${.CURDIR}/../loader 46281237Semaste.PATH: ${.CURDIR}/../../common 47264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../common 48264391Snwhitehorn 49264975SnwhitehornFILES= boot1.efi boot1.efifat 50264391SnwhitehornFILESMODE_boot1.efi= ${BINMODE} 51264391Snwhitehorn 52281524SandrewLDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} 53281027SandrewLDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared 54264391Snwhitehorn 55282474Sandrew.if ${MACHINE_CPUARCH} == "aarch64" 56282474SandrewCFLAGS+= -msoft-float -mgeneral-regs-only 57282474Sandrew.endif 58281027Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 59281300SandrewCFLAGS+= -fPIC 60281027SandrewLDFLAGS+= -Wl,-znocombreloc 61281027Sandrew.endif 62281027Sandrew 63281156Sandrew# 64281238Semaste# Add libstand for the runtime functions used by the compiler - for example 65281238Semaste# __aeabi_* (arm) or __divdi3 (i386). 66293460Ssmh# as well as required string and memory functions for all platforms. 67281156Sandrew# 68281156SandrewDPADD+= ${LIBSTAND} 69281156SandrewLDADD+= -lstand 70281156Sandrew 71287930SjhbDPADD+= ${LDSCRIPT} 72264391Snwhitehorn 73264391SnwhitehornOBJCOPY?= objcopy 74264391SnwhitehornOBJDUMP?= objdump 75264391Snwhitehorn 76264391Snwhitehorn.if ${MACHINE_CPUARCH} == "amd64" 77264391SnwhitehornEFI_TARGET= efi-app-x86_64 78280950Sandrew.elif ${MACHINE_CPUARCH} == "i386" 79264391SnwhitehornEFI_TARGET= efi-app-ia32 80281156Sandrew.else 81281156SandrewEFI_TARGET= binary 82264391Snwhitehorn.endif 83264391Snwhitehorn 84287930Sjhbboot1.efi: ${PROG} 85264391Snwhitehorn if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \ 86264391Snwhitehorn ${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \ 87264391Snwhitehorn exit 1; \ 88264391Snwhitehorn fi 89281156Sandrew ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 90264391Snwhitehorn -j .dynamic -j .dynsym -j .rel.dyn \ 91287930Sjhb -j .rela.dyn -j .reloc -j .eh_frame \ 92276146Semaste --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 93264391Snwhitehorn 94264414Snwhitehornboot1.o: ${.CURDIR}/../../common/ufsread.c 95264414Snwhitehorn 96287930Sjhb# The following inserts our objects into a template FAT file system 97264975Snwhitehorn# created by generate-fat.sh 98264975Snwhitehorn 99264975Snwhitehorn.include "${.CURDIR}/Makefile.fat" 100293425SemasteBOOT1_MAXSIZE?= 131072 101264975Snwhitehorn 102264975Snwhitehornboot1.efifat: boot1.efi 103293425Semaste @set -- `ls -l boot1.efi`; \ 104293425Semaste x=$$(($$5-${BOOT1_MAXSIZE})); \ 105293425Semaste if [ $$x -ge 0 ]; then \ 106293425Semaste echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 107293425Semaste exit 1; \ 108293425Semaste fi 109264975Snwhitehorn echo ${.OBJDIR} 110281524Sandrew uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu 111281524Sandrew mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 112264975Snwhitehorn bzip2 -f -d ${.TARGET}.bz2 113264975Snwhitehorn dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc 114264975Snwhitehorn 115281117SandrewCLEANFILES= boot1.efi boot1.efifat 116264975Snwhitehorn 117264391Snwhitehorn.include <bsd.prog.mk> 118264391Snwhitehorn 119281496Sandrewbeforedepend ${OBJS}: machine 120264391Snwhitehorn 121281496SandrewCLEANFILES+= machine 122264391Snwhitehorn 123264391Snwhitehornmachine: 124281496Sandrew ln -sf ${.CURDIR}/../../../${MACHINE}/include machine 125264391Snwhitehorn 126281496Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 127281496Sandrewbeforedepend ${OBJS}: x86 128281496SandrewCLEANFILES+= x86 129281496Sandrew 130264391Snwhitehornx86: 131264391Snwhitehorn ln -sf ${.CURDIR}/../../../x86/include x86 132281027Sandrew.endif 133