Makefile.efiboot revision 1.23
11.23Sjmcneill# $NetBSD: Makefile.efiboot,v 1.23 2021/09/28 11:37:45 jmcneill 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.23Sjmcneill		efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c \
281.23Sjmcneill		efiwatchdog.c efigop.c smbios.c
291.1Sjmcneill
301.1Sjmcneill.PATH: ${S}/external/bsd/libfdt/dist
311.1SjmcneillCPPFLAGS+=	-I${S}/external/bsd/libfdt/dist
321.7SthorpejSOURCES+=	fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c
331.1SjmcneillSOURCES+=	fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c
341.1Sjmcneill
351.1SjmcneillSRCS= ${SOURCES} ${EXTRA_SOURCES}
361.1Sjmcneill
371.1Sjmcneill.include <bsd.init.mk>
381.1Sjmcneill
391.1SjmcneillSTRIPFLAG=	# nothing
401.1Sjmcneill
411.1SjmcneillLIBCRT0=	# nothing
421.1SjmcneillLIBCRTI=	# nothing
431.1SjmcneillLIBCRTBEGIN=	# nothing
441.1SjmcneillLIBCRTEND=	# nothing
451.1SjmcneillLIBC=		# nothing
461.1Sjmcneill
471.1SjmcneillBINDIR=/usr/mdec
481.1SjmcneillBINMODE=444
491.1Sjmcneill
501.1Sjmcneill.PATH:	${.CURDIR} ${.CURDIR}/..
511.1Sjmcneill.PATH:	${.CURDIR}/../../lib
521.1Sjmcneill
531.12SrinLDFLAGS+= --no-dynamic-linker --noinhibit-exec
541.1SjmcneillLDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared
551.1SjmcneillCPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR}/../common -I$S/lib/libsa
561.1SjmcneillCPPFLAGS+= -I${.OBJDIR}
571.1SjmcneillCPPFLAGS+= -I${.CURDIR}/../../lib
581.7SthorpejCPPFLAGS+= -I${S}/../common/include
591.1Sjmcneill
601.1SjmcneillCOPTS+=	-fpic -g -O2
611.1SjmcneillCOPTS+=	-fshort-wchar -fno-strict-aliasing
621.1SjmcneillCOPTS+=	-ffreestanding -fno-stack-protector
631.1SjmcneillLDFLAGS+= --defsym=EFI_SUBSYSTEM=0xa
641.1Sjmcneill
651.1Sjmcneill
661.1SjmcneillCOPTS+= ${${ACTIVE_CC} == "gcc":? -Wno-error=unused-but-set-variable :}
671.1SjmcneillCPPFLAGS+= -nostdinc -D_STANDALONE
681.1SjmcneillCPPFLAGS+= -DEFIBOOT
691.5SjmcneillCPPFLAGS+= -DPROGRESS_FN=efi_progress
701.1Sjmcneill
711.1SjmcneillCPPFLAGS+= -Wall -Wmissing-prototypes
721.1SjmcneillCPPFLAGS+= -Wno-pointer-sign
731.1Sjmcneill
741.1SjmcneillCPPFLAGS+= -DHEAP_VARIABLE
751.19SjmcneillCPPFLAGS+= -DSUPPORT_CD9660
761.1SjmcneillCPPFLAGS+= -D"devb2cdb(bno)=(bno)"
771.3SjmcneillCPPFLAGS+= -DSUPPORT_DOSFS
781.1Sjmcneill#CPPFLAGS+= -DSUPPORT_EXT2FS
791.3SjmcneillCPPFLAGS+= -DSUPPORT_BOOTP
801.3SjmcneillCPPFLAGS+= -DSUPPORT_DHCP
811.1Sjmcneill#CPPFLAGS+= -DSUPPORT_NFS
821.3SjmcneillCPPFLAGS+= -DSUPPORT_TFTP
831.2SjmcneillCPPFLAGS+= -DLIBSA_ENABLE_LS_OP
841.21SmrgCPPFLAGS+= -DLIBSA_FFS_EI
851.21SmrgCPPFLAGS+= -DLIBSA_DISKLABEL_EI
861.1Sjmcneill
871.7Sthorpej#CPPFLAGS+= -DEFIBOOT_DEBUG
881.1Sjmcneill#CPPFLAGS+= -DARP_DEBUG
891.1Sjmcneill#CPPFLAGS+= -DBOOTP_DEBUG
901.1Sjmcneill#CPPFLAGS+= -DNET_DEBUG
911.1Sjmcneill#CPPFLAGS+= -DNETIF_DEBUG
921.1Sjmcneill#CPPFLAGS+= -DNFS_DEBUG
931.1Sjmcneill#CPPFLAGS+= -DRARP_DEBUG
941.1Sjmcneill#CPPFLAGS+= -DRPC_DEBUG
951.1Sjmcneill
961.11Stnn# Follow the suit of Makefile.kern.inc; needed for the lfs64 union
971.11Stnn# accessors -- they don't actually dereference the resulting pointer,
981.11Stnn# just use it for type-checking.
991.11StnnCWARNFLAGS.clang+=	-Wno-error=address-of-packed-member
1001.18SmrgCWARNFLAGS.gcc+=	${GCC_NO_ADDR_OF_PACKED_MEMBER}
1011.11Stnn
1021.1SjmcneillSAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
1031.1SjmcneillSAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
1041.1SjmcneillSAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"
1051.1Sjmcneill
1061.1Sjmcneill### find out what to use for libsa
1071.1SjmcneillSA_AS= library
1081.1SjmcneillSAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
1091.1SjmcneillSAMISCMAKEFLAGS+="SA_USE_CREAD=yes"
1101.3SjmcneillSAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes"
1111.2SjmcneillSAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
1121.8SrinSAMISCMAKEFLAGS+="SA_ENABLE_BIENDIAN=yes"
1131.1Sjmcneill.include "${S}/lib/libsa/Makefile.inc"
1141.1SjmcneillLIBSA= ${SALIB}
1151.1Sjmcneill
1161.1Sjmcneill### find out what to use for libkern
1171.1SjmcneillKERN_AS= library
1181.1SjmcneillLIBKERN_ARCH?= ${MACHINE_ARCH}
1191.1SjmcneillKERNMISCMAKEFLAGS+="LIBKERN_ARCH=${LIBKERN_ARCH}"
1201.1Sjmcneill.include "${S}/lib/libkern/Makefile.inc"
1211.1SjmcneillLIBKERN= ${KERNLIB}
1221.1Sjmcneill
1231.1Sjmcneill### find out what to use for libz
1241.1SjmcneillZ_AS= library
1251.1Sjmcneill.include "${S}/lib/libz/Makefile.inc"
1261.1SjmcneillLIBZ= ${ZLIB}
1271.1Sjmcneill
1281.1Sjmcneill### find out what to use for libgnuefi
1291.1SjmcneillGNUEFI_AS= library
1301.1SjmcneillLIBGNUEFI_ARCH?= ${MACHINE_ARCH}
1311.1SjmcneillGNUEFIMISCMAKEFLAGS+="LIBGNUEFI_ARCH=${LIBGNUEFI_ARCH}"
1321.1SjmcneillGNUEFIMISCCPPFLAGS+= -I${EFIDIR}/lib
1331.1Sjmcneill.include "${S}/lib/libgnuefi/Makefile.inc"
1341.1SjmcneillLIBGNUEFI= ${GNUEFILIB}
1351.1Sjmcneill
1361.1Sjmcneillcleandir distclean: .WAIT cleanlibdir
1371.1Sjmcneill
1381.1Sjmcneillcleanlibdir:
1391.1Sjmcneill	-rm -rf lib
1401.1Sjmcneill
1411.1SjmcneillLIBLIST= ${LIBGNUEFI} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBSA}
1421.1Sjmcneill
1431.20SjmcneillVERSIONMACHINE=${MACHINE}
1441.1Sjmcneill.include "${S}/conf/newvers_stand.mk"
1451.1Sjmcneill
1461.1SjmcneillCLEANFILES+=	${PROG}.so ${PROG}.tmp
1471.1Sjmcneill
1481.1Sjmcneill${PROG}: ${PROG}.so
1491.1Sjmcneill	${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
1501.1Sjmcneill	    -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \
1511.1Sjmcneill	    -j .reloc -O binary ${PROG}.so ${.TARGET}
1521.1Sjmcneill
1531.1Sjmcneill.include <bsd.prog.mk>
1541.1Sjmcneill
1551.1Sjmcneill${PROG}.so: ${OBJS} ${LIBLIST} ${LDSCRIPT} ${.CURDIR}/../Makefile.efiboot
1561.1Sjmcneill	${LD} ${LDFLAGS} -o ${.TARGET}.tmp ${OBJS} ${LIBLIST}
1571.1Sjmcneill	@if ${OBJDUMP} -t ${.TARGET}.tmp | grep 'UND'; then		\
1581.1Sjmcneill	    (echo Undefined symbols; false);				\
1591.1Sjmcneill	fi
1601.1Sjmcneill	rm -f ${.TARGET}
1611.1Sjmcneill	mv ${.TARGET}.tmp ${.TARGET}
1621.1Sjmcneill
1631.1SjmcneillKLINK_MACHINE?=	${MACHINE}
1641.1Sjmcneill.include <bsd.klinks.mk>
165