Index: build.sh
===================================================================
RCS file: /cvsroot/src/build.sh,v
retrieving revision 1.346
diff -u -p -u -r1.346 build.sh
--- build.sh	28 Jan 2021 10:36:27 -0000	1.346
+++ build.sh	24 Apr 2021 22:04:58 -0000
@@ -660,6 +660,8 @@ MACHINE=evbmips		MACHINE_ARCH=mips64eb	A
 MACHINE=evbmips		MACHINE_ARCH=mips64el	ALIAS=evbmips64-el
 MACHINE=evbmips		MACHINE_ARCH=mipseb	ALIAS=evbmips-eb
 MACHINE=evbmips		MACHINE_ARCH=mipsel	ALIAS=evbmips-el
+MACHINE=evbmips		MACHINE_ARCH=mipsn64eb	ALIAS=evbmipsn64-eb
+MACHINE=evbmips		MACHINE_ARCH=mipsn64el	ALIAS=evbmipsn64-el
 MACHINE=evbppc		MACHINE_ARCH=powerpc	DEFAULT
 MACHINE=evbppc		MACHINE_ARCH=powerpc64	ALIAS=evbppc64
 MACHINE=evbsh3		MACHINE_ARCH=		NO_DEFAULT
Index: common/lib/libc/arch/mips/atomic/Makefile.inc
===================================================================
RCS file: /cvsroot/src/common/lib/libc/arch/mips/atomic/Makefile.inc,v
retrieving revision 1.14
diff -u -p -u -r1.14 Makefile.inc
--- common/lib/libc/arch/mips/atomic/Makefile.inc	28 Feb 2019 02:35:37 -0000	1.14
+++ common/lib/libc/arch/mips/atomic/Makefile.inc	24 Apr 2021 22:04:59 -0000
@@ -3,7 +3,7 @@
 .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
 	|| ${LIB} == "rump")
 
-.if ${MACHINE_ARCH:Mmips64*} == ""
+.if !${MACHINE_MIPS64}
 SRCS+=	atomic_add_32_cas.c atomic_add_32_nv_cas.c \
 	atomic_and_32_cas.c atomic_and_32_nv_cas.c \
 	atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
@@ -30,7 +30,7 @@ SRCS+=	membar_ops.S
 
 .if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
 
-.if ${MACHINE_ARCH:Mmips64*} == ""
+.if !${MACHINE_MIPS64}
 SRCS+=	atomic_init_testset.c atomic_cas_up.S
 .else
 SRCS+=	atomic_cas.S atomic_init_cas.c atomic_cas_by_cas32.c
Index: distrib/cobalt/instkernel/Makefile
===================================================================
RCS file: /cvsroot/src/distrib/cobalt/instkernel/Makefile,v
retrieving revision 1.2
diff -u -p -u -r1.2 Makefile
--- distrib/cobalt/instkernel/Makefile	20 Feb 2011 08:26:08 -0000	1.2
+++ distrib/cobalt/instkernel/Makefile	24 Apr 2021 22:05:01 -0000
@@ -6,7 +6,7 @@
 RAMDISKDIR!=	cd ${.CURDIR}/../ramdisk && ${PRINTOBJDIR}
 RAMDISK=	${RAMDISKDIR}/ramdisk.fs
 
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 SFX=		64
 .endif
 
Index: distrib/evbmips/instkernel/instkernel/Makefile
===================================================================
RCS file: /cvsroot/src/distrib/evbmips/instkernel/instkernel/Makefile,v
retrieving revision 1.7
diff -u -p -u -r1.7 Makefile
--- distrib/evbmips/instkernel/instkernel/Makefile	15 Jul 2020 12:15:30 -0000	1.7
+++ distrib/evbmips/instkernel/instkernel/Makefile	24 Apr 2021 22:05:01 -0000
@@ -12,12 +12,12 @@ MDSETTARGETS=		INSTALL_CI20		${RAMDISK}	
 MDSETTARGETS+=		INSTALL_OMSAL400	${RAMDISK}	-
 MDSETTARGETS+=		INSTALL_MALTA		${RAMDISK}	-
 
-.elif ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el"
+.elif ${MACHINE_MIPS64}
 MDSETTARGETS=		INSTALL_MALTA32		${RAMDISK}	-
 MDSETTARGETS+=		INSTALL_MALTA64		${RAMDISK}	-
 MDSETTARGETS+=		INSTALL_XLSATX32	${RAMDISK}	-
 MDSETTARGETS+=		INSTALL_XLSATX64	${RAMDISK}	-
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 MDSETTARGETS+=		INSTALL_LOONGSON	${RAMDISK}	-
 .else
 MDSETTARGETS+=		INSTALL_OCTEON		${RAMDISK}	-
Index: distrib/evbmips/instkernel/ramdisk/Makefile
===================================================================
RCS file: /cvsroot/src/distrib/evbmips/instkernel/ramdisk/Makefile,v
retrieving revision 1.14
diff -u -p -u -r1.14 Makefile
--- distrib/evbmips/instkernel/ramdisk/Makefile	9 Jan 2020 20:07:46 -0000	1.14
+++ distrib/evbmips/instkernel/ramdisk/Makefile	24 Apr 2021 22:05:01 -0000
@@ -13,7 +13,7 @@ DBG=		-Os
 CRUNCHBIN=	ramdiskbin
 LISTS=		${.CURDIR}/list ${DISTRIBDIR}/common/list.sysinst
 MTREECONF=	${DISTRIBDIR}/common/mtree.common
-.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:M*el)
 IMAGEENDIAN=	le
 .else
 IMAGEENDIAN=	be
Index: distrib/pmax/instkernel/Makefile
===================================================================
RCS file: /cvsroot/src/distrib/pmax/instkernel/Makefile,v
retrieving revision 1.44
diff -u -p -u -r1.44 Makefile
--- distrib/pmax/instkernel/Makefile	16 Aug 2020 11:43:36 -0000	1.44
+++ distrib/pmax/instkernel/Makefile	24 Apr 2021 22:05:02 -0000
@@ -5,7 +5,7 @@
 
 .include <bsd.kernobj.mk>
 
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 SFX=		64
 .endif
 
Index: distrib/pmax/miniroot/Makefile.inc
===================================================================
RCS file: /cvsroot/src/distrib/pmax/miniroot/Makefile.inc,v
retrieving revision 1.25
diff -u -p -u -r1.25 Makefile.inc
--- distrib/pmax/miniroot/Makefile.inc	24 Jan 2017 18:04:04 -0000	1.25
+++ distrib/pmax/miniroot/Makefile.inc	24 Apr 2021 22:05:02 -0000
@@ -1,6 +1,6 @@
 #	$NetBSD: Makefile.inc,v 1.25 2017/01/24 18:04:04 christos Exp $
 
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 SFX=		64
 .endif
 
Index: distrib/pmax/ramdisk/Makefile
===================================================================
RCS file: /cvsroot/src/distrib/pmax/ramdisk/Makefile,v
retrieving revision 1.54
diff -u -p -u -r1.54 Makefile
--- distrib/pmax/ramdisk/Makefile	7 Sep 2020 09:05:10 -0000	1.54
+++ distrib/pmax/ramdisk/Makefile	24 Apr 2021 22:05:02 -0000
@@ -5,7 +5,7 @@
 
 IMAGE=		ramdisk.fs
 IMAGETAR=	diskimage.tgz
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 IMAGESIZE=	4500k
 .else
 IMAGESIZE=	4200k
