Makefile.efiboot revision 1.26
1# $NetBSD: Makefile.efiboot,v 1.26 2022/03/25 21:23:00 jmcneill Exp $ 2 3S= ${.CURDIR}/../../.. 4 5NOMAN= # defined 6NOPIE= # defined 7NOLIBCSANITIZER=# defined 8NOSANITIZER= # defined 9NORELRO= # defined 10PROG?= boot.efi 11NEWVERSWHAT?= "efiboot" 12 13EFIDIR= ${S}/external/bsd/gnu-efi/dist 14GNUEFIARCH?= ${MACHINE_CPU} 15CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH} 16CPPFLAGS+= -I${EFIDIR}/inc/protocol 17 18LDSCRIPT?= ${EFIDIR}/gnuefi/elf_${GNUEFIARCH}_efi.lds 19 20AFLAGS.start.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} 21 22.PATH: ${EFIDIR}/gnuefi 23SOURCES= crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c 24SOURCES+= boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \ 25 module.c panic.c prompt.c userconf.c 26SOURCES+= efiboot.c efichar.c efidev.c efigetsecs.c \ 27 efifile.c efiblock.c efinet.c efipxe.c efirng.c \ 28 efiwatchdog.c efigop.c smbios.c 29 30.if ${EFIBOOT_FDT:Uno} == "yes" 31CPPFLAGS+= -DEFIBOOT_FDT 32SOURCES+= efifdt.c overlay.c 33.PATH: ${S}/external/bsd/libfdt/dist 34CPPFLAGS+= -I${S}/external/bsd/libfdt/dist 35SOURCES+= fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c 36SOURCES+= fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c 37.endif 38 39.if ${EFIBOOT_ACPI:Uno} == "yes" 40CPPFLAGS+= -DEFIBOOT_ACPI 41SOURCES+= efiacpi.c 42.endif 43 44SRCS= ${SOURCES} ${EXTRA_SOURCES} 45 46.include <bsd.init.mk> 47 48STRIPFLAG= # nothing 49 50LIBCRT0= # nothing 51LIBCRTI= # nothing 52LIBCRTBEGIN= # nothing 53LIBCRTEND= # nothing 54LIBC= # nothing 55 56BINDIR=/usr/mdec 57BINMODE=444 58 59.PATH: ${.CURDIR} ${.CURDIR}/.. 60.PATH: ${.CURDIR}/../../lib 61 62LDFLAGS+= --no-dynamic-linker --noinhibit-exec 63LDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared 64CPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR}/../common -I$S/lib/libsa 65CPPFLAGS+= -I${.OBJDIR} 66CPPFLAGS+= -I${.CURDIR}/../../lib 67CPPFLAGS+= -I${S}/../common/include 68 69COPTS+= -fpic -g -O2 70COPTS+= -fshort-wchar -fno-strict-aliasing 71COPTS+= -ffreestanding -fno-stack-protector 72LDFLAGS+= --defsym=EFI_SUBSYSTEM=0xa 73 74 75COPTS+= ${${ACTIVE_CC} == "gcc":? -Wno-error=unused-but-set-variable :} 76CPPFLAGS+= -nostdinc -D_STANDALONE 77CPPFLAGS+= -DEFIBOOT 78CPPFLAGS+= -DPROGRESS_FN=efi_progress 79 80CPPFLAGS+= -Wall -Wmissing-prototypes 81CPPFLAGS+= -Wno-pointer-sign 82 83CPPFLAGS+= -DHEAP_VARIABLE 84CPPFLAGS+= -DSUPPORT_CD9660 85CPPFLAGS+= -D"devb2cdb(bno)=(bno)" 86CPPFLAGS+= -DSUPPORT_DOSFS 87#CPPFLAGS+= -DSUPPORT_EXT2FS 88CPPFLAGS+= -DSUPPORT_BOOTP 89CPPFLAGS+= -DSUPPORT_DHCP 90#CPPFLAGS+= -DSUPPORT_NFS 91CPPFLAGS+= -DSUPPORT_TFTP 92CPPFLAGS+= -DLIBSA_ENABLE_LS_OP 93CPPFLAGS+= -DLIBSA_FFS_EI 94CPPFLAGS+= -DLIBSA_DISKLABEL_EI 95CPPFLAGS+= -DDEFAULT_TIMEOUT=5 96 97#CPPFLAGS+= -DEFIBOOT_DEBUG 98#CPPFLAGS+= -DARP_DEBUG 99#CPPFLAGS+= -DBOOTP_DEBUG 100#CPPFLAGS+= -DNET_DEBUG 101#CPPFLAGS+= -DNETIF_DEBUG 102#CPPFLAGS+= -DNFS_DEBUG 103#CPPFLAGS+= -DRARP_DEBUG 104#CPPFLAGS+= -DRPC_DEBUG 105 106# Follow the suit of Makefile.kern.inc; needed for the lfs64 union 107# accessors -- they don't actually dereference the resulting pointer, 108# just use it for type-checking. 109CWARNFLAGS.clang+= -Wno-error=address-of-packed-member 110CWARNFLAGS.gcc+= ${GCC_NO_ADDR_OF_PACKED_MEMBER} 111 112SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT 113SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT 114SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)" 115 116### find out what to use for libsa 117SA_AS= library 118SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 119SAMISCMAKEFLAGS+="SA_USE_CREAD=yes" 120SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes" 121SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes" 122SAMISCMAKEFLAGS+="SA_ENABLE_BIENDIAN=yes" 123.include "${S}/lib/libsa/Makefile.inc" 124LIBSA= ${SALIB} 125 126### find out what to use for libkern 127KERN_AS= library 128LIBKERN_ARCH?= ${MACHINE_ARCH} 129KERNMISCMAKEFLAGS+="LIBKERN_ARCH=${LIBKERN_ARCH}" 130.include "${S}/lib/libkern/Makefile.inc" 131LIBKERN= ${KERNLIB} 132 133### find out what to use for libz 134Z_AS= library 135.include "${S}/lib/libz/Makefile.inc" 136LIBZ= ${ZLIB} 137 138### find out what to use for libgnuefi 139GNUEFI_AS= library 140LIBGNUEFI_ARCH?= ${MACHINE_ARCH} 141GNUEFIMISCMAKEFLAGS+="LIBGNUEFI_ARCH=${LIBGNUEFI_ARCH}" 142GNUEFIMISCCPPFLAGS+= -I${EFIDIR}/lib 143.include "${S}/lib/libgnuefi/Makefile.inc" 144LIBGNUEFI= ${GNUEFILIB} 145 146cleandir distclean: .WAIT cleanlibdir 147 148cleanlibdir: 149 -rm -rf lib 150 151LIBLIST= ${LIBGNUEFI} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBSA} 152 153VERSIONMACHINE=${MACHINE} 154.include "${S}/conf/newvers_stand.mk" 155 156CLEANFILES+= ${PROG}.so ${PROG}.tmp 157 158${PROG}: ${PROG}.so 159 ${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ 160 -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ 161 -j .reloc ${OBJCOPY_FORMAT} ${PROG}.so ${.TARGET} 162 163.include <bsd.prog.mk> 164 165${PROG}.so: ${OBJS} ${LIBLIST} ${LDSCRIPT} ${.CURDIR}/../Makefile.efiboot 166 ${LD} ${LDFLAGS} -o ${.TARGET}.tmp ${OBJS} ${LIBLIST} 167 @if ${OBJDUMP} -t ${.TARGET}.tmp | grep 'UND'; then \ 168 (echo Undefined symbols; false); \ 169 fi 170 rm -f ${.TARGET} 171 mv ${.TARGET}.tmp ${.TARGET} 172 173KLINK_MACHINE?= ${MACHINE} 174.include <bsd.klinks.mk> 175