From 1864ac41fb2d58402c0db0bed6fa0074ffdfca5a Mon Sep 17 00:00:00 2001
From: Andrew Johnson <anj@aps.anl.gov>
Date: Mon, 30 Jul 2012 17:50:30 -0500
Subject: [PATCH] Add support for native linux-arm builds.

---
 configure/os/CONFIG.Common.linux-arm         |  2 +-
 configure/os/CONFIG.linux-arm.Common         | 10 ++++++++++
 configure/os/CONFIG.linux-arm.linux-arm      | 10 ++++++++++
 configure/os/CONFIG_SITE.linux-arm.linux-arm |  7 +++++++
 configure/os/CONFIG_SITE.linux-x86.linux-arm |  8 +++++---
 src/tools/mkmf.pl                            |  0
 startup/EpicsHostArch                        | 19 +++++++++++--------
 startup/EpicsHostArch.pl                     |  7 ++++---
 8 files changed, 48 insertions(+), 15 deletions(-)
 create mode 100644 configure/os/CONFIG.linux-arm.Common
 create mode 100644 configure/os/CONFIG.linux-arm.linux-arm
 create mode 100644 configure/os/CONFIG_SITE.linux-arm.linux-arm
 mode change 100755 => 100644 src/tools/mkmf.pl

diff --git a/configure/os/CONFIG.Common.linux-arm b/configure/os/CONFIG.Common.linux-arm
index 15dad9e9e8..7ccb1bbad0 100644
--- a/configure/os/CONFIG.Common.linux-arm
+++ b/configure/os/CONFIG.Common.linux-arm
@@ -17,7 +17,7 @@ ifeq ($(BUILD_CLASS),CROSS)
 
     # prefix of compiler tools
     CMPLR_SUFFIX =
-    CMPLR_PREFIX = $(addsuffix -,$(GNU_TARGET))
+    CMPLR_PREFIX = $(GNU_TARGET)-
 
     # Provide a link-time path for shared libraries
     SHRLIBDIR_RPATH_LDFLAGS_YES += $(SHRLIB_DEPLIB_DIRS:%=-Wl,-rpath-link,%)
diff --git a/configure/os/CONFIG.linux-arm.Common b/configure/os/CONFIG.linux-arm.Common
new file mode 100644
index 0000000000..788f594d73
--- /dev/null
+++ b/configure/os/CONFIG.linux-arm.Common
@@ -0,0 +1,10 @@
+# CONFIG.linux-arm.Common
+#
+# $Revision-Id$
+#
+# Definitions for linux-arm host builds
+# Sites may override these definitions in CONFIG_SITE.linux-arm.Common
+#-------------------------------------------------------
+
+#Include definitions common to unix hosts
+include $(CONFIG)/os/CONFIG.UnixCommon.Common
diff --git a/configure/os/CONFIG.linux-arm.linux-arm b/configure/os/CONFIG.linux-arm.linux-arm
new file mode 100644
index 0000000000..e52660f144
--- /dev/null
+++ b/configure/os/CONFIG.linux-arm.linux-arm
@@ -0,0 +1,10 @@
+# CONFIG.linux-arm.linux-arm
+#
+# $Revision-Id$
+#
+# Definitions for native linux-arm builds
+# Sites may override these definitions in CONFIG_SITE.linux-arm.linux-arm
+#-------------------------------------------------------
+
+# Include common gnu compiler definitions
+include $(CONFIG)/CONFIG.gnuCommon
diff --git a/configure/os/CONFIG_SITE.linux-arm.linux-arm b/configure/os/CONFIG_SITE.linux-arm.linux-arm
new file mode 100644
index 0000000000..a8cc0ff9f0
--- /dev/null
+++ b/configure/os/CONFIG_SITE.linux-arm.linux-arm
@@ -0,0 +1,7 @@
+#  CONFIG_SITE.linux-arm.linux-arm
+#
+# $Revision-Id$
+#
+# Site specific definitions for native linux-arm builds
+#-------------------------------------------------------
+
diff --git a/configure/os/CONFIG_SITE.linux-x86.linux-arm b/configure/os/CONFIG_SITE.linux-x86.linux-arm
index 726d38578a..f27a6a0cd0 100644
--- a/configure/os/CONFIG_SITE.linux-x86.linux-arm
+++ b/configure/os/CONFIG_SITE.linux-x86.linux-arm
@@ -5,8 +5,10 @@
 # Site specific definitions for linux-x86 host - linux-arm target builds
 #-------------------------------------------------------
 
-# Diamond:
+# Tools install path
 #GNU_DIR = /home/targetOS/linux-arm/host/x86-linux/gcc_3.3.3
 
-# anj@aps:
-#GNU_DIR = /local/anj/cross-arm/gcc-3.4.5-glibc-2.3.6/arm-linux
+GNU_DIR = /net/phoebus/vw/zynq-2011.09
+
+# GNU crosscompiler target name
+GNU_TARGET = arm-xilinx-linux-gnueabi
diff --git a/src/tools/mkmf.pl b/src/tools/mkmf.pl
old mode 100755
new mode 100644
diff --git a/startup/EpicsHostArch b/startup/EpicsHostArch
index 6b102b9b91..8861ac56c9 100755
--- a/startup/EpicsHostArch
+++ b/startup/EpicsHostArch
@@ -24,21 +24,24 @@ case $sysname in
     Linux )
         os=linux
         cpu=`uname -m`
-        case $cpu in i386 | i486 | i586 | i686 )
-            cpu=x86
-            ;;
+        case $cpu in
+            i386 | i486 | i586 | i686 )
+                cpu=x86 ;;
+            x86_64 )
+                ;; # $cpu is correct
+            armv6l | armv7l )
+                cpu=arm ;;
         esac
-        if [ ${cpu} = "x86_64" ]; then
-            cpu=x86_64
-        fi
         echo ${os}-${cpu}${suffix}
         ;;
     Darwin )
         os=darwin
         cpu=`uname -m`
         case $cpu in
-            "Power Macintosh") cpu=ppc ;;
-            i386 | x86_64 ) cpu=x86 ;;
+            "Power Macintosh")
+                cpu=ppc ;;
+            i386 | x86_64 )
+                cpu=x86 ;;
         esac
         echo ${os}-${cpu}${suffix}
         ;;
diff --git a/startup/EpicsHostArch.pl b/startup/EpicsHostArch.pl
index 7fb5747c8b..1c4a96dcb7 100755
--- a/startup/EpicsHostArch.pl
+++ b/startup/EpicsHostArch.pl
@@ -24,10 +24,11 @@ print "$EpicsHostArch$suffix";
 
 sub GetEpicsHostArch { # no args
     $arch=$Config{'archname'};
-    if ($arch =~ /sun4-solaris/)       { return "solaris-sparc";
+    if ($arch =~ /sun4-solaris/)        { return "solaris-sparc";
     } elsif ($arch =~ m/i86pc-solaris/) { return "solaris-x86";
-    } elsif ($arch =~ m/i[3-6]86-linux/)    { return "linux-x86";
-    } elsif ($arch =~ m/x86_64-linux/)    { return "linux-x86_64";
+    } elsif ($arch =~ m/i[3-6]86-linux/){ return "linux-x86";
+    } elsif ($arch =~ m/x86_64-linux/)  { return "linux-x86_64";
+    } elsif ($arch =~ m/arm-linux/)     { return "linux-arm";
     } elsif ($arch =~ m/MSWin32-x86/)   { return "win32-x86";
     } elsif ($arch =~ m/cygwin/)        { return "cygwin-x86";
     } elsif ($arch =~ m/darwin/)        {
-- 
GitLab