Makefile revision 293460
1264391Snwhitehorn# $FreeBSD: head/sys/boot/efi/boot1/Makefile 293460 2016-01-09 03:20:01Z 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= 14264391Snwhitehorn 15264391Snwhitehorn# architecture-specific loader code 16282727SianSRCS= boot1.c self_reloc.c start.S 17264391Snwhitehorn 18264391SnwhitehornCFLAGS+= -I. 19280950SandrewCFLAGS+= -I${.CURDIR}/../include 20281524SandrewCFLAGS+= -I${.CURDIR}/../include/${MACHINE} 21264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include 22264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../.. 23264391Snwhitehorn 24264403Snwhitehorn# Always add MI sources and REGULAR efi loader bits 25281524Sandrew.PATH: ${.CURDIR}/../loader/arch/${MACHINE} 26281237Semaste.PATH: ${.CURDIR}/../loader 27281237Semaste.PATH: ${.CURDIR}/../../common 28264391SnwhitehornCFLAGS+= -I${.CURDIR}/../../common 29264391Snwhitehorn 30264975SnwhitehornFILES= boot1.efi boot1.efifat 31264391SnwhitehornFILESMODE_boot1.efi= ${BINMODE} 32264391Snwhitehorn 33281524SandrewLDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} 34281027SandrewLDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared 35264391Snwhitehorn 36282474Sandrew.if ${MACHINE_CPUARCH} == "aarch64" 37282474SandrewCFLAGS+= -msoft-float -mgeneral-regs-only 38282474Sandrew.endif 39281027Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 40281300SandrewCFLAGS+= -fPIC 41281027SandrewLDFLAGS+= -Wl,-znocombreloc 42281027Sandrew.endif 43281027Sandrew 44281156Sandrew# 45281238Semaste# Add libstand for the runtime functions used by the compiler - for example 46281238Semaste# __aeabi_* (arm) or __divdi3 (i386). 47293460Ssmh# as well as required string and memory functions for all platforms. 48281156Sandrew# 49281156SandrewDPADD+= ${LIBSTAND} 50281156SandrewLDADD+= -lstand 51281156Sandrew 52287930SjhbDPADD+= ${LDSCRIPT} 53264391Snwhitehorn 54264391SnwhitehornOBJCOPY?= objcopy 55264391SnwhitehornOBJDUMP?= objdump 56264391Snwhitehorn 57264391Snwhitehorn.if ${MACHINE_CPUARCH} == "amd64" 58264391SnwhitehornEFI_TARGET= efi-app-x86_64 59280950Sandrew.elif ${MACHINE_CPUARCH} == "i386" 60264391SnwhitehornEFI_TARGET= efi-app-ia32 61281156Sandrew.else 62281156SandrewEFI_TARGET= binary 63264391Snwhitehorn.endif 64264391Snwhitehorn 65287930Sjhbboot1.efi: ${PROG} 66264391Snwhitehorn if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \ 67264391Snwhitehorn ${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \ 68264391Snwhitehorn exit 1; \ 69264391Snwhitehorn fi 70281156Sandrew ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 71264391Snwhitehorn -j .dynamic -j .dynsym -j .rel.dyn \ 72287930Sjhb -j .rela.dyn -j .reloc -j .eh_frame \ 73276146Semaste --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 74264391Snwhitehorn 75264414Snwhitehornboot1.o: ${.CURDIR}/../../common/ufsread.c 76264414Snwhitehorn 77287930Sjhb# The following inserts our objects into a template FAT file system 78264975Snwhitehorn# created by generate-fat.sh 79264975Snwhitehorn 80264975Snwhitehorn.include "${.CURDIR}/Makefile.fat" 81293425SemasteBOOT1_MAXSIZE?= 131072 82264975Snwhitehorn 83264975Snwhitehornboot1.efifat: boot1.efi 84293425Semaste @set -- `ls -l boot1.efi`; \ 85293425Semaste x=$$(($$5-${BOOT1_MAXSIZE})); \ 86293425Semaste if [ $$x -ge 0 ]; then \ 87293425Semaste echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 88293425Semaste exit 1; \ 89293425Semaste fi 90264975Snwhitehorn echo ${.OBJDIR} 91281524Sandrew uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu 92281524Sandrew mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 93264975Snwhitehorn bzip2 -f -d ${.TARGET}.bz2 94264975Snwhitehorn dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc 95264975Snwhitehorn 96281117SandrewCLEANFILES= boot1.efi boot1.efifat 97264975Snwhitehorn 98264391Snwhitehorn.endif # ${COMPILER_TYPE} != "gcc" 99264391Snwhitehorn 100264391Snwhitehorn.include <bsd.prog.mk> 101264391Snwhitehorn 102281496Sandrewbeforedepend ${OBJS}: machine 103264391Snwhitehorn 104281496SandrewCLEANFILES+= machine 105264391Snwhitehorn 106264391Snwhitehornmachine: 107281496Sandrew ln -sf ${.CURDIR}/../../../${MACHINE}/include machine 108264391Snwhitehorn 109281496Sandrew.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 110281496Sandrewbeforedepend ${OBJS}: x86 111281496SandrewCLEANFILES+= x86 112281496Sandrew 113264391Snwhitehornx86: 114264391Snwhitehorn ln -sf ${.CURDIR}/../../../x86/include x86 115281027Sandrew.endif 116