1# $FreeBSD$ 2 3.include <bsd.init.mk> 4 5PROG= boot1.sym 6INTERNALPROG= 7WARNS?= 6 8 9CFLAGS+= -DEFI_BOOT1 10# We implement a slightly non-standard %S in that it always takes a 11# CHAR16 that's common in UEFI-land instead of a wchar_t. This only 12# seems to matter on arm64 where wchar_t defaults to an int instead 13# of a short. There's no good cast to use here so just ignore the 14# warnings for now. 15CWARNFLAGS.boot1.c+= -Wno-format 16 17# Disable warnings that are currently incompatible with the zfs boot code 18CWARNFLAGS.zfs_module.c += -Wno-array-bounds 19CWARNFLAGS.zfs_module.c += -Wno-cast-align 20CWARNFLAGS.zfs_module.c += -Wno-cast-qual 21CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes 22CWARNFLAGS.zfs_module.c += -Wno-sign-compare 23CWARNFLAGS.zfs_module.c += -Wno-unused-parameter 24CWARNFLAGS.zfs_module.c += -Wno-unused-function 25 26# architecture-specific loader code 27SRCS= boot1.c self_reloc.c start.S ufs_module.c 28.if ${MK_LOADER_ZFS} != "no" 29SRCS+= zfs_module.c 30CFLAGS.zfs_module.c+= -I${ZFSSRC} 31CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/boot/zfs 32CFLAGS.zfs_module.c+= -I${SYSDIR}/crypto/skein 33CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/common 34 35CFLAGS+= -DEFI_ZFS_BOOT 36.endif 37 38.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 39CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized 40.endif 41 42CFLAGS+= -I${EFIINC} 43CFLAGS+= -I${EFIINCMD} 44CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include 45CFLAGS+= -DEFI_UFS_BOOT 46.ifdef(EFI_DEBUG) 47CFLAGS+= -DEFI_DEBUG 48.endif 49 50# Always add MI sources and REGULAR efi loader bits 51.PATH: ${EFISRC}/loader/arch/${MACHINE} 52.PATH: ${EFISRC}/loader 53.PATH: ${LDRSRC} 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 82boot1.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 98boot1.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