Makefile revision 293724
1264391Snwhitehorn# $FreeBSD: head/sys/boot/efi/boot1/Makefile 293724 2016-01-12 02:17:39Z smh $ 2264391Snwhitehorn 3264925SimpMAN= 4264391Snwhitehorn 5264391Snwhitehorn.include <bsd.own.mk> 6264391Snwhitehorn 7264391Snwhitehorn# In-tree GCC does not support __attribute__((ms_abi)). 8264391Snwhitehorn.if ${COMPILER_TYPE} != "gcc" 9264391Snwhitehorn 10264391SnwhitehornMK_SSP= no 11264391Snwhitehorn 12287930SjhbPROG= boot1.sym 13264391SnwhitehornINTERNALPROG= 14293724SsmhWARNS?= 6 15264391Snwhitehorn 16264391Snwhitehorn# architecture-specific loader code 17282727SianSRCS= boot1.c self_reloc.c start.S 18264391Snwhitehorn 19264391SnwhitehornCFLAGS+= -I. 20280950SandrewCFLAGS+= -I${.CURDIR}/../include 21281524SandrewCFLAGS+= -I${.CURDIR}/../include/${MACHINE} 22264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include 23264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../.. 24264391Snwhitehorn 25264403Snwhitehorn# Always add MI sources and REGULAR efi loader bits 26281524Sandrew.PATH: ${.CURDIR}/../loader/arch/${MACHINE} 27281237Semaste.PATH: ${.CURDIR}/../loader 28281237Semaste.PATH: ${.CURDIR}/../../common 29264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../common 30264391Snwhitehorn 31264975SnwhitehornFILES= boot1.efi boot1.efifat 32264391SnwhitehornFILESMODE_boot1.efi= ${BINMODE} 33264391Snwhitehorn 34281524SandrewLDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} 35281027SandrewLDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared 36264391Snwhitehorn 37282474Sandrew.if ${MACHINE_CPUARCH} == "aarch64" 38282474SandrewCFLAGS+= -msoft-float -mgeneral-regs-only 39282474Sandrew.endif 40281027Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 41281300SandrewCFLAGS+= -fPIC 42281027SandrewLDFLAGS+= -Wl,-znocombreloc 43281027Sandrew.endif 44281027Sandrew 45281156Sandrew# 46281238Semaste# Add libstand for the runtime functions used by the compiler - for example 47281238Semaste# __aeabi_* (arm) or __divdi3 (i386). 48293460Ssmh# as well as required string and memory functions for all platforms. 49281156Sandrew# 50281156SandrewDPADD+= ${LIBSTAND} 51281156SandrewLDADD+= -lstand 52281156Sandrew 53287930SjhbDPADD+= ${LDSCRIPT} 54264391Snwhitehorn 55264391SnwhitehornOBJCOPY?= objcopy 56264391SnwhitehornOBJDUMP?= objdump 57264391Snwhitehorn 58264391Snwhitehorn.if ${MACHINE_CPUARCH} == "amd64" 59264391SnwhitehornEFI_TARGET= efi-app-x86_64 60280950Sandrew.elif ${MACHINE_CPUARCH} == "i386" 61264391SnwhitehornEFI_TARGET= efi-app-ia32 62281156Sandrew.else 63281156SandrewEFI_TARGET= binary 64264391Snwhitehorn.endif 65264391Snwhitehorn 66287930Sjhbboot1.efi: ${PROG} 67264391Snwhitehorn if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \ 68264391Snwhitehorn ${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \ 69264391Snwhitehorn exit 1; \ 70264391Snwhitehorn fi 71281156Sandrew ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 72264391Snwhitehorn -j .dynamic -j .dynsym -j .rel.dyn \ 73287930Sjhb -j .rela.dyn -j .reloc -j .eh_frame \ 74276146Semaste --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 75264391Snwhitehorn 76264414Snwhitehornboot1.o: ${.CURDIR}/../../common/ufsread.c 77264414Snwhitehorn 78287930Sjhb# The following inserts our objects into a template FAT file system 79264975Snwhitehorn# created by generate-fat.sh 80264975Snwhitehorn 81264975Snwhitehorn.include "${.CURDIR}/Makefile.fat" 82293425SemasteBOOT1_MAXSIZE?= 131072 83264975Snwhitehorn 84264975Snwhitehornboot1.efifat: boot1.efi 85293425Semaste @set -- `ls -l boot1.efi`; \ 86293425Semaste x=$$(($$5-${BOOT1_MAXSIZE})); \ 87293425Semaste if [ $$x -ge 0 ]; then \ 88293425Semaste echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 89293425Semaste exit 1; \ 90293425Semaste fi 91264975Snwhitehorn echo ${.OBJDIR} 92281524Sandrew uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu 93281524Sandrew mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 94264975Snwhitehorn bzip2 -f -d ${.TARGET}.bz2 95264975Snwhitehorn dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc 96264975Snwhitehorn 97281117SandrewCLEANFILES= boot1.efi boot1.efifat 98264975Snwhitehorn 99264391Snwhitehorn.endif # ${COMPILER_TYPE} != "gcc" 100264391Snwhitehorn 101264391Snwhitehorn.include <bsd.prog.mk> 102264391Snwhitehorn 103281496Sandrewbeforedepend ${OBJS}: machine 104264391Snwhitehorn 105281496SandrewCLEANFILES+= machine 106264391Snwhitehorn 107264391Snwhitehornmachine: 108281496Sandrew ln -sf ${.CURDIR}/../../../${MACHINE}/include machine 109264391Snwhitehorn 110281496Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 111281496Sandrewbeforedepend ${OBJS}: x86 112281496SandrewCLEANFILES+= x86 113281496Sandrew 114264391Snwhitehornx86: 115264391Snwhitehorn ln -sf ${.CURDIR}/../../../x86/include x86 116281027Sandrew.endif 117