Makefile.efiboot revision 1.21
11.21Smrg# $NetBSD: Makefile.efiboot,v 1.21 2021/05/27 06:54:45 mrg Exp $
21.1Sjmcneill
31.1SjmcneillS=		${.CURDIR}/../../..
41.1Sjmcneill
51.1SjmcneillNOMAN=		# defined
61.1SjmcneillNOPIE=		# defined
71.1SjmcneillNOLIBCSANITIZER=# defined
81.1SjmcneillNOSANITIZER=	# defined
91.1SjmcneillNORELRO=	# defined
101.1SjmcneillPROG?=		boot.efi
111.10SjmcneillNEWVERSWHAT?=	"efiboot"
121.1Sjmcneill
131.1SjmcneillEFIDIR= ${S}/external/bsd/gnu-efi/dist
141.1SjmcneillGNUEFIARCH?= ${MACHINE_CPU}
151.1SjmcneillCPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH}
161.1SjmcneillCPPFLAGS+= -I${EFIDIR}/inc/protocol
171.1Sjmcneill
181.1SjmcneillLDSCRIPT?= ${EFIDIR}/gnuefi/elf_${GNUEFIARCH}_efi.lds
191.1Sjmcneill
201.1SjmcneillAFLAGS.start.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
211.1Sjmcneill
221.1Sjmcneill.PATH: ${EFIDIR}/gnuefi
231.1SjmcneillSOURCES=	crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c
241.15SjmcneillSOURCES+=	boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \
251.16Sthorpej		module.c overlay.c panic.c prompt.c
261.17SjmcneillSOURCES+=	efiboot.c efichar.c efidev.c efigetsecs.c efifdt.c \
271.14Sjmcneill		efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c smbios.c
281.1Sjmcneill
291.1Sjmcneill.PATH: ${S}/external/bsd/libfdt/dist
301.1SjmcneillCPPFLAGS+=	-I${S}/external/bsd/libfdt/dist
311.7SthorpejSOURCES+=	fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c
321.1SjmcneillSOURCES+=	fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c
331.1Sjmcneill
341.1SjmcneillSRCS= ${SOURCES} ${EXTRA_SOURCES}
351.1Sjmcneill
361.1Sjmcneill.include <bsd.init.mk>
371.1Sjmcneill
381.1SjmcneillSTRIPFLAG=	# nothing
391.1Sjmcneill
401.1SjmcneillLIBCRT0=	# nothing
411.1SjmcneillLIBCRTI=	# nothing
421.1SjmcneillLIBCRTBEGIN=	# nothing
431.1SjmcneillLIBCRTEND=	# nothing
441.1SjmcneillLIBC=		# nothing
451.1Sjmcneill
461.1SjmcneillBINDIR=/usr/mdec
471.1SjmcneillBINMODE=444
481.1Sjmcneill
491.1Sjmcneill.PATH:	${.CURDIR} ${.CURDIR}/..
501.1Sjmcneill.PATH:	${.CURDIR}/../../lib
511.1Sjmcneill
521.12SrinLDFLAGS+= --no-dynamic-linker --noinhibit-exec
531.1SjmcneillLDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared
541.1SjmcneillCPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR}/../common -I$S/lib/libsa
551.1SjmcneillCPPFLAGS+= -I${.OBJDIR}
561.1SjmcneillCPPFLAGS+= -I${.CURDIR}/../../lib
571.7SthorpejCPPFLAGS+= -I${S}/../common/include
581.1Sjmcneill
591.1SjmcneillCOPTS+=	-fpic -g -O2
601.1SjmcneillCOPTS+=	-fshort-wchar -fno-strict-aliasing
611.1SjmcneillCOPTS+=	-ffreestanding -fno-stack-protector
621.1SjmcneillLDFLAGS+= --defsym=EFI_SUBSYSTEM=0xa
631.1Sjmcneill
641.1Sjmcneill
651.1SjmcneillCOPTS+= ${${ACTIVE_CC} == "gcc":? -Wno-error=unused-but-set-variable :}
661.1SjmcneillCPPFLAGS+= -nostdinc -D_STANDALONE
671.1SjmcneillCPPFLAGS+= -DEFIBOOT
681.5SjmcneillCPPFLAGS+= -DPROGRESS_FN=efi_progress
691.1Sjmcneill
701.1SjmcneillCPPFLAGS+= -Wall -Wmissing-prototypes
711.1SjmcneillCPPFLAGS+= -Wno-pointer-sign
721.1Sjmcneill
731.1SjmcneillCPPFLAGS+= -DHEAP_VARIABLE
741.19SjmcneillCPPFLAGS+= -DSUPPORT_CD9660
751.1SjmcneillCPPFLAGS+= -D"devb2cdb(bno)=(bno)"
761.3SjmcneillCPPFLAGS+= -DSUPPORT_DOSFS
771.1Sjmcneill#CPPFLAGS+= -DSUPPORT_EXT2FS
781.3SjmcneillCPPFLAGS+= -DSUPPORT_BOOTP
791.3SjmcneillCPPFLAGS+= -DSUPPORT_DHCP
801.1Sjmcneill#CPPFLAGS+= -DSUPPORT_NFS
811.3SjmcneillCPPFLAGS+= -DSUPPORT_TFTP
821.2SjmcneillCPPFLAGS+= -DLIBSA_ENABLE_LS_OP
831.21SmrgCPPFLAGS+= -DLIBSA_FFS_EI
841.21SmrgCPPFLAGS+= -DLIBSA_DISKLABEL_EI
851.1Sjmcneill
861.7Sthorpej#CPPFLAGS+= -DEFIBOOT_DEBUG
871.1Sjmcneill#CPPFLAGS+= -DARP_DEBUG
881.1Sjmcneill#CPPFLAGS+= -DBOOTP_DEBUG
891.1Sjmcneill#CPPFLAGS+= -DNET_DEBUG
901.1Sjmcneill#CPPFLAGS+= -DNETIF_DEBUG
911.1Sjmcneill#CPPFLAGS+= -DNFS_DEBUG
921.1Sjmcneill#CPPFLAGS+= -DRARP_DEBUG
931.1Sjmcneill#CPPFLAGS+= -DRPC_DEBUG
941.1Sjmcneill
951.11Stnn# Follow the suit of Makefile.kern.inc; needed for the lfs64 union
961.11Stnn# accessors -- they don't actually dereference the resulting pointer,
971.11Stnn# just use it for type-checking.
981.11StnnCWARNFLAGS.clang+=	-Wno-error=address-of-packed-member
991.18SmrgCWARNFLAGS.gcc+=	${GCC_NO_ADDR_OF_PACKED_MEMBER}
1001.11Stnn
1011.1SjmcneillSAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
1021.1SjmcneillSAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
1031.1SjmcneillSAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"
1041.1Sjmcneill
1051.1Sjmcneill### find out what to use for libsa
1061.1SjmcneillSA_AS= library
1071.1SjmcneillSAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
1081.1SjmcneillSAMISCMAKEFLAGS+="SA_USE_CREAD=yes"
1091.3SjmcneillSAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes"
1101.2SjmcneillSAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
1111.8SrinSAMISCMAKEFLAGS+="SA_ENABLE_BIENDIAN=yes"
1121.1Sjmcneill.include "${S}/lib/libsa/Makefile.inc"
1131.1SjmcneillLIBSA= ${SALIB}
1141.1Sjmcneill
1151.1Sjmcneill### find out what to use for libkern
1161.1SjmcneillKERN_AS= library
1171.1SjmcneillLIBKERN_ARCH?= ${MACHINE_ARCH}
1181.1SjmcneillKERNMISCMAKEFLAGS+="LIBKERN_ARCH=${LIBKERN_ARCH}"
1191.1Sjmcneill.include "${S}/lib/libkern/Makefile.inc"
1201.1SjmcneillLIBKERN= ${KERNLIB}
1211.1Sjmcneill
1221.1Sjmcneill### find out what to use for libz
1231.1SjmcneillZ_AS= library
1241.1Sjmcneill.include "${S}/lib/libz/Makefile.inc"
1251.1SjmcneillLIBZ= ${ZLIB}
1261.1Sjmcneill
1271.1Sjmcneill### find out what to use for libgnuefi
1281.1SjmcneillGNUEFI_AS= library
1291.1SjmcneillLIBGNUEFI_ARCH?= ${MACHINE_ARCH}
1301.1SjmcneillGNUEFIMISCMAKEFLAGS+="LIBGNUEFI_ARCH=${LIBGNUEFI_ARCH}"
1311.1SjmcneillGNUEFIMISCCPPFLAGS+= -I${EFIDIR}/lib
1321.1Sjmcneill.include "${S}/lib/libgnuefi/Makefile.inc"
1331.1SjmcneillLIBGNUEFI= ${GNUEFILIB}
1341.1Sjmcneill
1351.1Sjmcneillcleandir distclean: .WAIT cleanlibdir
1361.1Sjmcneill
1371.1Sjmcneillcleanlibdir:
1381.1Sjmcneill	-rm -rf lib
1391.1Sjmcneill
1401.1SjmcneillLIBLIST= ${LIBGNUEFI} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBSA}
1411.1Sjmcneill
1421.20SjmcneillVERSIONMACHINE=${MACHINE}
1431.1Sjmcneill.include "${S}/conf/newvers_stand.mk"
1441.1Sjmcneill
1451.1SjmcneillCLEANFILES+=	${PROG}.so ${PROG}.tmp
1461.1Sjmcneill
1471.1Sjmcneill${PROG}: ${PROG}.so
1481.1Sjmcneill	${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
1491.1Sjmcneill	    -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \
1501.1Sjmcneill	    -j .reloc -O binary ${PROG}.so ${.TARGET}
1511.1Sjmcneill
1521.1Sjmcneill.include <bsd.prog.mk>
1531.1Sjmcneill
1541.1Sjmcneill${PROG}.so: ${OBJS} ${LIBLIST} ${LDSCRIPT} ${.CURDIR}/../Makefile.efiboot
1551.1Sjmcneill	${LD} ${LDFLAGS} -o ${.TARGET}.tmp ${OBJS} ${LIBLIST}
1561.1Sjmcneill	@if ${OBJDUMP} -t ${.TARGET}.tmp | grep 'UND'; then		\
1571.1Sjmcneill	    (echo Undefined symbols; false);				\
1581.1Sjmcneill	fi
1591.1Sjmcneill	rm -f ${.TARGET}
1601.1Sjmcneill	mv ${.TARGET}.tmp ${.TARGET}
1611.1Sjmcneill
1621.1SjmcneillKLINK_MACHINE?=	${MACHINE}
1631.1Sjmcneill.include <bsd.klinks.mk>
164