Description: add support for s390x arch.
Author: Gilles Filippini <pini@debian.org>
Forwarded: sgothel@jausoft.com
Last-Update: 2023-03-15

--- /dev/null
+++ b/make/scripts/make.gluegen.all.linux-s390x.sh
@@ -0,0 +1,24 @@
+#! /bin/sh
+
+#    -Dc.compiler.debug=true \
+#    -Dgluegen.cpptasks.detected.os=true \
+#    -DisUnix=true \
+#    -DisLinux=true \
+#    -DisLinuxX86=true \
+#    -DisX11=true \
+
+MACHINE=s390x
+ARCH=s390x
+TRIPLET=s390x-linux-gnu
+
+export TARGET_PLATFORM_LIBS=/usr/lib/$TRIPLET
+export TARGET_JAVA_LIBS=/usr/lib/jvm/java-7-openjdk-$ARCH/jre/lib/$MACHINE
+
+export GLUEGEN_CPPTASKS_FILE="lib/gluegen-cpptasks-linux-$MACHINE.xml"
+
+#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org"
+export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet"
+
+ant \
+    -Drootrel.build=build-linux-$MACHINE \
+    $* 2>&1 | tee make.gluegen.all.linux-$MACHINE.log
--- a/src/java/jogamp/common/os/PlatformPropsImpl.java
+++ b/src/java/jogamp/common/os/PlatformPropsImpl.java
@@ -581,6 +581,7 @@
      *   <li>linux-ia64</li>
      *   <li>linux-sparcv9</li>
      *   <li>linux-risc2.0</li>
+     *   <li>linux-s390x</li>
      *   <li>freebsd-i586</li>
      *   <li>freebsd-amd64</li>
      *   <li>hpux-hppa</li>
@@ -647,6 +648,9 @@
             case PA_RISC2_0:
                 _and_arch_tmp = "risc2.0";
                 break;
+            case S390X:
+                _and_arch_tmp = "s390x";
+                break;
             default:
                 throw new InternalError("Unhandled CPUType: "+cpuType);
         }
--- a/src/java/jogamp/common/os/elf/ElfHeaderPart1.java
+++ b/src/java/jogamp/common/os/elf/ElfHeaderPart1.java
@@ -412,6 +412,15 @@
                 cpuName = "ppc64";
                 abiType = ABIType.GENERIC_ABI;
                 break;
+            case EM_S390:
+                 // Can be 32 or 64 bits
+                if( 64 == getArchClassBits() ) {
+                    cpuName = "s390x";
+                } else {
+                    cpuName = "s390";
+                }
+                abiType = ABIType.GENERIC_ABI;
+                break;
             case EM_SH:
                 cpuName = "superh";
                 abiType = ABIType.GENERIC_ABI;
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -77,7 +77,9 @@
         /** Itanium */
         IA64,
         /** Hitachi SuperH */
-        SuperH;
+        SuperH,
+        /** IBM ESA/390 and zSystems */
+        S390;
     }
 
     public enum CPUType {
@@ -118,9 +120,13 @@
         /** SPARC 64bit, big endian */
         SPARCV9_64(CPUFamily.SPARC,   false),
         /** PA_RISC2_0 64bit, ??? endian */
-        PA_RISC2_0(CPUFamily.PA_RISC, false);
+        PA_RISC2_0(CPUFamily.PA_RISC, false),
         // 17
 
+        /** S390X 64bit big endian */
+        S390X(CPUFamily.S390, true);
+	// 18
+
         public final CPUFamily family;
         public final boolean is32Bit;
 
@@ -201,6 +207,8 @@
                 return MIPS_32;
             } else if( cpuABILower.startsWith("superh") ) {
                 return SuperH;
+            } else if( cpuABILower.equals("s390x") ) {
+                return S390X;
             } else {
                 throw new RuntimeException("Please port CPUType detection to your platform (CPU_ABI string '" + cpuABILower + "')");
             }
