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