1# $FreeBSD$ 2 3MAN= 4 5.include <bsd.init.mk> 6 7MK_SSP= no 8MK_FORTH= no 9 10PROG= boot1.sym 11INTERNALPROG= 12WARNS?= 6 13 14# We implement a slightly non-standard %S in that it always takes a 15# CHAR16 that's common in UEFI-land instead of a wchar_t. This only 16# seems to matter on arm64 where wchar_t defaults to an int instead 17# of a short. There's no good cast to use here so just ignore the 18# warnings for now. 19CWARNFLAGS.boot1.c+= -Wno-format 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 32.if ${MK_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 38LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a 39.endif 40 41.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 42CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized 43.endif 44 45CFLAGS+= -I${EFIINC} 46CFLAGS+= -I${EFIINCMD} 47CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include 48CFLAGS+= -DEFI_UFS_BOOT 49.ifdef(EFI_DEBUG) 50CFLAGS+= -DEFI_DEBUG 51.endif 52 53# Always add MI sources and REGULAR efi loader bits 54.PATH: ${EFISRC}/loader/arch/${MACHINE} 55.PATH: ${EFISRC}/loader 56.PATH: ${LDRSRC} 57CFLAGS+= -I${LDRSRC} 58 59FILES= boot1.efi boot1.efifat 60FILESMODE_boot1.efi= ${BINMODE} 61 62LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE} 63LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared 64 65.if ${MACHINE_CPUARCH} == "aarch64" 66CFLAGS+= -mgeneral-regs-only 67.endif 68.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 69CFLAGS+= -fPIC 70LDFLAGS+= -Wl,-znocombreloc 71.endif 72 73LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a 74 75# 76# Add libstand for the runtime functions used by the compiler - for example 77# __aeabi_* (arm) or __divdi3 (i386). 78# as well as required string and memory functions for all platforms. 79# 80DPADD+= ${LIBEFI} ${LIBZFSBOOT} ${LIBSA} 81LDADD+= ${LIBEFI} ${LIBZFSBOOT} ${LIBSA} 82 83DPADD+= ${LDSCRIPT} 84 85NM?= nm 86OBJCOPY?= objcopy 87 88.if ${MACHINE_CPUARCH} == "amd64" 89EFI_TARGET= efi-app-x86_64 90.elif ${MACHINE_CPUARCH} == "i386" 91EFI_TARGET= efi-app-ia32 92.else 93EFI_TARGET= binary 94.endif 95 96# Arbitrarily set the PE/COFF header timestamps to 1 Jan 2016 00:00:00 97# for build reproducibility. 98SOURCE_DATE_EPOCH?=1451606400 99boot1.efi: ${PROG} 100 if ${NM} ${.ALLSRC} | grep ' U '; then \ 101 echo "Undefined symbols in ${.ALLSRC}"; \ 102 exit 1; \ 103 fi 104 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 105 ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 106 -j .dynamic -j .dynsym -j .rel.dyn \ 107 -j .rela.dyn -j .reloc -j .eh_frame \ 108 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 109 110# The following inserts our objects into a template FAT file system 111# created by generate-fat.sh 112 113.include "Makefile.fat" 114 115boot1.efifat: boot1.efi 116 @set -- `ls -l ${.ALLSRC}`; \ 117 x=$$(($$5-${BOOT1_MAXSIZE})); \ 118 if [ $$x -ge 0 ]; then \ 119 echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ 120 exit 1; \ 121 fi 122 echo ${.OBJDIR} 123 xz -d -c ${BOOTSRC}/efi/boot1/fat-${MACHINE}.tmpl.xz > ${.TARGET} 124 ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc 125 126CLEANFILES+= boot1.efi boot1.efifat 127 128.include <bsd.prog.mk> 129