Module Name:    src
Committed By:   martin
Date:           Sat Jun 22 11:11:53 UTC 2024

Modified Files:
        src/share/mk [netbsd-10]: bsd.kmodule.mk
        src/sys/arch/aarch64/aarch64 [netbsd-10]: netbsd32_machdep_13.c
            netbsd32_machdep_16.c
        src/sys/arch/mips/mips [netbsd-10]: netbsd32_machdep_13.c
            netbsd32_machdep_16.c
        src/sys/arch/powerpc/powerpc [netbsd-10]: compat_13_machdep.c
            compat_16_machdep.c
        src/sys/arch/sun2/sun2 [netbsd-10]: enable.h genassym.cf
        src/sys/modules/compat_13 [netbsd-10]: Makefile
        src/sys/modules/compat_16 [netbsd-10]: Makefile
        src/sys/modules/compat_netbsd32_13 [netbsd-10]: Makefile
        src/sys/modules/compat_netbsd32_16 [netbsd-10]: Makefile
Added Files:
        src/sys/modules [netbsd-10]: Makefile.compat

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #724):

        sys/modules/compat_netbsd32_16/Makefile: revision 1.5
        sys/arch/powerpc/powerpc/compat_16_machdep.c: revision 1.25
        sys/arch/powerpc/powerpc/compat_16_machdep.c: revision 1.26
        sys/modules/compat_16/Makefile: revision 1.3
        sys/modules/compat_netbsd32_13/Makefile: revision 1.5
        sys/modules/compat_16/Makefile: revision 1.4
        sys/arch/sun2/sun2/genassym.cf: revision 1.17
        sys/arch/sun2/sun2/enable.h: revision 1.5
        sys/modules/compat_13/Makefile: revision 1.3
        sys/modules/compat_13/Makefile: revision 1.4
        sys/modules/compat_13/Makefile: revision 1.5
        sys/arch/mips/mips/netbsd32_machdep_16.c: revision 1.8
        sys/modules/Makefile.compat: revision 1.1
        sys/arch/mips/mips/netbsd32_machdep_13.c: revision 1.4
        share/mk/bsd.kmodule.mk: revision 1.86
        sys/arch/aarch64/aarch64/netbsd32_machdep_16.c: revision 1.4
        sys/arch/powerpc/powerpc/compat_13_machdep.c: revision 1.23
        sys/arch/aarch64/aarch64/netbsd32_machdep_13.c: revision 1.4

Import AFLAGS to allow processing of assembler files in modules.
Prerequisite for kern/583346.

Introduce sys/modules/Makefile.compat and hook some compat_1[36]
machdep code into the modules.  kern/58346

Ooops missed a source file!

Proteect #include of kernel options files with #ifdef _KERNEL_OPT

XXX Add to existing 10.0 and 9.0 tickets for kern/583346

Include required headers

Add required include for compat_16 machdep code

fix the m68k compat_13 build.

include Makefile.assym to generate assym.h.
use -I. and -x assembler-with-cpp to actually use cpp and find assym.h.
also apply m68k assym.h fix here as well as compat_13.

powerpc64: Provide dummy stubs for compat1[36]
as done for amd64. We haven't had working userland for powerpc64,
and therefore compatible to 1.[36] is only useful for netbsd32.

Fix build failure for evbppc64 for PR kern/58346 (my bug!).
sun2/genassym.cf: Skip KERNBASE for _MODULE
as it is not a compile-time constant; see sun2/vmparam.h.

It should not be, and is not actually, used for modules.

PR kern/58346

sun2/enable.h: Fix -Wold-style-definition for WARNS=5 build as modules
Finally fix sun2 build for PR kern/58346


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.81.2.1 src/share/mk/bsd.kmodule.mk
cvs rdiff -u -r1.3 -r1.3.4.1 \
    src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c \
    src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c
cvs rdiff -u -r1.3 -r1.3.26.1 src/sys/arch/mips/mips/netbsd32_machdep_13.c
cvs rdiff -u -r1.7 -r1.7.4.1 src/sys/arch/mips/mips/netbsd32_machdep_16.c
cvs rdiff -u -r1.22 -r1.22.4.1 \
    src/sys/arch/powerpc/powerpc/compat_13_machdep.c
cvs rdiff -u -r1.23 -r1.23.4.1 \
    src/sys/arch/powerpc/powerpc/compat_16_machdep.c