Index: etc/etc.cobalt/Makefile.inc
===================================================================
RCS file: /cvsroot/src/etc/etc.cobalt/Makefile.inc,v
retrieving revision 1.5
diff -u -p -u -r1.5 Makefile.inc
--- etc/etc.cobalt/Makefile.inc	20 Feb 2011 08:27:32 -0000	1.5
+++ etc/etc.cobalt/Makefile.inc	24 Apr 2021 22:05:02 -0000
@@ -6,7 +6,7 @@
 # If you change the list of distributed kernels, don't forget
 # to update the release documentation in distrib/notes/common/contents
 
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 KERNEL_SETS=		GENERIC32 GENERIC64 INSTALL32 INSTALL64
 
 BUILD_KERNELS=		RAMDISK32 RAMDISK64
Index: etc/etc.evbmips/Makefile.inc
===================================================================
RCS file: /cvsroot/src/etc/etc.evbmips/Makefile.inc,v
retrieving revision 1.25
diff -u -p -u -r1.25 Makefile.inc
--- etc/etc.evbmips/Makefile.inc	15 Aug 2020 05:03:06 -0000	1.25
+++ etc/etc.evbmips/Makefile.inc	24 Apr 2021 22:05:02 -0000
@@ -15,12 +15,12 @@ BUILD_KERNELS=		INSTALL_CI20 INSTALL_OMS
 
 KERNEL_SETS+=		P4032 P5064 P6032
 
-.elif ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el"
+.elif ${MACHINE_MIPS64}
 KERNEL_SETS=		MALTA32 MALTA64 XLSATX32 XLSATX64
 BUILD_KERNELS=		INSTALL_MALTA32 INSTALL_MALTA64
 BUILD_KERNELS+=		INSTALL_XLSATX32 INSTALL_XLSATX64
 
-. if ${MACHINE_ARCH} == "mips64el"
+. if !empty(MACHINE_ARCH:Mmips*64el)
 KERNEL_SETS+=		P5064-64
 KERNEL_SETS+=		LOONGSON
 BUILD_KERNELS+=		INSTALL_LOONGSON
@@ -68,7 +68,7 @@ __mkimage: .USE
             -S ${NETBSDSRCDIR} -B ${IMAGEENDIAN} ${MKI_OPTS.${.TARGET}} \
             ${IMAGE.dir}/${.TARGET:S/smp_//}.img.gz
 
-.if ${MACHINE_ARCH} == "mips64eb"
+.if !empty(MACHINE_ARCH:Mmips*64eb)
 smp_octeon: __mkimage
 MKI_OPTS.smp_octeon=	-K ${IMAGE.kern}
 SNAP_MD_POST_DEPS+=	smp_octeon
Index: etc/mtree/Makefile
===================================================================
RCS file: /cvsroot/src/etc/mtree/Makefile,v
retrieving revision 1.44
diff -u -p -u -r1.44 Makefile
--- etc/mtree/Makefile	12 Jun 2020 14:12:20 -0000	1.44
+++ etc/mtree/Makefile	24 Apr 2021 22:05:02 -0000
@@ -9,7 +9,7 @@ EXTRA_DIST_FILES+=	NetBSD.dist.Xorg
 .endif
 
 # Derived from MACHINE_CPU, but keeping 32/64bit for most.
-MTREE_MACHINE_ARCH=${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips64/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/arm.*/arm/:C/earm.*/arm/:S/earm/arm/:S/aarch64eb/aarch64/:S/or1knd/or1k/}
+MTREE_MACHINE_ARCH=${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips64/:C/mipsn64e[bl]/mips64/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/arm.*/arm/:C/earm.*/arm/:S/earm/arm/:S/aarch64eb/aarch64/:S/or1knd/or1k/}
 
 # The compat specific files
 
Index: external/apache2/llvm/include/Makefile
===================================================================
RCS file: /cvsroot/src/external/apache2/llvm/include/Makefile,v
retrieving revision 1.1
diff -u -p -u -r1.1 Makefile
--- external/apache2/llvm/include/Makefile	11 Nov 2019 22:45:02 -0000	1.1
+++ external/apache2/llvm/include/Makefile	24 Apr 2021 22:05:04 -0000
@@ -101,7 +101,7 @@ INCS=	arm_acle.h \
 .  if ${MACHINE_CPU} == "aarch64"
 INCS+=	arm64intr.h
 .  endif
-.elif ${MACHINE_CPU} == "mips" || ${MACHINE_CPU} == "mips64"
+.elif ${MACHINE_CPU} == "mips"
 INCS=	msa.h
 .endif
 INCS+=	stdatomic.h
Index: external/gpl3/binutils/dist/config.sub
===================================================================
RCS file: /cvsroot/src/external/gpl3/binutils/dist/config.sub,v
retrieving revision 1.14
diff -u -p -u -r1.14 config.sub
--- external/gpl3/binutils/dist/config.sub	3 Apr 2020 23:48:45 -0000	1.14
+++ external/gpl3/binutils/dist/config.sub	24 Apr 2021 22:05:48 -0000
@@ -1191,6 +1191,7 @@ case $cpu-$vendor in
 			| mips | mipsbe | mipseb | mipsel | mipsle \
 			| mips16 \
 			| mips64 | mips64eb | mips64el \
+			| mipsn64 | mipsn64eb | mipsn64el \
 			| mips64octeon | mips64octeonel \
 			| mips64orion | mips64orionel \
 			| mips64r5900 | mips64r5900el \
Index: external/gpl3/binutils/dist/gas/configure
===================================================================
RCS file: /cvsroot/src/external/gpl3/binutils/dist/gas/configure,v
retrieving revision 1.9
diff -u -p -u -r1.9 configure
--- external/gpl3/binutils/dist/gas/configure	3 Apr 2020 23:48:47 -0000	1.9
+++ external/gpl3/binutils/dist/gas/configure	24 Apr 2021 22:05:48 -0000
@@ -12689,7 +12689,7 @@ _ACEOF
       mips)
 	# Set mips_cpu to the name of the default CPU.
 	case ${target_cpu} in
-	  mips | mipsbe | mipseb | mipsle | mipsel | mips64 | mips64el)
+	  mips | mipsbe | mipseb | mipsle | mipsel | mips64 | mips64el | mips64eb | mipsn64el | mipsn64eb)
 	    mips_cpu=from-abi
 	    ;;
 	  mipsisa32 | mipsisa32el)
Index: external/gpl3/binutils/dist/gas/configure.ac
===================================================================
RCS file: /cvsroot/src/external/gpl3/binutils/dist/gas/configure.ac,v
retrieving revision 1.7
diff -u -p -u -r1.7 configure.ac
--- external/gpl3/binutils/dist/gas/configure.ac	3 Apr 2020 23:48:47 -0000	1.7
+++ external/gpl3/binutils/dist/gas/configure.ac	24 Apr 2021 22:05:48 -0000
@@ -292,7 +292,7 @@ changequote([,])dnl
       mips)
 	# Set mips_cpu to the name of the default CPU.
 	case ${target_cpu} in
-	  mips | mipsbe | mipseb | mipsle | mipsel | mips64 | mips64el)
+	  mips | mipsbe | mipseb | mipsle | mipsel | mips64 | mips64el | mips64eb | mipsn64el | mipsn64eb )
 	    mips_cpu=from-abi
 	    ;;
 	  mipsisa32 | mipsisa32el)
