Makefile revision 294060
1264391Snwhitehorn# $FreeBSD: head/sys/boot/efi/boot1/Makefile 294060 2016-01-15 01:22:36Z smh $ 2264391Snwhitehorn 3264925SimpMAN= 4264391Snwhitehorn 5294060Ssmh.include <src.opts.mk> 6264391Snwhitehorn 7264391SnwhitehornMK_SSP= no 8264391Snwhitehorn 9287930SjhbPROG= boot1.sym 10264391SnwhitehornINTERNALPROG= 11293724SsmhWARNS?= 6 12264391Snwhitehorn 13264391Snwhitehorn# architecture-specific loader code 14294060SsmhSRCS= boot1.c self_reloc.c start.S ufs_module.c 15264391Snwhitehorn 16264391SnwhitehornCFLAGS+= -I. 17280950SandrewCFLAGS+= -I${.CURDIR}/../include 18281524SandrewCFLAGS+= -I${.CURDIR}/../include/${MACHINE} 19264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include 20264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../.. 21294060SsmhCFLAGS+= -DEFI_UFS_BOOT 22264391Snwhitehorn 23264403Snwhitehorn# Always add MI sources and REGULAR efi loader bits 24281524Sandrew.PATH: ${.CURDIR}/../loader/arch/${MACHINE} 25281237Semaste.PATH: ${.CURDIR}/../loader 26281237Semaste.PATH: ${.CURDIR}/../../common 27264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../common 28264391Snwhitehorn 29264975SnwhitehornFILES= boot1.efi boot1.efifat 30264391SnwhitehornFILESMODE_boot1.efi= ${BINMODE} 31264391Snwhitehorn 32281524SandrewLDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} 33281027SandrewLDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared 34264391Snwhitehorn 35282474Sandrew.if ${MACHINE_CPUARCH} == "aarch64" 36282474SandrewCFLAGS+= -msoft-float -mgeneral-regs-only 37282474Sandrew.endif 38281027Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 39281300SandrewCFLAGS+= -fPIC 40281027SandrewLDFLAGS+= -Wl,-znocombreloc 41281027Sandrew.endif 42281027Sandrew 43281156Sandrew# 44281238Semaste# Add libstand for the runtime functions used by the compiler - for example 45281238Semaste# __aeabi_* (arm) or __divdi3 (i386). 46293460Ssmh# as well as required string and memory functions for all platforms. 47281156Sandrew# 48281156SandrewDPADD+= ${LIBSTAND} 49281156SandrewLDADD+= -lstand 50281156Sandrew 51287930SjhbDPADD+= ${LDSCRIPT} 52264391Snwhitehorn 53264391SnwhitehornOBJCOPY?= objcopy 54264391SnwhitehornOBJDUMP?= objdump 55264391Snwhitehorn 56264391Snwhitehorn.if ${MACHINE_CPUARCH} == "amd64" 57264391SnwhitehornEFI_TARGET= efi-app-x86_64 58280950Sandrew.elif ${MACHINE_CPUARCH} == "i386" 59264391SnwhitehornEFI_TARGET= efi-app-ia32 60281156Sandrew.else 61281156SandrewEFI_TARGET= binary 62264391Snwhitehorn.endif 63264391Snwhitehorn 64287930Sjhbboot1.efi: ${PROG} 65264391Snwhitehorn if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \ 66264391Snwhitehorn ${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \ 67264391Snwhitehorn exit 1; \ 68264391Snwhitehorn fi 69281156Sandrew ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 70264391Snwhitehorn -j .dynamic -j .dynsym -j .rel.dyn \ 71287930Sjhb -j .rela.dyn -j .reloc -j .eh_frame \ 72276146Semaste --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 73264391Snwhitehorn 74264414Snwhitehornboot1.o: ${.CURDIR}/../../common/ufsread.c 75264414Snwhitehorn 76287930Sjhb# The following inserts our objects into a template FAT file system 77264975Snwhitehorn# created by generate-fat.sh 78264975Snwhitehorn 79264975Snwhitehorn.include "${.CURDIR}/Makefile.fat" 80293425SemasteBOOT1_MAXSIZE?= 131072 81264975Snwhitehorn 82264975Snwhitehornboot1.efifat: boot1.efi 83293425Semaste @set -- `ls -l boot1.efi`; \ 84293425Semaste x=$$(($$5-${BOOT1_MAXSIZE})); \ 85293425Semaste if [ $$x -ge 0 ]; then \ 86293425Semaste echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 87293425Semaste exit 1; \ 88293425Semaste fi 89264975Snwhitehorn echo ${.OBJDIR} 90281524Sandrew uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu 91281524Sandrew mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 92264975Snwhitehorn bzip2 -f -d ${.TARGET}.bz2 93264975Snwhitehorn dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc 94264975Snwhitehorn 95281117SandrewCLEANFILES= boot1.efi boot1.efifat 96264975Snwhitehorn 97264391Snwhitehorn.include <bsd.prog.mk> 98264391Snwhitehorn 99281496Sandrewbeforedepend ${OBJS}: machine 100264391Snwhitehorn 101281496SandrewCLEANFILES+= machine 102264391Snwhitehorn 103264391Snwhitehornmachine: 104281496Sandrew ln -sf ${.CURDIR}/../../../${MACHINE}/include machine 105264391Snwhitehorn 106281496Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 107281496Sandrewbeforedepend ${OBJS}: x86 108281496SandrewCLEANFILES+= x86 109281496Sandrew 110264391Snwhitehornx86: 111264391Snwhitehorn ln -sf ${.CURDIR}/../../../x86/include x86 112281027Sandrew.endif 113