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