Index: external/gpl3/binutils/dist/ld/configure.tgt
===================================================================
RCS file: /cvsroot/src/external/gpl3/binutils/dist/ld/configure.tgt,v
retrieving revision 1.35
diff -u -p -u -r1.35 configure.tgt
--- external/gpl3/binutils/dist/ld/configure.tgt	13 Sep 2020 21:14:01 -0000	1.35
+++ external/gpl3/binutils/dist/ld/configure.tgt	24 Apr 2021 22:05:48 -0000
@@ -506,10 +506,18 @@ mips*-sgi-irix6*)	targ_emul=elf32bmipn32
 mips64*el-*-netbsd*)	targ_emul=elf32ltsmipn32 	 
 			targ_extra_emuls="elf64btsmip elf64ltsmip elf32ltsmip elf32btsmipn32 elf32btsmip" 	 
 			targ_extra_libpath=$targ_extra_emuls
+			;;
+mipsn64*el-*-netbsd*)	targ_emul=elf64ltsmip
+			targ_extra_emuls="elf64btsmip elf64ltsmip elf32ltsmip elf32btsmip elf32btsmipn32 elf32ltsmip32"
+			targ_extra_libpath=$targ_extra_emuls
 			;; 	 
 mips64*-*-netbsd*)	targ_emul=elf32btsmipn32
 			targ_extra_emuls="elf64ltsmip elf64btsmip elf32btsmip elf32ltsmipn32 elf32ltsmip"
 			targ_extra_libpath=$targ_extra_emuls
+			;;
+mipsn64*-*-netbsd*)	targ_emul=elf64btsmip
+			targ_extra_emuls="elf64ltsmip elf64btsmip elf32ltsmip elf32btsmip elf32ltsmipn32 elf32btsmipn32"
+			targ_extra_libpath=$targ_extra_emuls
   			;;
 mips*el-*-netbsd*)	targ_emul=elf32ltsmip
 			targ_extra_emuls="elf32btsmip elf64ltsmip elf64btsmip"
Index: external/gpl3/binutils/usr.bin/ld/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/binutils/usr.bin/ld/Makefile,v
retrieving revision 1.33
diff -u -p -u -r1.33 Makefile
--- external/gpl3/binutils/usr.bin/ld/Makefile	4 Apr 2020 01:34:30 -0000	1.33
+++ external/gpl3/binutils/usr.bin/ld/Makefile	24 Apr 2021 22:05:48 -0000
@@ -79,7 +79,8 @@ e${f}.c: ${DIST}/ld/genscripts.sh ${.CUR
     !empty(BINUTILS_MACHINE_ARCH:Maarch64*) || \
     !empty(BINUTILS_MACHINE_ARCH:Mearm*) || \
     !empty(BINUTILS_MACHINE_ARCH:Marm*) || \
-    !empty(BINUTILS_MACHINE_ARCH:Mmips64*)
+    !empty(BINUTILS_MACHINE_ARCH:Mmips64*) || \
+    !empty(BINUTILS_MACHINE_ARCH:Mmipsn64*)
 .  for e in x xbn xc xd xdc xdw xn xr xs xsc xsw xu xw
 .   if exists(ldscripts/${f}.${e})
 FILES+= ${f}.${e}
Index: external/gpl3/binutils.old/usr.bin/ld/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/binutils.old/usr.bin/ld/Makefile,v
retrieving revision 1.8
diff -u -p -u -r1.8 Makefile
--- external/gpl3/binutils.old/usr.bin/ld/Makefile	3 Apr 2020 17:51:43 -0000	1.8
+++ external/gpl3/binutils.old/usr.bin/ld/Makefile	24 Apr 2021 22:05:49 -0000
@@ -78,7 +78,8 @@ e${f}.c: ${DIST}/ld/genscripts.sh ${.CUR
     !empty(BINUTILS_MACHINE_ARCH:Maarch64*) || \
     !empty(BINUTILS_MACHINE_ARCH:Mearm*) || \
     !empty(BINUTILS_MACHINE_ARCH:Marm*) || \
-    !empty(BINUTILS_MACHINE_ARCH:Mmips64*)
+    !empty(BINUTILS_MACHINE_ARCH:Mmips64*) || \
+    !empty(BINUTILS_MACHINE_ARCH:Mmipsn64*)
 .  for e in x xbn xc xd xdc xdw xn xr xs xsc xsw xu xw
 .   if exists(ldscripts/${f}.${e})
 FILES+= ${f}.${e}
Index: external/gpl3/gcc/dist/config.sub
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/dist/config.sub,v
retrieving revision 1.16
diff -u -p -u -r1.16 config.sub
--- external/gpl3/gcc/dist/config.sub	11 Apr 2021 00:02:10 -0000	1.16
+++ external/gpl3/gcc/dist/config.sub	24 Apr 2021 22:05:49 -0000
@@ -1191,6 +1191,7 @@ case $cpu-$vendor in
 			| mips | mipsbe | mipseb | mipsel | mipsle \
 			| mips16 \
 			| mips64 | mips64eb | mips64el \
+			| mipsn64 | mipsn64eb | mipsn64el \
 			| mips64octeon | mips64octeonel \
 			| mips64orion | mips64orionel \
 			| mips64r5900 | mips64r5900el \
Index: external/gpl3/gcc/dist/gcc/config.gcc
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/dist/gcc/config.gcc,v
retrieving revision 1.68
diff -u -p -u -r1.68 config.gcc
--- external/gpl3/gcc/dist/gcc/config.gcc	12 Apr 2021 09:03:39 -0000	1.68
+++ external/gpl3/gcc/dist/gcc/config.gcc	24 Apr 2021 22:05:49 -0000
@@ -2570,6 +2570,13 @@ riscv*-*-netbsd*)			# NetBSD RISC-V
 	gas=yes
 	gcc_cv_initfini_array=yes
 	;;
+mipsn64*-*-netbsd*)			# NetBSD/mips64, either endian.
+	target_cpu_default="MASK_ABICALLS|MASK_FLOAT64|MASK_SOFT_FLOAT_ABI"
+	tm_file="elfos.h ${tm_file} mips/elf.h ${nbsd_tm_file} mips/netbsd.h mips/netbsd64.h"
+	tmake_file="${tmake_file} mips/t-netbsd64"
+	tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_64"
+	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
+	;;
 mips64*-*-netbsd*)			# NetBSD/mips64, either endian.
 	target_cpu_default="MASK_ABICALLS|MASK_FLOAT64|MASK_SOFT_FLOAT_ABI"
 	tm_file="elfos.h ${tm_file} mips/elf.h ${nbsd_tm_file} mips/netbsd.h mips/netbsd64.h"
Index: external/gpl3/gcc/dist/gcc/config/mips/netbsd64.h
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/dist/gcc/config/mips/netbsd64.h,v
retrieving revision 1.5
diff -u -p -u -r1.5 netbsd64.h
--- external/gpl3/gcc/dist/gcc/config/mips/netbsd64.h	29 Mar 2021 01:33:12 -0000	1.5
+++ external/gpl3/gcc/dist/gcc/config/mips/netbsd64.h	24 Apr 2021 22:05:49 -0000
@@ -22,11 +22,19 @@ Boston, MA 02110-1301, USA.  */
 /* Force the default endianness and ABI flags onto the command line
    in order to make the other specs easier to write.  */
 
