1# $FreeBSD$ 2 3LOADER_NET_SUPPORT?= yes 4LOADER_MSDOS_SUPPORT?= yes 5LOADER_UFS_SUPPORT?= yes 6LOADER_CD9660_SUPPORT?= no 7LOADER_EXT2FS_SUPPORT?= no 8 9.include <bsd.init.mk> 10 11LOADER?= loader_${LOADER_INTERP} 12PROG= ${LOADER}.sym 13INTERNALPROG= 14WARNS?= 3 15 16# architecture-specific loader code 17SRCS= autoload.c \ 18 bootinfo.c \ 19 conf.c \ 20 copy.c \ 21 efi_main.c \ 22 framebuffer.c \ 23 main.c \ 24 self_reloc.c \ 25 vers.c \ 26 gfx_fb.c \ 27 8x16.c 28 29CFLAGS+= -I${.CURDIR}/../loader 30.if ${MK_LOADER_ZFS} != "no" 31CFLAGS+= -I${ZFSSRC} 32CFLAGS+= -I${SYSDIR}/contrib/openzfs/include 33CFLAGS+= -I${SYSDIR}/contrib/openzfs/include/os/freebsd/zfs 34CFLAGS+= -DEFI_ZFS_BOOT 35HAVE_ZFS= yes 36.endif 37 38CFLAGS.bootinfo.c += -I$(SRCTOP)/sys/teken 39CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite 40CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken 41CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite 42CFLAGS.main.c += -I$(SRCTOP)/sys/teken 43CFLAGS.main.c += -I${SRCTOP}/contrib/pnglite 44CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken 45CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 46CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite 47CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib 48 49# We implement a slightly non-standard %S in that it always takes a 50# CHAR16 that's common in UEFI-land instead of a wchar_t. This only 51# seems to matter on arm64 where wchar_t defaults to an int instead 52# of a short. There's no good cast to use here so just ignore the 53# warnings for now. 54CWARNFLAGS.main.c+= -Wno-format 55 56.PATH: ${.CURDIR}/../loader 57.PATH: ${.CURDIR}/../loader/arch/${MACHINE} 58.include "${.CURDIR}/../loader/arch/${MACHINE}/Makefile.inc" 59 60CFLAGS+= -I${.CURDIR} 61CFLAGS+= -I${.CURDIR}/arch/${MACHINE} 62CFLAGS+= -I${EFISRC}/include 63CFLAGS+= -I${EFISRC}/include/${MACHINE} 64CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include 65CFLAGS+= -I${BOOTSRC}/i386/libi386 66CFLAGS+= -DEFI 67 68.if defined(HAVE_FDT) && ${MK_FDT} != "no" 69.include "${BOOTSRC}/fdt.mk" 70LIBEFI_FDT= ${BOOTOBJ}/efi/fdt/libefi_fdt.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.if ${MK_LOADER_EFI_SECUREBOOT} != "no" 81CFLAGS+= -DEFI_SECUREBOOT 82.endif 83 84NEWVERSWHAT= "EFI loader" ${MACHINE} 85VERSION_FILE= ${.CURDIR}/../loader/version 86HELP_FILENAME= loader.help.efi 87 88# Always add MI sources 89.include "${BOOTSRC}/loader.mk" 90 91CLEANFILES+= 8x16.c 92 938x16.c: ${SRCTOP}/contrib/terminus/ter-u16b.bdf 94 vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC} 95 96FILES+= ${LOADER}.efi 97FILESMODE_${LOADER}.efi= ${BINMODE} 98 99.if ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP} 100LINKS+= ${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi 101.endif 102 103LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE} 104LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie 105.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400 106LDFLAGS+= -Wl,--no-dynamic-linker 107.endif 108 109CLEANFILES+= ${LOADER}.efi 110 111${LOADER}.efi: ${PROG} 112 if ${NM} ${.ALLSRC} | grep ' U '; then \ 113 echo "Undefined symbols in ${.ALLSRC}"; \ 114 exit 1; \ 115 fi 116 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ 117 ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ 118 -j .dynamic -j .dynsym -j .rel.dyn \ 119 -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ 120 -j set_Xficl_compile_set \ 121 --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} 122 123LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a 124 125DPADD= ${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} ${LDSCRIPT} 126LDADD= ${LDR_INTERP} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBSA} 127 128.include <bsd.prog.mk> 129