From dd2a939767e693c366792141de35045734fb4fc0 Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru <sylvestre.ledru@scilab.org>
Date: Mon, 28 Mar 2011 15:08:30 +0200
Subject: [PATCH 2/2] Enable the gluegen2 build under GNU/Linux ARMEL, HPPA, MIPS, MIPSEL, PPC, S390 & SPARC (implemented for debian)

---
 make/build.xml                 |   50 +++++++++++-
 make/gluegen-cpptasks-base.xml |  188 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 232 insertions(+), 6 deletions(-)

diff --git a/make/build.xml b/make/build.xml
index 6e5a6ac..667eadc 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -272,7 +272,55 @@
       <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
     </target>
 
-    <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64,declare.linux.ia64" if="isLinux" >
+    <target name="declare.linux.alpha" if="isLinuxAlpha">
+      <echo message="Linux.alpha" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
+    </target>
+
+    <target name="declare.linux.armel" if="isLinuxArmel">
+      <echo message="Linux.armael" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
+    </target>
+
+    <target name="declare.linux.hppa" if="isLinuxHPPA">
+      <echo message="Linux.hppa" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
+    </target>
+
+    <target name="declare.linux.mips" if="isLinuxMIPS">
+      <echo message="Linux.mips" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
+    </target>
+
+    <target name="declare.linux.mipsel" if="isLinuxMIPSEL">
+      <echo message="Linux.mipsel" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
+    </target>
+
+    <target name="declare.linux.ppc" if="isLinuxPPC">
+      <echo message="Linux.ppc" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
+    </target>
+
+    <target name="declare.linux.s390" if="isLinuxS390">
+      <echo message="Linux.s390" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
+    </target>
+
+    <target name="declare.linux.sparc" if="isLinuxSparc">
+      <echo message="Linux.sparc" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
+    </target>
+
+    <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64,declare.linux.ia64,declare.linux.alpha,declare.linux.armel,declare.linux.hppa,declare.linux.mips,declare.linux.mipsel,declare.linux.ppc,declare.linux.s390,declare.linux.sparc" if="isLinux" >
       <property name="c.src.dir.os"                         value="unix" />
       <property name="java.includes.dir.platform"           value="${java.includes.dir}/linux" />
     </target>
diff --git a/make/gluegen-cpptasks-base.xml b/make/gluegen-cpptasks-base.xml
index 444bce1..e0aad25 100755
--- a/make/gluegen-cpptasks-base.xml
+++ b/make/gluegen-cpptasks-base.xml
@@ -24,6 +24,14 @@
    -   isLinuxAMD64
    -   isLinuxIA64
    -   isLinuxX86
+   -   isLinuxAlpha
+   -   isLinuxArmel
+   -   isLinuxHPPA
+   -   isLinuxMIPS
+   -   isLinuxMIPSEL
+   -   isLinuxPPC
+   -   isLinuxS390
+   -   isLinuxSparc
    -   isOSX
    -   isOSXPPC
    -   isSolaris
@@ -242,6 +250,78 @@
     <condition property="isIA64">
       <os arch="IA64" />
     </condition>
+    <condition property="isLinuxAlpha">
+      <and>
+        <istrue value="${isLinux}" />
+        <os arch="alpha" />
+      </and>
+    </condition>
+    <condition property="alpha">
+      <os arch="alpha" />
+    </condition>
+    <condition property="isLinuxArmel">
+      <and>
+        <istrue value="${isLinux}" />
+        <os arch="arm" />
+      </and>
+    </condition>
+    <condition property="arm">
+      <os arch="arm" />
+    </condition>
+    <condition property="isLinuxHPPA">
+      <and>
+        <istrue value="${isLinux}" />
+        <os arch="hppa" />
+      </and>
+    </condition>
+    <condition property="hppa">
+      <os arch="hppa" />
+    </condition>
+    <condition property="isLinuxMIPS">
+      <and>
+        <istrue value="${isLinux}" />
+        <os arch="mips" />
+      </and>
+    </condition>
+    <condition property="mips">
+      <os arch="mips" />
+    </condition>
+    <condition property="isLinuxMIPSEL">
+      <and>
+        <istrue value="${isLinux}" />
+        <os arch="mipsel" />
+      </and>
+    </condition>
+    <condition property="mipsel">
+      <os arch="mipsel" />
+    </condition>
+    <condition property="isLinuxPPC">
+      <and>
+        <istrue value="${isLinux}" />
+        <os arch="ppc" />
+      </and>
+    </condition>
+    <condition property="ppc">
+      <os arch="ppc" />
+    </condition>
+    <condition property="isLinuxS390">
+      <and>
+        <istrue value="${isLinux}" />
+        <os arch="s390" />
+      </and>
+    </condition>
+    <condition property="s390">
+      <os arch="s390" />
+    </condition>
+    <condition property="isLinuxSparc">
+      <and>
+        <istrue value="${isLinux}" />
+        <os arch="sparc" />
+      </and>
+    </condition>
+    <condition property="sparc">
+      <os arch="sparc" />
+    </condition>
     <condition property="isSolaris32Bit">
       <and>
          <istrue value="${isSolaris}" />