+#if MIPS_ABI_DEFAULT == ABI_N32
+# define MIPS64_ABI "%{!mabi=*: -mabi=n32}"
+# elif MIPS_ABI_DEFAULT == ABI_64
+# define MIPS64_ABI "%{!mabi=*: -mabi=64}"
+#else
+# error "Missing MIPS_ABI_DEFAULT " # MIPS_ABI_DEFAULT
+#endif
+
 #undef DRIVER_SELF_SPECS
 #define DRIVER_SELF_SPECS \
   BASE_DRIVER_SELF_SPECS \
   "%{!EB:%{!EL:%(endian_spec)}}", \
-  "%{!mabi=*: -mabi=n32}"
+  MIPS64_ABI
 
 /* Define default target values.  */
 
Index: external/gpl3/gcc/dist/libgcc/config.host
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/dist/libgcc/config.host,v
retrieving revision 1.30
diff -u -p -u -r1.30 config.host
--- external/gpl3/gcc/dist/libgcc/config.host	17 Apr 2021 10:53:18 -0000	1.30
+++ external/gpl3/gcc/dist/libgcc/config.host	24 Apr 2021 22:05:49 -0000
@@ -1056,7 +1056,7 @@ mipsr5900-*-elf* | mipsr5900el-*-elf*)
 	tmake_file="$tmake_file mips/t-elf mips/t-crtstuff"
 	extra_parts="$extra_parts crti.o crtn.o"
 	;;
-mips64-*-elf* | mips64el-*-elf*)
+mips64-*-elf* | mips64el-*-elf* | mipsn64-*-elf* | mipsn64el-*-elf*)
 	tmake_file="$tmake_file mips/t-elf mips/t-crtstuff mips/t-mips16"
 	extra_parts="$extra_parts crti.o crtn.o"
 	;;
Index: external/gpl3/gcc/lib/crtstuff/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/lib/crtstuff/Makefile,v
retrieving revision 1.14
diff -u -p -u -r1.14 Makefile
--- external/gpl3/gcc/lib/crtstuff/Makefile	15 Mar 2016 19:21:27 -0000	1.14
+++ external/gpl3/gcc/lib/crtstuff/Makefile	24 Apr 2021 22:05:52 -0000
@@ -66,7 +66,7 @@ ${OBJS}: ${DPSRCS}
 	${CC} ${CPPFLAGS} ${CPPFLAGS.${.TARGET}} ${GCFLAGS} ${COPTS} ${COPTS.${.TARGET}} ${CPUFLAGS} -c ${.IMPSRC} -o ${.TARGET}.o
 	mv ${.TARGET}.o ${.TARGET}
 
-.if (${MACHINE_ARCH} == "mips64eb") || (${MACHINE_ARCH} == "mips64el")
+.if ${MACHINE_MIPS64}
 # Turn off as(1) warnings on MIPS, since warnings are fatal with WARNS>0
 # and GCC configury passes -finhibit-size-directive which causes mips-gas
 # to barf.  Don't know what the real fix for this is...
Index: external/gpl3/gcc/lib/libgcc/Makefile.inc
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/lib/libgcc/Makefile.inc,v
retrieving revision 1.50
diff -u -p -u -r1.50 Makefile.inc
--- external/gpl3/gcc/lib/libgcc/Makefile.inc	24 Apr 2021 06:34:52 -0000	1.50
+++ external/gpl3/gcc/lib/libgcc/Makefile.inc	24 Apr 2021 22:05:52 -0000
@@ -69,7 +69,8 @@ LIB2FUNCS_ALL+= \
 .if ${LIBGCC_MACHINE_ARCH} != "coldfire" && \
     empty(LIBGCC_MACHINE_ARCH:Mearm*) && \
     empty(LIBGCC_MACHINE_ARCH:Maarch64*) && \
-    empty(LIBGCC_MACHINE_ARCH:Mmips64*)
+    empty(LIBGCC_MACHINE_ARCH:Mmips64*) && \
+    empty(LIBGCC_MACHINE_ARCH:Mmipsn64*)
 
 EXTRA_FUNC_SIZES=	sf df xf
 
Index: external/gpl3/gcc/lib/libgcc/libgcc_s/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/lib/libgcc/libgcc_s/Makefile,v
retrieving revision 1.15
diff -u -p -u -r1.15 Makefile
--- external/gpl3/gcc/lib/libgcc/libgcc_s/Makefile	12 Apr 2021 00:05:55 -0000	1.15
+++ external/gpl3/gcc/lib/libgcc/libgcc_s/Makefile	24 Apr 2021 22:05:52 -0000
@@ -29,7 +29,7 @@ LIB2ADD_HACK+=	${GNUHOSTDIST}/gcc/config
 .endif
 
 # XXXGCC5 GCC 5.3 has all these in libgcc and we have them in libc.
-.if ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb"
+.if ${MACHINE_MIPS64}
 LIB2ADD_EDITED= ${G_LIB2ADD:T:Nfloatsisf.c:Nfloatunsisf.c:Nfloatsidf.c:Nfloatunsidf.c:Nfixsfsi.c:Nextendsfdf2.c:Naddsf3.c:Nmulsf3.c:Ndivsf3.c:Nadddf3.c:Nsubdf3.c:Nmuldf3.c:Ndivdf3.c:Nfixdfsi.c:S/.asm/.S/}
 .else
 LIB2ADD_EDITED=	${G_LIB2ADD:T:S/.asm/.S/}
Index: external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/Makefile,v
retrieving revision 1.5
diff -u -p -u -r1.5 Makefile
--- external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/Makefile	9 Feb 2019 02:36:56 -0000	1.5
+++ external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/Makefile	24 Apr 2021 22:05:53 -0000
@@ -1,6 +1,7 @@
 #	$NetBSD: Makefile,v 1.5 2019/02/09 02:36:56 mrg Exp $
 
 # install multilib c++config.h files
+.include <bsd.init.mk>
 
 .if ${MACHINE_ARCH} == "sparc64"
 SUBDIR=		sparc sparc64
@@ -12,7 +13,7 @@ SUBDIR=		i386 x86_64
 CXXCONFIGARGS=	x86_64 _LP64 i386
 .endif
 
-.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el"
+.if ${MACHINE_MIPS64}
 SUBDIR=		mips64 mips32 mipso32
 CXXCONFIGARGS=	mips64 _ABI64 mipso32 _ABIO32 mips32
 .endif
Index: external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/mipso32/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/mipso32/Makefile,v
retrieving revision 1.1
diff -u -p -u -r1.1 Makefile
--- external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/mipso32/Makefile	1 Mar 2014 10:00:48 -0000	1.1
+++ external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/mipso32/Makefile	24 Apr 2021 22:05:53 -0000
@@ -4,4 +4,4 @@ GCC_MACHINE_ARCH=mipso32
 .include "../Makefile.arch_bits"
 
 # mips o32 files are in mipse[lb] subdirs.
