1# $FreeBSD: head/sys/boot/efi/boot1/Makefile 296769 2016-03-12 21:44:33Z emaste $ 2 3MAN= 4 5PROG= boot1.sym 6INTERNALPROG= 7WARNS?= 6 8 9# architecture-specific loader code 10SRCS= boot1.c self_reloc.c start.S ufs_module.c 11 12# DO NOT USE -static, this is a special case 13.undef NOSHARED 14 15CFLAGS+= -I. 16CFLAGS+= -I${.CURDIR}/../include 17CFLAGS+= -I${.CURDIR}/../../../lib 18CFLAGS+= -I${.CURDIR}/../../../../sys/contrib/dev/acpica/source/include 19CFLAGS+= -I${.CURDIR}/../../../contrib/edk2/MdePkg/Include 20CFLAGS+= -I${.CURDIR}/../../../contrib/edk2/MdeModulePkg/Include 21CFLAGS+= -I${.CURDIR}/../../../../sys 22CFLAGS+= -DEFI_UFS_BOOT 23 24.if ${MACHINE_ARCH} == "x86_64" 25CFLAGS+= -I${.CURDIR}/../../../contrib/edk2/MdePkg/Include/X64 26.endif 27 28# Disable stack protector 29CFLAGS+= -fno-stack-protector 30 31.ifdef(EFI_DEBUG) 32CFLAGS+= -DEFI_DEBUG 33.endif 34 35# Always add MI sources and REGULAR efi loader bits 36.PATH: ${.CURDIR}/../loader/arch/${MACHINE} 37.PATH: ${.CURDIR}/../loader 38.PATH: ${.CURDIR}/../../common 39CFLAGS+= -I${.CURDIR}/../../common 40 41FILES= boot1.efi 42FILESMODE_boot1.efi= ${BINMODE} 43 44LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} 45LDFLAGS+= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared 46 47.if ${MACHINE_ARCH} == "aarch64" 48CFLAGS+= -msoft-float -mgeneral-regs-only 49.endif 50.if ${MACHINE_ARCH} == "x86_64" 51CFLAGS+= -fPIC 52LDFLAGS+= -Wl,-znocombreloc 53.endif 54 55.if exists(${.OBJDIR}/../libefi/libefi.a) 56LIBEFI= ${.OBJDIR}/../libefi/libefi.a 57.endif 58.if exists(${.OBJDIR}/../../../lib/libstand.a) 59LIBSTAND= ${.OBJDIR}/../../../lib/libstand.a 60.endif 61 62# 63# Add libstand for the runtime functions used by the compiler - for example 64# __aeabi_* (arm) or __divdi3 (i386). 65# as well as required string and memory functions for all platforms. 66# 67DPADD+= ${LIBEFI} ${LIBSTAND} 68LDADD+= ${LIBEFI} ${LIBSTAND} 69 70DPADD+= ${LDSCRIPT} 71 72NM?= nm 73OBJCOPY?= objcopy 74 75.if ${MACHINE_ARCH} == "x86_64" 76EFI_TARGET= pei-x86-64 77.else 78EFI_TARGET= binary 79.endif 80 81all: boot1.efi 82 83boot1.efi: ${PROG} 84 if ${NM} ${.ALLSRC} | grep ' U '; then \ 85 echo "Undefined symbols in ${.ALLSRC}"; \ 86 exit 1; \ 87 fi 88 ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 89 -j .dynamic -j .dynsym -j .rel.dyn \ 90 -j .rela.dyn -j .reloc \ 91 ${EFI_GOLD_OBJCOPY_FLAGS} --subsystem efi-app \ 92 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 93 94boot1.o: ${.CURDIR}/../../common/ufsread.c 95 96# The following inserts our objects into a template FAT file system 97# created by generate-fat.sh 98 99# XXX generate-fat.sh needs porting 100#.include "${.CURDIR}/Makefile.fat" 101#BOOT1_MAXSIZE?= 131072 102 103#boot1.efifat: boot1.efi 104# @set -- `ls -l boot1.efi`; \ 105# x=$$(($$5-${BOOT1_MAXSIZE})); \ 106# if [ $$x -ge 0 ]; then \ 107# echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 108# exit 1; \ 109# fi 110# echo ${.OBJDIR} 111# uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu 112# mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 113# bzip2 -f -d ${.TARGET}.bz2 114# dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc \ 115# status=none 116 117CLEANFILES= boot1.efi 118 119.include <bsd.prog.mk> 120