@@ -311,6 +391,14 @@
     <echo message="LinuxAMD64=${isLinuxAMD64}" />
     <echo message="LinuxIA64=${isLinuxIA64}" />
     <echo message="LinuxX86=${isLinuxX86}" />
+    <echo message="LinuxAlpha=${isLinuxAlpha}" />
+    <echo message="LinuxArmel=${isLinuxArmel}" />
+    <echo message="LinuxHPPA=${isLinuxHPPA}" />
+    <echo message="LinuxMIPS=${isLinuxMIPS}" />
+    <echo message="LinuxMIPSEL=${isLinuxMIPSEL}" />
+    <echo message="LinuxPPC=${isLinuxPPC}" />
+    <echo message="LinuxS390=${isLinuxS390}" />
+    <echo message="LinuxSparc=${isLinuxSparc}" />
     <echo message="OS X=${isOSX}" />
     <echo message="OS X PPC=${use.macosppc}" />
     <echo message="OS X x32=${use.macosx32}" />
@@ -324,6 +412,9 @@
     <echo message="Unix=${isUnix}" />
     <echo message="Windows=${isWindows}" />
     <echo message="X11=${isX11}" />
+    <echo message="os=${os.name}" />
+    <echo message="os=${os.version}" />
+    <echo message="arch=${os.arch}" />
   </target>
 
   <target name="gluegen.cpptasks.detect.os.freebsd.x86" unless="gluegen.cpptasks.detected.os.2" if="isFreeBSDX86">
@@ -352,7 +443,39 @@
     <property name="os.and.arch" value="linux-i586" />
   </target>
 
-  <target name="gluegen.cpptasks.detect.os.linux" depends="gluegen.cpptasks.detect.os.linux.amd64,gluegen.cpptasks.detect.os.linux.ia64,gluegen.cpptasks.detect.os.linux.x86" unless="gluegen.cpptasks.detected.os.2" />
+  <target name="gluegen.cpptasks.detect.os.linux.alpha" unless="gluegen.cpptasks.detected.os.2" if="isLinuxAlpha">
+    <property name="os.and.arch" value="linux-alpha" />
+  </target>
+
+  <target name="gluegen.cpptasks.detect.os.linux.armel" unless="gluegen.cpptasks.detected.os.2" if="isLinuxArmel">
+    <property name="os.and.arch" value="linux-armel" />
+  </target>
+
+  <target name="gluegen.cpptasks.detect.os.linux.hppa" unless="gluegen.cpptasks.detected.os.2" if="isLinuxHPPA">
+    <property name="os.and.arch" value="linux-hppa" />
+  </target>
+
+  <target name="gluegen.cpptasks.detect.os.linux.mips" unless="gluegen.cpptasks.detected.os.2" if="isLinuxMIPS">
+    <property name="os.and.arch" value="linux-mips" />
+  </target>
+
+  <target name="gluegen.cpptasks.detect.os.linux.mipsel" unless="gluegen.cpptasks.detected.os.2" if="isLinuxMIPSEL">
+    <property name="os.and.arch" value="linux-mipsel" />
+  </target>
+
+  <target name="gluegen.cpptasks.detect.os.linux.ppc" unless="gluegen.cpptasks.detected.os.2" if="isLinuxPPC">
+    <property name="os.and.arch" value="linux-ppc" />
+  </target>
+
+  <target name="gluegen.cpptasks.detect.os.linux.s390" unless="gluegen.cpptasks.detected.os.2" if="isLinuxS390">
+    <property name="os.and.arch" value="linux-s390" />
+  </target>
+
+  <target name="gluegen.cpptasks.detect.os.linux.sparc" unless="gluegen.cpptasks.detected.os.2" if="isLinuxSparc">
+    <property name="os.and.arch" value="linux-sparc" />
+  </target>
+
+  <target name="gluegen.cpptasks.detect.os.linux" depends="gluegen.cpptasks.detect.os.linux.amd64,gluegen.cpptasks.detect.os.linux.ia64,gluegen.cpptasks.detect.os.linux.x86,gluegen.cpptasks.detect.os.linux.alpha,gluegen.cpptasks.detect.os.linux.armel,gluegen.cpptasks.detect.os.linux.hppa,gluegen.cpptasks.detect.os.linux.mips,gluegen.cpptasks.detect.os.linux.mipsel,gluegen.cpptasks.detect.os.linux.ppc,gluegen.cpptasks.detect.os.linux.s390,gluegen.cpptasks.detect.os.linux.sparc" unless="gluegen.cpptasks.detected.os.2" />
 
   <target name="gluegen.cpptasks.detect.os.osx" unless="gluegen.cpptasks.detected.os.2" if="isOSX">
     <property name="native.library.suffix"     value="*lib" />