-.PATH: ${.CURDIR}/../../../../arch/${MACHINE_ARCH:S/64//}
+.PATH: ${.CURDIR}/../../../../arch/${MACHINE_ARCH:S/mipsn/mips/:S/64//}
Index: external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/riscv64/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/riscv64/Makefile,v
retrieving revision 1.1
diff -u -p -u -r1.1 Makefile
--- external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/riscv64/Makefile	19 Sep 2014 17:23:24 -0000	1.1
+++ external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/riscv64/Makefile	24 Apr 2021 22:05:53 -0000
@@ -3,5 +3,5 @@
 GCC_MACHINE_ARCH=riscv64
 .include "../Makefile.arch_bits"
 
-# mips64 files are in mips64e[lb] subdirs.
+# riscv64 files are in riscv64 subdirs.
 .PATH: ${.CURDIR}/../../../../arch/${MACHINE_ARCH}
Index: external/gpl3/gcc/lib/libtsan/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc/lib/libtsan/Makefile,v
retrieving revision 1.15
diff -u -p -u -r1.15 Makefile
--- external/gpl3/gcc/lib/libtsan/Makefile	14 Sep 2020 15:01:58 -0000	1.15
+++ external/gpl3/gcc/lib/libtsan/Makefile	24 Apr 2021 22:05:53 -0000
@@ -52,7 +52,7 @@ TSAN_SRCS= \
 TSAN_SRCS+= tsan_rtl_amd64.S
 .elif ${MACHINE_ARCH} == "aarch64"
 TSAN_SRCS+= tsan_rtl_aarch64.S
-.elif ${MACHINE_ARCH} == "mips64el"
+.elif ${MACHINE_MIPS64}
 TSAN_SRCS+= tsan_rtl_mips64.S
 .elif ${MACHINE_ARCH} == "powerpc64"
 TSAN_SRCS+= tsan_rtl_ppc64.S
Index: external/gpl3/gcc.old/lib/crtstuff/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc.old/lib/crtstuff/Makefile,v
retrieving revision 1.9
diff -u -p -u -r1.9 Makefile
--- external/gpl3/gcc.old/lib/crtstuff/Makefile	9 Apr 2021 23:15:14 -0000	1.9
+++ external/gpl3/gcc.old/lib/crtstuff/Makefile	24 Apr 2021 22:05:54 -0000
@@ -66,7 +66,7 @@ ${OBJS}: ${DPSRCS}
 	${CC} ${CPPFLAGS} ${CPPFLAGS.${.TARGET}} ${GCFLAGS} ${COPTS} ${COPTS.${.TARGET}} ${CPUFLAGS} -c ${.IMPSRC} -o ${.TARGET}.o
 	mv ${.TARGET}.o ${.TARGET}
 
-.if (${MACHINE_ARCH} == "mips64eb") || (${MACHINE_ARCH} == "mips64el")
+.if ${MACHINE_MIPS64}
 # Turn off as(1) warnings on MIPS, since warnings are fatal with WARNS>0
 # and GCC configury passes -finhibit-size-directive which causes mips-gas
 # to barf.  Don't know what the real fix for this is...
Index: external/gpl3/gcc.old/lib/libgcc/Makefile.inc
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc.old/lib/libgcc/Makefile.inc,v
retrieving revision 1.14
diff -u -p -u -r1.14 Makefile.inc
--- external/gpl3/gcc.old/lib/libgcc/Makefile.inc	9 Apr 2021 23:15:20 -0000	1.14
+++ external/gpl3/gcc.old/lib/libgcc/Makefile.inc	24 Apr 2021 22:05:54 -0000
@@ -67,7 +67,8 @@ LIB2FUNCS_ALL+= \
 .if ${LIBGCC_MACHINE_ARCH} != "coldfire" && \
     empty(LIBGCC_MACHINE_ARCH:Mearm*) && \
     empty(LIBGCC_MACHINE_ARCH:Maarch64*) && \
-    empty(LIBGCC_MACHINE_ARCH:Mmips64*)
+    empty(LIBGCC_MACHINE_ARCH:Mmips64*) && \
+    empty(LIBGCC_MACHINE_ARCH:Mmipsn64*)
 
 EXTRA_FUNC_SIZES=	sf df xf
 
Index: external/gpl3/gcc.old/lib/libgcc/libgcc_s/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc.old/lib/libgcc/libgcc_s/Makefile,v
retrieving revision 1.9
diff -u -p -u -r1.9 Makefile
--- external/gpl3/gcc.old/lib/libgcc/libgcc_s/Makefile	9 Apr 2021 23:15:23 -0000	1.9
+++ external/gpl3/gcc.old/lib/libgcc/libgcc_s/Makefile	24 Apr 2021 22:05:54 -0000
@@ -29,7 +29,7 @@ LIB2ADD_HACK+=	${GNUHOSTDIST}/gcc/config
 .endif
 
 # XXXGCC5 GCC 5.3 has all these in libgcc and we have them in libc.
-.if ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb"
+.if ${MACHINE_MIPS64}
 LIB2ADD_EDITED= ${G_LIB2ADD:T:Nfloatsisf.c:Nfloatunsisf.c:Nfloatsidf.c:Nfloatunsidf.c:Nfixsfsi.c:Nextendsfdf2.c:Naddsf3.c:Nmulsf3.c:Ndivsf3.c:Nadddf3.c:Nsubdf3.c:Nmuldf3.c:Ndivdf3.c:Nfixdfsi.c:S/.asm/.S/}
 .else
 LIB2ADD_EDITED=	${G_LIB2ADD:T:S/.asm/.S/}
Index: external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/Makefile,v
retrieving revision 1.8
diff -u -p -u -r1.8 Makefile
--- external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/Makefile	9 Apr 2021 23:15:48 -0000	1.8
+++ external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/Makefile	24 Apr 2021 22:05:54 -0000
@@ -12,7 +12,7 @@ SUBDIR=		i386 x86_64
 CXXCONFIGARGS=	x86_64 _LP64 i386
 .endif
 
-.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el"
+.if ${MACHINE_MIPS64}
 SUBDIR=		mips64 mips32 mipso32
 CXXCONFIGARGS=	mips64 _ABI64 mipso32 _ABIO32 mips32
 .endif
Index: external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/riscv64/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/riscv64/Makefile,v
retrieving revision 1.7
diff -u -p -u -r1.7 Makefile
--- external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/riscv64/Makefile	9 Apr 2021 23:15:49 -0000	1.7
+++ external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/riscv64/Makefile	24 Apr 2021 22:05:54 -0000
@@ -3,5 +3,5 @@
 GCC_MACHINE_ARCH=riscv64
 .include "../Makefile.arch_bits"
 
-# mips64 files are in mips64e[lb] subdirs.
+# riscv64 files are in riscv64 subdirs.
 .PATH: ${.CURDIR}/../../../../arch/${MACHINE_ARCH}
Index: external/gpl3/gcc.old/lib/libtsan/Makefile
===================================================================
RCS file: /cvsroot/src/external/gpl3/gcc.old/lib/libtsan/Makefile,v
retrieving revision 1.10
diff -u -p -u -r1.10 Makefile
--- external/gpl3/gcc.old/lib/libtsan/Makefile	9 Apr 2021 23:15:51 -0000	1.10
+++ external/gpl3/gcc.old/lib/libtsan/Makefile	24 Apr 2021 22:05:54 -0000
@@ -52,7 +52,7 @@ TSAN_SRCS= \
 TSAN_SRCS+= tsan_rtl_amd64.S
 .elif ${MACHINE_ARCH} == "aarch64"
 TSAN_SRCS+= tsan_rtl_aarch64.S
-.elif ${MACHINE_ARCH} == "mips64el"
+.elif ${MACHINE_MIPS64}
 TSAN_SRCS+= tsan_rtl_mips64.S
 .elif ${MACHINE_ARCH} == "powerpc64"
 TSAN_SRCS+= tsan_rtl_ppc64.S
Index: external/gpl3/gdb/dist/config.sub
===================================================================
RCS file: /cvsroot/src/external/gpl3/gdb/dist/config.sub,v
retrieving revision 1.12
diff -u -p -u -r1.12 config.sub
--- external/gpl3/gdb/dist/config.sub	15 Sep 2020 02:05:15 -0000	1.12
+++ external/gpl3/gdb/dist/config.sub	24 Apr 2021 22:05:54 -0000
@@ -1191,6 +1191,7 @@ case $cpu-$vendor in
 			| mips | mipsbe | mipseb | mipsel | mipsle \
 			| mips16 \
 			| mips64 | mips64eb | mips64el \
+			| mipsn64 | mipsn64eb | mipsn64el \
 			| mips64octeon | mips64octeonel \
 			| mips64orion | mips64orionel \
 			| mips64r5900 | mips64r5900el \
Index: external/lgpl3/mpfr/lib/libmpfr/Makefile
===================================================================
RCS file: /cvsroot/src/external/lgpl3/mpfr/lib/libmpfr/Makefile,v
retrieving revision 1.21
diff -u -p -u -r1.21 Makefile
--- external/lgpl3/mpfr/lib/libmpfr/Makefile	26 Sep 2020 07:50:41 -0000	1.21
+++ external/lgpl3/mpfr/lib/libmpfr/Makefile	24 Apr 2021 22:06:06 -0000
@@ -297,14 +297,15 @@ CPPFLAGS+=	-I${MPFRDIST}/src
 CPPFLAGS+=	-DHAVE_LDOUBLE_IEEE_EXT_LITTLE=1
 .endif
 
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 CPPFLAGS+=	-DHAVE_LDOUBLE_IEEE_QUAD_LITTLE=1
 .endif
 
 .if ${MACHINE_ARCH} == "sparc64" || \
     ${MACHINE_ARCH} == "powerpc" || \
     ${MACHINE_ARCH} == "powerpc64" || \
-    ${MACHINE_ARCH} == "mips64eb"
+    ${MACHINE_ARCH} == "mips64eb" || \
+    ${MACHINE_ARCH} == "mipsn64eb"
 CPPFLAGS+=	-DHAVE_LDOUBLE_IEEE_QUAD_BIG=1
 .endif
 
Index: external/mit/xorg/lib/pixman/Makefile
===================================================================
RCS file: /cvsroot/src/external/mit/xorg/lib/pixman/Makefile,v
retrieving revision 1.36
diff -u -p -u -r1.36 Makefile
--- external/mit/xorg/lib/pixman/Makefile	15 Sep 2020 05:14:19 -0000	1.36
+++ external/mit/xorg/lib/pixman/Makefile	24 Apr 2021 22:06:09 -0000
@@ -90,7 +90,7 @@ AFLAGS+=	${${ACTIVE_CC} == "clang" :? -f
 #CPPFLAGS+=	-DUSE_ARM_IWMMXT
 .endif
 
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 # Loongson MMI
 SRCS+=		pixman-mmx.c
 CPPFLAGS+=	-DUSE_LOONGSON_MMI
Index: lib/Makefile
===================================================================
RCS file: /cvsroot/src/lib/Makefile,v
retrieving revision 1.291
diff -u -p -u -r1.291 Makefile
--- lib/Makefile	9 Apr 2021 20:49:05 -0000	1.291
+++ lib/Makefile	24 Apr 2021 22:06:10 -0000
@@ -40,7 +40,7 @@ LIBC_MACHINE_CPU?=${MACHINE_CPU}
 SUBDIR+=	libc_vfp
 .endif
 .endif
-.if ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb"
+.if ${MACHINE_MIPS64}
 SUBDIR+=	libc_fp
 .endif
 .if (${MKRUMP} != "no")
Index: lib/libc/arch/mips/Makefile.inc
===================================================================
RCS file: /cvsroot/src/lib/libc/arch/mips/Makefile.inc,v
retrieving revision 1.14
diff -u -p -u -r1.14 Makefile.inc
--- lib/libc/arch/mips/Makefile.inc	24 Jan 2016 15:55:34 -0000	1.14
+++ lib/libc/arch/mips/Makefile.inc	24 Apr 2021 22:06:10 -0000
@@ -14,13 +14,11 @@ CPPFLAGS+= -DSOFTFLOAT
 
 SRCS+=	fixunsgen_ieee754.c
 SRCS+=	fixunsgen64_ieee754.c #fixunssfdi.c fixunsdfdi.c
-.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el") \
-    && (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32))
+.if ${MACHINE_MIPS64} && (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32))
 SRCS+=	fixunstfsi_ieee754.c fixunstfdi_ieee754.c
 .endif
 .endif
 
-.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el") \
-    && (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32))
+.if ${MACHINE_MIPS64} && (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32))
 SRCS+=	floatunditf_ieee754.c
 .endif
Index: lib/libc/arch/mips/gdtoa/Makefile.inc
===================================================================
RCS file: /cvsroot/src/lib/libc/arch/mips/gdtoa/Makefile.inc,v
retrieving revision 1.4
diff -u -p -u -r1.4 Makefile.inc
--- lib/libc/arch/mips/gdtoa/Makefile.inc	20 Jan 2011 18:41:39 -0000	1.4
+++ lib/libc/arch/mips/gdtoa/Makefile.inc	24 Apr 2021 22:06:10 -0000
@@ -1,7 +1,7 @@
 #	$NetBSD: Makefile.inc,v 1.4 2011/01/20 18:41:39 matt Exp $
 
 SRCS+=	strtof.c
-.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el")
+.if ${MACHINE_MIPS64}
 .if !defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32)
 SRCS+=	strtold_pQ.c
 SRCS+=	strtopQ.c
