1# $FreeBSD$ 2 3.include <bsd.init.mk> 4 5BOOT1?= boot1 6PROG= ${BOOT1}.sym 7INTERNALPROG= 8WARNS?= 6 9 10CFLAGS+= -DEFI_BOOT1 11# We implement a slightly non-standard %S in that it always takes a 12# CHAR16 that's common in UEFI-land instead of a wchar_t. This only 13# seems to matter on arm64 where wchar_t defaults to an int instead 14# of a short. There's no good cast to use here so just ignore the 15# warnings for now. 16CWARNFLAGS.boot1.c+= -Wno-format 17 18# Disable bogus alignment issues 19CWARNFLAGS.ufs_module.c += -Wno-cast-align 20 21# Disable warnings that are currently incompatible with the zfs boot code 22CWARNFLAGS.zfs_module.c += -Wno-array-bounds 23CWARNFLAGS.zfs_module.c += -Wno-cast-align 24CWARNFLAGS.zfs_module.c += -Wno-cast-qual 25CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes 26CWARNFLAGS.zfs_module.c += -Wno-sign-compare 27CWARNFLAGS.zfs_module.c += -Wno-unused-parameter 28CWARNFLAGS.zfs_module.c += -Wno-unused-function 29 30# architecture-specific loader code 31SRCS+= boot1.c self_reloc.c start.S ufs_module.c devpath.c 32.if ${MK_LOADER_ZFS} != "no" 33SRCS+= zfs_module.c 34CFLAGS.zfs_module.c+= -I${ZFSSRC} 35CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/boot/zfs 36CFLAGS.zfs_module.c+= -I${SYSDIR}/crypto/skein 37CFLAGS+= -DEFI_ZFS_BOOT 38.endif 39 40.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 41CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized 42.endif 43 44CFLAGS+= -I${EFIINC} 45CFLAGS+= -I${EFIINCMD} 46CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include 47CFLAGS+= -DEFI_UFS_BOOT 48.ifdef(EFI_DEBUG) 49CFLAGS+= -DEFI_DEBUG 50.endif 51 52# Always add MI sources and REGULAR efi loader bits 53.PATH: ${EFISRC}/loader/arch/${MACHINE} 54.PATH: ${EFISRC}/loader 55.PATH: ${LDRSRC} 56.PATH: ${EFISRC}/libefi 57CFLAGS+= -I${LDRSRC} 58 59FILES= ${BOOT1}.efi 60FILESMODE_${BOOT1}.efi= ${BINMODE} 61.ifndef(NOFAT) 62FILES+= ${BOOT1}.efifat 63.endif 64 65LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE} 66LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared 67 68.if ${MACHINE_CPUARCH} == "aarch64" 69CFLAGS+= -mgeneral-regs-only 70.endif 71.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 72CFLAGS+= -fPIC 73LDFLAGS+= -Wl,-znocombreloc 74.endif 75 76LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a 77 78# 79# Add libstand for the runtime functions used by the compiler - for example 80# __aeabi_* (arm) or __divdi3 (i386). 81# as well as required string and memory functions for all platforms. 82# 83DPADD+= ${LIBEFI} ${LIBSA} 84LDADD+= ${LIBEFI} ${LIBSA} 85 86DPADD+= ${LDSCRIPT} 87 88${BOOT1}.efi: ${PROG} 89 if ${NM} ${.ALLSRC} | grep ' U '; then \ 90 echo "Undefined symbols in ${.ALLSRC}"; \ 91 exit 1; \ 92 fi 93 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 94 ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 95 -j .dynamic -j .dynsym -j .rel.dyn \ 96 -j .rela.dyn -j .reloc -j .eh_frame \ 97 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 98 99.ifndef(NOFAT) 100# The following inserts our objects into a template FAT file system 101# created by generate-fat.sh 102 103.include "Makefile.fat" 104 105${BOOT1}.efifat: ${BOOT1}.efi 106 @set -- `ls -l ${.ALLSRC}`; \ 107 x=$$(($$5-${BOOT1_MAXSIZE})); \ 108 if [ $$x -ge 0 ]; then \ 109 echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 110 exit 1; \ 111 fi 112 echo ${.OBJDIR} 113 xz -d -c ${BOOTSRC}/efi/boot1/fat-${MACHINE}.tmpl.xz > ${.TARGET} 114 ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc 115 116CLEANFILES+= ${BOOT1}.efi ${BOOT1}.efifat 117.endif 118 119.include <bsd.prog.mk> 120