cvs rdiff -u -r1.4 -r1.4.118.1 src/sys/arch/sun2/sun2/enable.h
cvs rdiff -u -r1.14 -r1.14.24.1 src/sys/arch/sun2/sun2/genassym.cf
cvs rdiff -u -r0 -r1.1.2.2 src/sys/modules/Makefile.compat
cvs rdiff -u -r1.2 -r1.2.32.1 src/sys/modules/compat_13/Makefile
cvs rdiff -u -r1.2 -r1.2.32.1 src/sys/modules/compat_16/Makefile
cvs rdiff -u -r1.4 -r1.4.26.1 src/sys/modules/compat_netbsd32_13/Makefile
cvs rdiff -u -r1.4 -r1.4.26.1 src/sys/modules/compat_netbsd32_16/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/mk/bsd.kmodule.mk
diff -u src/share/mk/bsd.kmodule.mk:1.81 src/share/mk/bsd.kmodule.mk:1.81.2.1
--- src/share/mk/bsd.kmodule.mk:1.81	Sun Aug  7 23:42:09 2022
+++ src/share/mk/bsd.kmodule.mk	Sat Jun 22 11:11:53 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.kmodule.mk,v 1.81 2022/08/07 23:42:09 riastradh Exp $
+#	$NetBSD: bsd.kmodule.mk,v 1.81.2.1 2024/06/22 11:11:53 martin Exp $
 
 # We are not building this with PIE
 MKPIE=no
@@ -31,6 +31,7 @@ CPPFLAGS+=	-nostdinc -I. -I${.CURDIR} -i
 CPPFLAGS+=	-isystem ${S}/../common/include
 CPPFLAGS+=	-D_KERNEL -D_MODULE -DSYSCTL_INCLUDE_DESCR
 CPPFLAGS+=	${${MKDTRACE:Uno} != "no" :? -DKDTRACE_HOOKS :}
+AFLAGS+=	-D_LOCORE -Wa,--fatal-warnings
 
 CWARNFLAGS.clang+=	-Wno-error=constant-conversion
 

Index: src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c:1.3 src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c:1.3.4.1
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c:1.3	Sun Nov 14 15:12:01 2021
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c	Sat Jun 22 11:11:53 2024
@@ -29,12 +29,14 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep_13.c,v 1.3 2021/11/14 15:12:01 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep_13.c,v 1.3.4.1 2024/06/22 11:11:53 martin Exp $");
 
 #if defined (_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
 #endif
 