Index: lib/libm/Makefile
===================================================================
RCS file: /cvsroot/src/lib/libm/Makefile,v
retrieving revision 1.212
diff -u -p -u -r1.212 Makefile
--- lib/libm/Makefile	11 Nov 2019 22:45:27 -0000	1.212
+++ lib/libm/Makefile	24 Apr 2021 22:06:11 -0000
@@ -200,8 +200,7 @@ COMMON_SRCS += fenv.c
 COMMON_SRCS += fenv.c
 .endif
 COMMON_SRCS+= s_rintl.c
-.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el") \
-    && (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32))
+.if ${MACHINE_MIPS64} && (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32))
 COMMON_SRCS+= s_nexttoward.c
 .endif
 
Index: share/mk/bsd.own.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.own.mk,v
retrieving revision 1.1242
diff -u -p -u -r1.1242 bsd.own.mk
--- share/mk/bsd.own.mk	18 Apr 2021 20:32:49 -0000	1.1242
+++ share/mk/bsd.own.mk	24 Apr 2021 22:06:12 -0000
@@ -14,7 +14,12 @@ MAKECONF?=	/etc/mk.conf
 #
 # CPU model, derived from MACHINE_ARCH
 #
-MACHINE_CPU=	${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/arm.*/arm/:C/earm.*/arm/:S/earm/arm/:S/powerpc64/powerpc/:S/aarch64eb/aarch64/:S/or1knd/or1k/:C/riscv../riscv/}
+MACHINE_CPU=	${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/mipsn64e[bl]/mips/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/arm.*/arm/:C/earm.*/arm/:S/earm/arm/:S/powerpc64/powerpc/:S/aarch64eb/aarch64/:S/or1knd/or1k/:C/riscv../riscv/}
+
+MACHINE_MIPS64= (${MACHINE_ARCH} == "mips64el" || \
+		 ${MACHINE_ARCH} == "mips64eb" || \
+		 ${MACHINE_ARCH} == "mipsn64el" || \
+		 ${MACHINE_ARCH} == "mips64eb")
 
 #
 # Subdirectory used below ${RELEASEDIR} when building a release
