1# $FreeBSD$ 2 3MAN= 4 5.include <bsd.own.mk> 6 7MK_SSP= no 8 9PROG= loader.sym 10INTERNALPROG= 11WARNS?= 3 12 13# architecture-specific loader code 14SRCS= autoload.c \ 15 bootinfo.c \ 16 conf.c \ 17 copy.c \ 18 devicename.c \ 19 main.c \ 20 smbios.c \ 21 vers.c 22 23.if ${MK_ZFS} != "no" 24SRCS+= zfs.c 25.PATH: ${.CURDIR}/../../zfs 26 27# Disable warnings that are currently incompatible with the zfs boot code 28CWARNFLAGS.zfs.c+= -Wno-sign-compare 29CWARNFLAGS.zfs.c+= -Wno-array-bounds 30CWARNFLAGS.zfs.c+= -Wno-missing-prototypes 31.endif 32 33.PATH: ${.CURDIR}/arch/${MACHINE} 34# For smbios.c 35.PATH: ${.CURDIR}/../../i386/libi386 36.include "${.CURDIR}/arch/${MACHINE}/Makefile.inc" 37 38CFLAGS+= -fPIC 39CFLAGS+= -I${.CURDIR} 40CFLAGS+= -I${.CURDIR}/arch/${MACHINE} 41CFLAGS+= -I${.CURDIR}/../include 42CFLAGS+= -I${.CURDIR}/../include/${MACHINE} 43CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include 44CFLAGS+= -I${.CURDIR}/../../.. 45CFLAGS+= -I${.CURDIR}/../../i386/libi386 46.if ${MK_ZFS} != "no" 47CFLAGS+= -I${.CURDIR}/../../zfs 48CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs 49CFLAGS+= -DEFI_ZFS_BOOT 50.endif 51CFLAGS+= -DNO_PCI -DEFI 52 53.if !defined(BOOT_HIDE_SERIAL_NUMBERS) 54# Export serial numbers, UUID, and asset tag from loader. 55CFLAGS+= -DSMBIOS_SERIAL_NUMBERS 56.if defined(BOOT_LITTLE_ENDIAN_UUID) 57# Use little-endian UUID format as defined in SMBIOS 2.6. 58CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID 59.elif defined(BOOT_NETWORK_ENDIAN_UUID) 60# Use network-endian UUID format for backward compatibility. 61CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID 62.endif 63.endif 64 65.if ${MK_FORTH} != "no" 66BOOT_FORTH= yes 67CFLAGS+= -DBOOT_FORTH 68CFLAGS+= -I${.CURDIR}/../../ficl 69CFLAGS+= -I${.CURDIR}/../../ficl/${MACHINE} 70LIBFICL= ${.OBJDIR}/../../ficl/libficl.a 71.endif 72 73# Include bcache code. 74HAVE_BCACHE= yes 75 76.if defined(EFI_STAGING_SIZE) 77CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE} 78.endif 79 80# Always add MI sources 81.PATH: ${.CURDIR}/../../common 82.include "${.CURDIR}/../../common/Makefile.inc" 83CFLAGS+= -I${.CURDIR}/../../common 84 85FILES= loader.efi 86FILESMODE_loader.efi= ${BINMODE} 87 88LDSCRIPT= ${.CURDIR}/arch/${MACHINE}/ldscript.${MACHINE} 89LDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -Wl,-znocombreloc 90 91CLEANFILES= vers.c loader.efi 92 93NEWVERSWHAT= "EFI loader" ${MACHINE} 94 95vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../../efi/loader/version 96 sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} 97 98NM?= nm 99OBJCOPY?= objcopy 100 101.if ${MACHINE_CPUARCH} == "amd64" 102EFI_TARGET= efi-app-x86_64 103.elif ${MACHINE_CPUARCH} == "i386" 104EFI_TARGET= efi-app-ia32 105.endif 106 107loader.efi: ${PROG} 108 if ${NM} ${.ALLSRC} | grep ' U '; then \ 109 echo "Undefined symbols in ${.ALLSRC}"; \ 110 exit 1; \ 111 fi 112 ${OBJCOPY} -j .text -j .sdata -j .data \ 113 -j .dynamic -j .dynsym -j .rel.dyn \ 114 -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ 115 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 116 117LIBEFI= ${.OBJDIR}/../libefi/libefi.a 118 119DPADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND} ${LDSCRIPT} 120LDADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND} 121 122.include <bsd.prog.mk> 123 124beforedepend ${OBJS}: machine x86 125 126CLEANFILES+= machine x86 127 128machine: 129 ln -sf ${.CURDIR}/../../../amd64/include machine 130 131x86: 132 ln -sf ${.CURDIR}/../../../x86/include x86 133