@@ -555,7 +678,6 @@
     <!-- UNIX compiler configuration -->
 
     <compiler id="compiler.cfg.linux" name="gcc">
-      <compilerarg value="-m32"/>
       <defineset>
         <define name="__unix__"/>
         <define name="_DEBUG"   if="c.compiler.use-debug"/>        
@@ -737,7 +859,7 @@
     <!-- Unix linker configuration -->
 
     <linker id="linker.cfg.linux" name="gcc">
-        <linkerarg value="-m32"/>
+<!--        <linkerarg value="-m32"/>-->
     </linker>
 
     <linker id="linker.cfg.linux.amd64" name="gcc">
@@ -888,12 +1010,68 @@
 
     <target name="gluegen.cpptasks.declare.compiler.linux.ia64" if="isLinuxIA64">
       <echo message="Linux.IA64" />
+      <property name="compiler.cfg.id.base"          value="compiler.cfg.linux.ia64" /> 
+      <property name="linker.cfg.id.base"            value="linker.cfg.linux.amd64" /> 
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/ia64" />
+    </target>
+
+    <target name="gluegen.cpptasks.declare.compiler.linux.alpha" if="isLinuxAlpha">
+      <echo message="Linux.Alpha" />
+      <property name="compiler.cfg.id.base"          value="compiler.cfg.linux.amd64" /> 
+      <property name="linker.cfg.id.base"            value="linker.cfg.linux.amd64" /> 
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/alpha" />
+    </target>
+
+    <target name="gluegen.cpptasks.declare.compiler.linux.armel" if="isLinuxArmel">
+      <echo message="Linux.armel" />
       <property name="compiler.cfg.id.base"          value="compiler.cfg.linux" /> 
       <property name="linker.cfg.id.base"            value="linker.cfg.linux" /> 
-      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/ia64" />
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/arm/" />
+    </target>
+
+    <target name="gluegen.cpptasks.declare.compiler.linux.hppa" if="isLinuxHPPA">
+      <echo message="Linux.hppa" />
+      <property name="compiler.cfg.id.base"          value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id.base"            value="linker.cfg.linux" /> 
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/hppa" />
+    </target>
+
+    <target name="gluegen.cpptasks.declare.compiler.linux.mips" if="isLinuxMIPS">
+      <echo message="Linux.MIPS" />
+      <property name="compiler.cfg.id.base"          value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id.base"            value="linker.cfg.linux" /> 
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/mips" />
+    </target>
+
+    <target name="gluegen.cpptasks.declare.compiler.linux.mipsel" if="isLinuxMIPSEL">
+      <echo message="Linux.MIPSEL" />
+      <property name="compiler.cfg.id.base"          value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id.base"            value="linker.cfg.linux" /> 
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/mipsel" />
+    </target>
+
+    <target name="gluegen.cpptasks.declare.compiler.linux.ppc" if="isLinuxPPC">
+      <echo message="Linux.PPC" />
+      <property name="compiler.cfg.id.base"          value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id.base"            value="linker.cfg.linux" /> 
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/ppc" />
+    </target>
+
+    <target name="gluegen.cpptasks.declare.compiler.linux.s390" if="isLinuxS390">
+      <echo message="Linux.S390" />
+      <property name="compiler.cfg.id.base"          value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id.base"            value="linker.cfg.linux" /> 
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/s390" />
+    </target>
+
+    <target name="gluegen.cpptasks.declare.compiler.linux.sparc" if="isLinuxSparc">
+      <echo message="Linux.Sparc" />
+      <property name="compiler.cfg.id.base"          value="compiler.cfg.linux" /> 
+      <property name="linker.cfg.id.base"            value="linker.cfg.linux" /> 
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/" />
     </target>
 
-    <target name="gluegen.cpptasks.declare.compiler.linux" depends="gluegen.cpptasks.declare.compiler.linux.x86,gluegen.cpptasks.declare.compiler.linux.amd64,gluegen.cpptasks.declare.compiler.linux.ia64" if="isLinux">
+    <target name="gluegen.cpptasks.declare.compiler.linux" depends="gluegen.cpptasks.declare.compiler.linux.x86,gluegen.cpptasks.declare.compiler.linux.amd64,gluegen.cpptasks.declare.compiler.linux.ia64,gluegen.cpptasks.declare.compiler.linux.alpha,gluegen.cpptasks.declare.compiler.linux.armel,gluegen.cpptasks.declare.compiler.linux.hppa,gluegen.cpptasks.declare.compiler.linux.mips,gluegen.cpptasks.declare.compiler.linux.mipsel,gluegen.cpptasks.declare.compiler.linux.ppc,gluegen.cpptasks.declare.compiler.linux.s390,gluegen.cpptasks.declare.compiler.linux.sparc" if="isLinux">
         <property name="java.includes.dir.platform" value="${java.includes.dir}/linux" />
     </target>
 
-- 
1.7.4.1

