git: 4b3f5dd4d87c - stable/13 - kboot: Split out powerpc build

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 24 Jan 2023 22:10:12 UTC
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=4b3f5dd4d87c28b4ef1c2cff521eb8bb0f450e89

commit 4b3f5dd4d87c28b4ef1c2cff521eb8bb0f450e89
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-12-30 23:07:13 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-01-24 21:49:19 +0000

    kboot: Split out powerpc build
    
    Split the powerpc specific parts into kboot/arch/powerpc64. More may be
    needed here.
    
    Sponsored by:           Netflix
    Reviewed by:            jhibbits
    Differential Revision:  https://reviews.freebsd.org/D33514
    
    (cherry picked from commit 6497250f6f7f93e36795f5d0ec8ac658f6e781d8)
---
 stand/Makefile                                       |  2 ++
 stand/kboot/Makefile                                 | 17 +++++------------
 stand/kboot/arch/powerpc64/Makefile.inc              | 14 ++++++++++++++
 stand/kboot/{ => arch/powerpc64}/conf.c              |  0
 stand/kboot/{ => arch/powerpc64}/host_syscall.S      |  0
 stand/kboot/{ => arch/powerpc64}/kerneltramp.S       |  0
 stand/kboot/{ => arch/powerpc64}/ldscript.powerpc    |  0
 stand/kboot/{ => arch/powerpc64}/ppc64_elf_freebsd.c |  0
 8 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/stand/Makefile b/stand/Makefile
index 8fd981cd21f1..1597f6832c07 100644
--- a/stand/Makefile
+++ b/stand/Makefile
@@ -80,8 +80,10 @@ SUBDIR_DEPEND_forth+=	ficl
 SUBDIR_DEPEND_lua+=	liblua
 
 SUBDIR_DEPEND_efi+=	${INTERP_DEPENDS}
+SUBDIR_DEPEND_kboot+=	${INTERP_DEPENDS}
 .if ${MK_FDT} != "no"
 SUBDIR_DEPEND_efi+=	fdt
+SUBDIR_DEPEND_kboot+=	fdt
 .endif
 
 SUBDIR_DEPEND_uboot+=	${INTERP_DEPENDS}
diff --git a/stand/kboot/Makefile b/stand/kboot/Makefile
index 46bcc3d0e63a..aa5511d915a9 100644
--- a/stand/kboot/Makefile
+++ b/stand/kboot/Makefile
@@ -17,30 +17,23 @@ NEWVERSWHAT=	"kboot loader" ${MACHINE_ARCH}
 INSTALLFLAGS=	-b
 
 # Architecture-specific loader code
-SRCS=		conf.c vers.c main.c ppc64_elf_freebsd.c
-SRCS+=		host_syscall.S hostcons.c hostdisk.c kerneltramp.S kbootfdt.c
-SRCS+=		ucmpdi2.c gfx_fb_stub.c
+SRCS=		vers.c main.c hostcons.c hostdisk.c kbootfdt.c gfx_fb_stub.c
 
 CFLAGS.gfx_fb_stub.c += -I${SRCTOP}/contrib/pnglite -I${SRCTOP}/sys/teken
 
 .include	"${BOOTSRC}/fdt.mk"
 
-CFLAGS+=	-mcpu=powerpc64
+.PATH:	${.CURDIR}/arch/${MACHINE_ARCH}
+.include "${.CURDIR}/arch/${MACHINE_ARCH}/Makefile.inc"
 
 # Always add MI sources
 .include	"${BOOTSRC}/loader.mk"
 .PATH:		${SYSDIR}/libkern
+CFLAGS+=	-I${.CURDIR} -I${.CURDIR}/arch/${MACHINE_ARCH}
 
-CFLAGS+=	-Wall -DAIM
-# load address. set in linker script
-RELOC?=		0x0
-CFLAGS+=	-DRELOC=${RELOC}
-
-LDFLAGS=	-nostdlib -static -T ${.CURDIR}/ldscript.powerpc
+CFLAGS+=	-Wall
 
 DPADD=		${LDR_INTERP} ${LIBOFW} ${LIBFDT} ${LIBSA}
 LDADD=		${LDR_INTERP} ${LIBOFW} ${LIBFDT} ${LIBSA}
 
-MK_PIE=		no
-
 .include <bsd.prog.mk>
diff --git a/stand/kboot/arch/powerpc64/Makefile.inc b/stand/kboot/arch/powerpc64/Makefile.inc
new file mode 100644
index 000000000000..3c2fb6e18a16
--- /dev/null
+++ b/stand/kboot/arch/powerpc64/Makefile.inc
@@ -0,0 +1,14 @@
+CFLAGS+=	-mcpu=powerpc64
+
+SRCS+=		conf.c ppc64_elf_freebsd.c host_syscall.S kerneltramp.S
+SRCS+=		ucmpdi2.c
+
+# load address. set in linker script
+RELOC?=		0x0
+CFLAGS+=	-DRELOC=${RELOC}
+
+LDFLAGS=	-nostdlib -static -T ${.CURDIR}/arch/${MACHINE_ARCH}/ldscript.powerpc
+
+MK_PIE=		no
+# Maybe bogus?
+CFLAGS+=	 -DAIM
diff --git a/stand/kboot/conf.c b/stand/kboot/arch/powerpc64/conf.c
similarity index 100%
rename from stand/kboot/conf.c
rename to stand/kboot/arch/powerpc64/conf.c
diff --git a/stand/kboot/host_syscall.S b/stand/kboot/arch/powerpc64/host_syscall.S
similarity index 100%
rename from stand/kboot/host_syscall.S
rename to stand/kboot/arch/powerpc64/host_syscall.S
diff --git a/stand/kboot/kerneltramp.S b/stand/kboot/arch/powerpc64/kerneltramp.S
similarity index 100%
rename from stand/kboot/kerneltramp.S
rename to stand/kboot/arch/powerpc64/kerneltramp.S
diff --git a/stand/kboot/ldscript.powerpc b/stand/kboot/arch/powerpc64/ldscript.powerpc
similarity index 100%
rename from stand/kboot/ldscript.powerpc
rename to stand/kboot/arch/powerpc64/ldscript.powerpc
diff --git a/stand/kboot/ppc64_elf_freebsd.c b/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c
similarity index 100%
rename from stand/kboot/ppc64_elf_freebsd.c
rename to stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c