@@ -1038,7 +1043,7 @@ MK${var}:=	yes
 # aarch64eb is not yet supported.
 #
 .if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "sparc64" \
-    || ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" \
+    || ${MACHINE_MIPS64}
     || ${MACHINE_ARCH} == "powerpc64" || ${MACHINE_ARCH} == "aarch64" \
     || ${MACHINE_ARCH} == "riscv64" || !empty(MACHINE_ARCH:Mearm*)
 MKCOMPAT?=	yes
@@ -1052,7 +1057,7 @@ MKCOMPATTESTS:=	no
 MKCOMPATX11:=	no
 .endif
 
-.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" \
+.if ${MACHINE_MIPS64} \
     || (${MACHINE} == "evbppc" && ${MACHINE_ARCH} == "powerpc")
 MKCOMPATMODULES?=	yes
 .else
@@ -1062,7 +1067,7 @@ MKCOMPATMODULES:=	no
 #
 # These platforms use softfloat by default.
 #
-.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el"
+.if ${MACHINE_MIPS64}
 MKSOFTFLOAT?=	yes
 .endif
 
Index: share/mk/bsd.sys.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.sys.mk,v
retrieving revision 1.304
diff -u -p -u -r1.304 bsd.sys.mk
--- share/mk/bsd.sys.mk	9 Nov 2020 16:15:05 -0000	1.304
+++ share/mk/bsd.sys.mk	24 Apr 2021 22:06:12 -0000
@@ -197,10 +197,12 @@ COPTS+=	${${ACTIVE_CC} == "gcc":? --para
 .if ${MACHINE_CPU} != "sh3"
 COPTS+=		${${ACTIVE_CC} == "gcc":? -msoft-float :}
 FOPTS+=		-msoft-float
+AFLAGS+=	-msoft-float
 .endif
 .elif ${MACHINE_ARCH} == "coldfire"
 COPTS+=		-mhard-float
 FOPTS+=		-mhard-float
+AFLAGS+=	-mhard-float
 .endif
 
 #.if !empty(MACHINE_ARCH:Mearmv7*)
@@ -220,7 +222,7 @@ CFLAGS+=	-Wa,-Av8plus
 .endif
 
 .if !defined(NOGCCERROR)
-.if (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
+.if ${MACHINE_MIPS64}
 CPUFLAGS+=	-Wa,--fatal-warnings
 .endif
 .endif
@@ -229,8 +231,7 @@ CPUFLAGS+=	-Wa,--fatal-warnings
 #CFLAGS+=	-mips64 -mtune=sb1
 #.endif
 
-#.if (${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb") && \
-#    (defined(MKPIC) && ${MKPIC} == "no")
+#.if ${MACHINE_MIPS64} && defined(MKPIC) && ${MKPIC} == "no"
 #CPUFLAGS+=	-mno-abicalls -fno-PIC
 #.endif
 CFLAGS+=	${CPUFLAGS}
Index: sys/arch/mips/conf/Makefile.mips
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/conf/Makefile.mips,v
retrieving revision 1.70
diff -u -p -u -r1.70 Makefile.mips
--- sys/arch/mips/conf/Makefile.mips	1 Jan 2019 19:41:04 -0000	1.70
+++ sys/arch/mips/conf/Makefile.mips	24 Apr 2021 22:06:12 -0000
@@ -54,7 +54,7 @@ AFLAGS.fp.S+=		-Wa,-mhard-float
 
 CFLAGS+=	${GP} -mno-abicalls -msoft-float -ffixed-24
 .if defined(LP64) && ${LP64} == "yes"
-.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el"
+.if ${MACHINE_MIPS64}
 CFLAGS+=	-msym32 -mabi=64
 AFLAGS+=	-msym32 -mabi=64
 .endif
@@ -65,7 +65,7 @@ SYSTEM_LD_TAIL_EXTRA+= \
 		;echo ${OBJCOPY} -O elf32-ntradbigmips $@ $@.elf32; \
 		${OBJCOPY} -O elf32-ntradbigmips $@ $@.elf32
 .endif
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 LDFLAGS+=	-Wl,-m,elf64ltsmip
 LINKFORMAT+=	-m elf64ltsmip
 SYSTEM_LD_TAIL_EXTRA+= \
@@ -96,7 +96,7 @@ locore_machdep.o: ${THISMIPS}/${MACHINE}
 ##
 ## (5) link settings
 ##
-.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el"
+.if ${MACHINE_MIPS64}
 TEXTADDR?=              ${DEFTEXTADDR:C/0x8/0xFFFFFFFF8/}
 .else   
 TEXTADDR?=		${DEFTEXTADDR}
Index: sys/arch/mips/include/mips_param.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/include/mips_param.h,v
retrieving revision 1.47
diff -u -p -u -r1.47 mips_param.h
--- sys/arch/mips/include/mips_param.h	26 Aug 2020 10:51:45 -0000	1.47
+++ sys/arch/mips/include/mips_param.h	24 Apr 2021 22:06:12 -0000
@@ -29,27 +29,28 @@
  * No reason this can't be common
  */
 #if defined(__MIPSEB__)
-# if defined(__mips_n32) || defined(__mips_n64)
-#  define	_MACHINE_ARCH	mips64eb
-#  define	MACHINE_ARCH	"mips64eb"
-#  define	_MACHINE32_ARCH	mipseb
-#  define	MACHINE32_ARCH	"mipseb"
-# else
-#  define	_MACHINE_ARCH	mipseb
-#  define	MACHINE_ARCH	"mipseb"
-# endif
+# define _MACHINE_SUFFIX eb
+# define MACHINE_SUFFIX "eb"
 #elif defined(__MIPSEL__)
-# if defined(__mips_n32) || defined(__mips_n64)
-#  define	_MACHINE_ARCH	mips64el
-#  define	MACHINE_ARCH	"mips64el"
-#  define	_MACHINE32_ARCH	mipsel
-#  define	MACHINE32_ARCH	"mipsel"
-# else
-#  define	_MACHINE_ARCH	mipsel
-#  define	MACHINE_ARCH	"mipsel"
-#endif
+# define _MACHINE_SUFFIX el
+# define MACHINE_SUFFIX "el"
 #else
-#error neither __MIPSEL__ nor __MIPSEB__ are defined.
+# error neither __MIPSEL__ nor __MIPSEB__ are defined.
+#endif
+
+#if defined(__mips_n32) || defined(__mips_n64)
+# if defined(__mips_n32)
+#  define	_MACHINE_ARCH	mips64##_MACHINE_SUFFIX
+#  define	MACHINE_ARCH	"mips64" MACHINE_SUFFIX
+# else /* __mips_n64 */
+#  define	_MACHINE_ARCH	mipsn64##_MACHINE_SUFFIX
+#  define	MACHINE_ARCH	"mipsn64" MACHINE_SUFFIX
+# endif
+# define	_MACHINE32_ARCH	mips##_MACHINE_SUFFIX
+# define	MACHINE32_ARCH	"mips" MACHINE_SUFFIX
+#else /* o32 */
+# define	_MACHINE_ARCH	mips##_MACHINE_SUFFIX
+# define	MACHINE_ARCH	"mips" MACHINE_SUFFIX
 #endif
 
 /*
Index: sys/arch/pmax/stand/Makefile.booters
===================================================================
RCS file: /cvsroot/src/sys/arch/pmax/stand/Makefile.booters,v
retrieving revision 1.64
diff -u -p -u -r1.64 Makefile.booters
--- sys/arch/pmax/stand/Makefile.booters	1 Jan 2019 19:41:04 -0000	1.64
+++ sys/arch/pmax/stand/Makefile.booters	24 Apr 2021 22:06:12 -0000
@@ -29,7 +29,7 @@ CFLAGS+=	-Wall -Wmissing-prototypes -Wst
 CFLAGS+=	-Werror
 LDBUG=		-T $S/arch/mips/conf/stand.ldscript
 
-.if ${MACHINE_ARCH} == "mips64el"
+.if !empty(MACHINE_ARCH:Mmips*64el)
 AFLAGS+=	-mips3 -mabi=32
 CFLAGS+=	-mips3 -mabi=32
 LDBUG+=		-m elf32ltsmip
Index: sys/modules/dtrace/Makefile
===================================================================
RCS file: /cvsroot/src/sys/modules/dtrace/Makefile,v
retrieving revision 1.9
diff -u -p -u -r1.9 Makefile
--- sys/modules/dtrace/Makefile	10 Apr 2021 15:34:05 -0000	1.9
+++ sys/modules/dtrace/Makefile	24 Apr 2021 22:06:14 -0000
@@ -5,7 +5,7 @@
 
 SUBDIR=		dtrace sdt fbt lockstat profile syscall
 
-.if ${MACHINE_ARCH} == "x86_64" || !empty(MACHINE_ARCH:Mmips64*)
+.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_MIPS64}
 SUBDIR+=	netbsd32_syscall
 .endif
 
Index: sys/rump/Makefile.rump
===================================================================
RCS file: /cvsroot/src/sys/rump/Makefile.rump,v
retrieving revision 1.131
diff -u -p -u -r1.131 Makefile.rump
--- sys/rump/Makefile.rump	13 Apr 2021 22:23:42 -0000	1.131
+++ sys/rump/Makefile.rump	24 Apr 2021 22:06:14 -0000
@@ -5,7 +5,7 @@
 _RUMP_MK= #defined
 
 WARNS?=		3	# XXX: src/sys won't compile with -Wsign-compare yet
-NOLINT=		# kernel code
+#NOLINT=		# kernel code
 
 .include <bsd.own.mk>
 
@@ -33,7 +33,7 @@ CFLAGS+=    ${${ACTIVE_CC} == "clang":? 
 # Define baseline cpu for mips ports, required for
 # rumpcomp_sync_icache() hypercall.
 .if !empty(MACHINE_ARCH:Mmips*)
-.if !empty(MACHINE_ARCH:Mmips64*)
+.if ${MACHINE_MIPS64}
 CPPFLAGS+=	-DMIPS64=1
 .else
 CPPFLAGS+=	-DMIPS1=1
Index: sys/rump/librump/rumpkern/arch/mips/Makefile.inc
===================================================================
RCS file: /cvsroot/src/sys/rump/librump/rumpkern/arch/mips/Makefile.inc,v
retrieving revision 1.3
diff -u -p -u -r1.3 Makefile.inc
--- sys/rump/librump/rumpkern/arch/mips/Makefile.inc	22 Apr 2015 20:10:56 -0000	1.3
+++ sys/rump/librump/rumpkern/arch/mips/Makefile.inc	24 Apr 2021 22:06:14 -0000
@@ -1,6 +1,8 @@
 # $NetBSD: Makefile.inc,v 1.3 2015/04/22 20:10:56 pooka Exp $
 
+.if empty(MACHINE_ARCH:Mmipsn64*)
 CPPFLAGS+=	-DARCH_ELFSIZE=32
+.endif
 
 .PATH:	${RUMPTOP}/librump/rumpkern/arch/generic
 SRCS+=	rump_generic_abi.c
Index: tools/Makefile
===================================================================
RCS file: /cvsroot/src/tools/Makefile,v
retrieving revision 1.207
diff -u -p -u -r1.207 Makefile
--- tools/Makefile	6 Feb 2021 16:14:55 -0000	1.207
+++ tools/Makefile	24 Apr 2021 22:06:15 -0000
@@ -180,8 +180,7 @@ SUBDIR+=	arm-elf2aout
 SUBDIR+=	m68k-elf2aout
 .endif
 
-.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
-     ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
+.if !empty(MACHINE_ARCH:Mmips*)
 SUBDIR+=	mips-elf2ecoff
 .endif
 
Index: usr.bin/ldd/Makefile.inc
===================================================================
RCS file: /cvsroot/src/usr.bin/ldd/Makefile.inc,v
retrieving revision 1.7
diff -u -p -u -r1.7 Makefile.inc
--- usr.bin/ldd/Makefile.inc	23 Jan 2016 21:22:49 -0000	1.7
+++ usr.bin/ldd/Makefile.inc	24 Apr 2021 22:06:15 -0000
@@ -17,7 +17,7 @@ MLIBDIR=	powerpc
 .endif
 
 # For now make "elf32" look for native (n32)
-.if (${MACHINE_ARCH} == "mips64eb") || (${MACHINE_ARCH} == "mips64el")
+.if !empty(MACHINE_ARCH:Mmips64*)
 MLIBDIR=	64
 COMPAT_MLIBDIR=	o32
 CPPFLAGS+= -DLDD_ELF64 -DMIPS_N32
Index: usr.bin/ldd/build/Makefile
===================================================================
RCS file: /cvsroot/src/usr.bin/ldd/build/Makefile,v
retrieving revision 1.6
diff -u -p -u -r1.6 Makefile
--- usr.bin/ldd/build/Makefile	4 Feb 2019 00:05:20 -0000	1.6
+++ usr.bin/ldd/build/Makefile	24 Apr 2021 22:06:15 -0000
@@ -18,7 +18,7 @@ CPPFLAGS.ldd.c+= -DELF64_ONLY
 .endif
 
 .if ${MKCOMPAT} != "no"
-. if (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
+. if ${MACHINE_MIPS64}
 LIB_ELF32COMPATDIR!=	cd ${.CURDIR}/../elf32_compat && ${PRINTOBJDIR}
 EXTRA_LIBS+=		${LIB_ELF32COMPATDIR}/libldd_elf32_compat.a
 . endif
Index: usr.bin/ldd/elf64/Makefile
===================================================================
RCS file: /cvsroot/src/usr.bin/ldd/elf64/Makefile,v
retrieving revision 1.12
diff -u -p -u -r1.12 Makefile
--- usr.bin/ldd/elf64/Makefile	4 Feb 2019 00:05:20 -0000	1.12
+++ usr.bin/ldd/elf64/Makefile	24 Apr 2021 22:06:15 -0000
@@ -41,7 +41,7 @@ CPPFLAGS+=	-D${_d}=_elf64_${_d}
 .endfor
 
 .if ${MKCOMPAT} != "no"
-. if (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
+. if ${MACHINE_MIPS64}
 CPPFLAGS+=	-DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
 . endif
 .endif