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