+#include <compat/netbsd32/netbsd32.h>
+
 void
 netbsd32_machdep_md_13_init(void)
 {
Index: src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c:1.3 src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c:1.3.4.1
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c:1.3	Sun Nov 14 15:12:01 2021
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c	Sat Jun 22 11:11:53 2024
@@ -29,12 +29,14 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep_16.c,v 1.3 2021/11/14 15:12:01 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep_16.c,v 1.3.4.1 2024/06/22 11:11:53 martin Exp $");
 
 #if defined (_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
 #endif
 
+#include <compat/netbsd32/netbsd32.h>
+
 void
 netbsd32_machdep_md_16_init(void)
 {

Index: src/sys/arch/mips/mips/netbsd32_machdep_13.c
diff -u src/sys/arch/mips/mips/netbsd32_machdep_13.c:1.3 src/sys/arch/mips/mips/netbsd32_machdep_13.c:1.3.26.1
--- src/sys/arch/mips/mips/netbsd32_machdep_13.c:1.3	Wed Nov 13 16:11:27 2019
+++ src/sys/arch/mips/mips/netbsd32_machdep_13.c	Sat Jun 22 11:11:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep_13.c,v 1.3 2019/11/13 16:11:27 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_machdep_13.c,v 1.3.26.1 2024/06/22 11:11:53 martin Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,9 +30,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_13.c,v 1.3 2019/11/13 16:11:27 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_13.c,v 1.3.26.1 2024/06/22 11:11:53 martin Exp $");
 
+#ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
+#endif
 
 #include <sys/param.h>
 #include <sys/systm.h>

Index: src/sys/arch/mips/mips/netbsd32_machdep_16.c
diff -u src/sys/arch/mips/mips/netbsd32_machdep_16.c:1.7 src/sys/arch/mips/mips/netbsd32_machdep_16.c:1.7.4.1
--- src/sys/arch/mips/mips/netbsd32_machdep_16.c:1.7	Sat Nov  6 20:42:56 2021
+++ src/sys/arch/mips/mips/netbsd32_machdep_16.c	Sat Jun 22 11:11:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep_16.c,v 1.7 2021/11/06 20:42:56 thorpej Exp $	*/
+/*	$NetBSD: netbsd32_machdep_16.c,v 1.7.4.1 2024/06/22 11:11:53 martin Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,9 +30,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_16.c,v 1.7 2021/11/06 20:42:56 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_16.c,v 1.7.4.1 2024/06/22 11:11:53 martin Exp $");
 
+#ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
+#endif
 
 #include <sys/param.h>
 #include <sys/systm.h>

Index: src/sys/arch/powerpc/powerpc/compat_13_machdep.c
diff -u src/sys/arch/powerpc/powerpc/compat_13_machdep.c:1.22 src/sys/arch/powerpc/powerpc/compat_13_machdep.c:1.22.4.1
--- src/sys/arch/powerpc/powerpc/compat_13_machdep.c:1.22	Sun Mar 13 17:50:55 2022
+++ src/sys/arch/powerpc/powerpc/compat_13_machdep.c	Sat Jun 22 11:11:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_13_machdep.c,v 1.22 2022/03/13 17:50:55 andvar Exp $	*/
+/*	$NetBSD: compat_13_machdep.c,v 1.22.4.1 2024/06/22 11:11:52 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.22 2022/03/13 17:50:55 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.22.4.1 2024/06/22 11:11:52 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ppcarch.h"
@@ -53,6 +53,22 @@ __KERNEL_RCSID(0, "$NetBSD: compat_13_ma
 
 #include <powerpc/psl.h>
 
+#ifdef _LP64
+
+/*
+ * COMPAT_13 is useful only with COMPAT_NETBSD32.
+ */
+
+int
+compat_13_sys_sigreturn(struct lwp *l,
+    const struct compat_13_sys_sigreturn_args *uap, register_t *retval)
+{
+
+	return ENOSYS;
+}
+
+#else
+
 int
 compat_13_sys_sigreturn(struct lwp *l,
     const struct compat_13_sys_sigreturn_args *uap, register_t *retval)
@@ -104,3 +120,5 @@ compat_13_sys_sigreturn(struct lwp *l,
 
 	return (EJUSTRETURN);
 }
+
+#endif /* !_LP64 */

Index: src/sys/arch/powerpc/powerpc/compat_16_machdep.c
diff -u src/sys/arch/powerpc/powerpc/compat_16_machdep.c:1.23 src/sys/arch/powerpc/powerpc/compat_16_machdep.c:1.23.4.1
--- src/sys/arch/powerpc/powerpc/compat_16_machdep.c:1.23	Sun Mar 13 17:50:55 2022
+++ src/sys/arch/powerpc/powerpc/compat_16_machdep.c	Sat Jun 22 11:11:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_16_machdep.c,v 1.23 2022/03/13 17:50:55 andvar Exp $	*/
+/*	$NetBSD: compat_16_machdep.c,v 1.23.4.1 2024/06/22 11:11:52 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.23 2022/03/13 17:50:55 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.23.4.1 2024/06/22 11:11:52 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: compat_16_ma
 #include <compat/sys/signal.h>
 #include <compat/sys/signalvar.h>
 
+#include <powerpc/frame.h>
 #include <powerpc/pcb.h>
 #include <powerpc/psl.h>
 #include <powerpc/fpu.h>
@@ -59,6 +60,29 @@ __KERNEL_RCSID(0, "$NetBSD: compat_16_ma
 #include <powerpc/altivec.h>
 #endif
 
+#ifdef _LP64
+
+/*
+ * COMPAT_16 is useful only with COMPAT_NETBSD32.
+ */
+void
+sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *mask)
+{
+
+	printf("sendsig_sigcontext: illegal\n");
+	sigexit(curlwp, SIGILL);
+}
+
+int
+compat_16_sys___sigreturn14(struct lwp *l,
+    const struct compat_16_sys___sigreturn14_args *uap, register_t *retval)
+{
+
+	return ENOSYS;
+}
+
+#else
+
 /*
  * Send a signal to process.
  */
@@ -252,3 +276,5 @@ compat_16_sys___sigreturn14(struct lwp *
 
 	return (EJUSTRETURN);
 }
+
+#endif /* !_LP64 */

Index: src/sys/arch/sun2/sun2/enable.h
diff -u src/sys/arch/sun2/sun2/enable.h:1.4 src/sys/arch/sun2/sun2/enable.h:1.4.118.1
--- src/sys/arch/sun2/sun2/enable.h:1.4	Mon Apr 28 20:23:37 2008
+++ src/sys/arch/sun2/sun2/enable.h	Sat Jun 22 11:11:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: enable.h,v 1.4 2008/04/28 20:23:37 martin Exp $	*/
+/*	$NetBSD: enable.h,v 1.4.118.1 2024/06/22 11:11:53 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -51,7 +51,7 @@
  */
 #ifdef	_KERNEL
 #define ENABLE_REG_SOFT_UNDEF (0)
-volatile extern u_short enable_reg_soft;
+extern volatile u_short enable_reg_soft;
 u_short enable_reg_and(u_short);
 u_short enable_reg_or(u_short);
 #endif	/* _KERNEL */

Index: src/sys/arch/sun2/sun2/genassym.cf
diff -u src/sys/arch/sun2/sun2/genassym.cf:1.14 src/sys/arch/sun2/sun2/genassym.cf:1.14.24.1
--- src/sys/arch/sun2/sun2/genassym.cf:1.14	Thu Feb 20 08:27:39 2020
+++ src/sys/arch/sun2/sun2/genassym.cf	Sat Jun 22 11:11:53 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.14 2020/02/20 08:27:39 skrll Exp $
+#	$NetBSD: genassym.cf,v 1.14.24.1 2024/06/22 11:11:53 martin Exp $
 
 #
 # Copyright (c) 1982, 1990, 1993
@@ -126,7 +126,9 @@ define	AM9513_CLK_CMD			AM9513_CLK_CMD
 define	SUN2_CLK_TIMER_CLEAR_OUTPUT	AM9513_CMD_CLEAR_OUTPUT(AM9513_TIMER2)
 
 # kernel-isms
+ifndef _MODULE
 define	KERNBASE			KERNBASE
+endif
 define	USPACE				USPACE
 define	PAGE_SIZE			PAGE_SIZE
 define	NBPG				NBPG

Index: src/sys/modules/compat_13/Makefile
diff -u src/sys/modules/compat_13/Makefile:1.2 src/sys/modules/compat_13/Makefile:1.2.32.1
--- src/sys/modules/compat_13/Makefile:1.2	Sun Jan 27 02:08:44 2019
+++ src/sys/modules/compat_13/Makefile	Sat Jun 22 11:11:53 2024
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile,v 1.2 2019/01/27 02:08:44 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.2.32.1 2024/06/22 11:11:53 martin Exp $
 
-.include "../Makefile.inc"
+.include <bsd.init.mk>
 
 .PATH:	${S}/compat/common
 
@@ -12,10 +12,14 @@ CPPFLAGS+=	-DCOMPAT_40 -DCOMPAT_50 -DCOM
 SRCS+=	compat_13_mod.c
 SRCS+=	uvm_13.c kern_sig_13.c
 
-.if ${MACHINE_ARCH} == "x86_64"
-.PATH:	${S}/arch/amd64/amd64
+COMPAT_MACHDEP_SRCS=	compat_13_machdep.c
 
-SRCS+=	compat_13_machdep.c
+.if ${MACHINE_CPU} == "m68k"
+.include "../Makefile.assym"
+
+COMPAT_MACHDEP_SRCS+=	compat_13_sigreturn13.s
+COPTS.compat_13_sigreturn13.s+=	-I. -x assembler-with-cpp
 .endif
 
+.include "../Makefile.compat"
 .include <bsd.kmodule.mk>

Index: src/sys/modules/compat_16/Makefile
diff -u src/sys/modules/compat_16/Makefile:1.2 src/sys/modules/compat_16/Makefile:1.2.32.1
--- src/sys/modules/compat_16/Makefile:1.2	Sun Jan 27 02:08:44 2019
+++ src/sys/modules/compat_16/Makefile	Sat Jun 22 11:11:53 2024
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile,v 1.2 2019/01/27 02:08:44 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.2.32.1 2024/06/22 11:11:53 martin Exp $
 
-.include "../Makefile.inc"
+.include <bsd.init.mk>
 
 .PATH:	${S}/compat/common
 
@@ -12,4 +12,17 @@ CPPFLAGS+=	-DCOMPAT_40 -DCOMPAT_50 -DCOM
 SRCS+=	compat_16_mod.c
 SRCS+=	kern_sig_16.c
 
+COMPAT_MACHDEP_SRCS=	compat_16_machdep.c
+.if ${MACHINE_CPU} == "m68k"
+.include "../Makefile.assym"
+
+COMPAT_MACHDEP_SRCS+=	compat_16_sigreturn14.s
+COPTS.compat_16_sigreturn14.s+=	-I. -x assembler-with-cpp
+.endif
+.if ${MACHINE_CPU} == "powerpc"
+COMPAT_MACHDEP_SRCS+=	sigcode.S
+.endif
+
+.include "../Makefile.compat"
+
 .include <bsd.kmodule.mk>

Index: src/sys/modules/compat_netbsd32_13/Makefile
diff -u src/sys/modules/compat_netbsd32_13/Makefile:1.4 src/sys/modules/compat_netbsd32_13/Makefile:1.4.26.1
--- src/sys/modules/compat_netbsd32_13/Makefile:1.4	Thu Sep 26 02:01:03 2019
+++ src/sys/modules/compat_netbsd32_13/Makefile	Sat Jun 22 11:11:53 2024
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile,v 1.4 2019/09/26 02:01:03 christos Exp $
+#	$NetBSD: Makefile,v 1.4.26.1 2024/06/22 11:11:53 martin Exp $
 
-.include "../Makefile.inc"
+.include <bsd.init.mk>
 
 .PATH:	${S}/compat/netbsd32
 
@@ -13,14 +13,8 @@ CPPFLAGS+=	-I${NETBSDSRCDIR}/sys/externa
 
 SRCS+=	netbsd32_compat_13.c
 
-.if ${MACHINE_ARCH} == "x86_64"
-.PATH:  ${S}/arch/amd64/amd64
-SRCS+=  netbsd32_machdep_13.c
-.endif
-
-.if ${MACHINE_ARCH} == "arm"
-.PATH:	${S}/arch/arm/arm32
-SRCS+=  netbsd32_machdep_13.c
-.endif
+COMPAT_MACHDEP_SRCS=	netbsd32_machdep_13.c
+
+.include "../Makefile.compat"
 
 .include <bsd.kmodule.mk>

Index: src/sys/modules/compat_netbsd32_16/Makefile
diff -u src/sys/modules/compat_netbsd32_16/Makefile:1.4 src/sys/modules/compat_netbsd32_16/Makefile:1.4.26.1
--- src/sys/modules/compat_netbsd32_16/Makefile:1.4	Thu Sep 26 02:01:03 2019
+++ src/sys/modules/compat_netbsd32_16/Makefile	Sat Jun 22 11:11:52 2024
@@ -1,6 +1,7 @@
-#	$NetBSD: Makefile,v 1.4 2019/09/26 02:01:03 christos Exp $
+#	$NetBSD: Makefile,v 1.4.26.1 2024/06/22 11:11:52 martin Exp $
+
+.include <bsd.init.mk>
 
-.include "../Makefile.inc"
 .include "../Makefile.assym"
 
 .PATH:	${S}/compat/netbsd32
@@ -14,15 +15,11 @@ CPPFLAGS+=	-I${NETBSDSRCDIR}/sys/externa
 
 SRCS+=	netbsd32_compat_16.c
 
-.if ${MACHINE_ARCH} == "x86_64"
-.PATH:  ${S}/arch/amd64/amd64
-SRCS+=  netbsd32_sigcode.S
-SRCS+=	netbsd32_machdep_16.c
+COMPAT_MACHDEP_SRCS=	netbsd32_machdep_16.c
+.if ${MACHINE_CPU} == "powerpc" || ${MACHINE_CPU} == "x86_64"
+COMPAT_MACHDEP_SRCS+=	netbsd32_sigcode.S
 .endif
 
-.if ${MACHINE_ARCH} == "arm"
-.PATH:	${S}/arch/arm/arm32
-SRCS+=	netbsd32_machdep_16.c
-.endif
+.include "../Makefile.compat"
 
 .include <bsd.kmodule.mk>

Added files:

Index: src/sys/modules/Makefile.compat
diff -u /dev/null src/sys/modules/Makefile.compat:1.1.2.2
--- /dev/null	Sat Jun 22 11:11:54 2024
+++ src/sys/modules/Makefile.compat	Sat Jun 22 11:11:53 2024
@@ -0,0 +1,18 @@
+#	$NetBSD: Makefile.compat,v 1.1.2.2 2024/06/22 11:11:53 martin Exp $
+
+COMPAT_ARCH=	${MACHINE_CPU:C/x86_64/amd64/}
+
+.if empty(KMOD:Mnetbsd32)
+COMPAT_SUBDIR=	${COMPAT_ARCH}
+.else
+COMPAT_SUBDIR=	${COMPAT_ARCH:C/arm/arm32/}
+.endif
+
+COMPAT_PATH=	${S}/arch/${COMPAT_ARCH}/${COMPAT_SUBDIR}
+
+.for _s in ${COMPAT_MACHDEP_SRCS}
+.if exists(${COMPAT_PATH}/${_s})
+.PATH:	${COMPAT_PATH}
+SRCS+=	${_s}
+.endif
+.endfor

Reply via email to