Makefile.efiboot revision 1.30
1# $NetBSD: Makefile.efiboot,v 1.30 2024/01/20 11:04:53 kre 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+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER} 110 111SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT 112SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT 113SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)" 114 115### find out what to use for libsa 116SA_AS= library 117SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 118SAMISCMAKEFLAGS+="SA_USE_CREAD=yes" 119SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes" 120SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes" 121SAMISCMAKEFLAGS+="SA_ENABLE_BIENDIAN=yes" 122.include "${S}/lib/libsa/Makefile.inc" 123LIBSA= ${SALIB} 124 125### find out what to use for libkern 126KERN_AS= library 127LIBKERN_ARCH?= ${MACHINE_ARCH} 128KERNMISCMAKEFLAGS+="LIBKERN_ARCH=${LIBKERN_ARCH}" 129.include "${S}/lib/libkern/Makefile.inc" 130CPPFLAGS+= -I${S}/../common/include/libc 131LIBKERN= ${KERNLIB} 132 133### find out what to use for libz 134Z_AS= library 135.include "${S}/lib/libz/Makefile.inc" 136CPPFLAGS+= -I${S}/lib/libz -I${S}/../common/dist/zlib 137LIBZ= ${ZLIB} 138 139### find out what to use for libgnuefi 140GNUEFI_AS= library 141LIBGNUEFI_ARCH?= ${MACHINE_ARCH} 142GNUEFIMISCMAKEFLAGS+="LIBGNUEFI_ARCH=${LIBGNUEFI_ARCH}" 143GNUEFIMISCCPPFLAGS+= -I${EFIDIR}/lib 144.include "${S}/lib/libgnuefi/Makefile.inc" 145LIBGNUEFI= ${GNUEFILIB} 146 147cleandir distclean: .WAIT cleanlibdir 148 149cleanlibdir: 150 -rm -rf lib 151 152LIBLIST= ${LIBGNUEFI} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBSA} 153 154VERSIONMACHINE=${MACHINE} 155.include "${S}/conf/newvers_stand.mk" 156 157CLEANFILES+= ${PROG}.so ${PROG}.tmp 158 159${PROG}: ${PROG}.so 160 ${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ 161 -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ 162 -j .reloc ${OBJCOPY_FORMAT} ${PROG}.so ${.TARGET} 163 164.include <bsd.prog.mk> 165 166${PROG}.so: ${OBJS} ${LIBLIST} ${LDSCRIPT} ${.CURDIR}/../Makefile.efiboot 167 ${LD} ${LDFLAGS} -o ${.TARGET}.tmp ${OBJS} ${LIBLIST} 168 @if ${OBJDUMP} -t ${.TARGET}.tmp | grep 'UND'; then \ 169 (echo Undefined symbols; false); \ 170 fi 171 rm -f ${.TARGET} 172 mv ${.TARGET}.tmp ${.TARGET} 173 174KLINK_MACHINE?= ${MACHINE} 175.include <bsd.klinks.mk> 176