From ec4ded271264928aed99a1f35247de67d842bf0c Mon Sep 17 00:00:00 2001
From: Ger van Diepen <diepen@astron.nl>
Date: Wed, 5 Dec 2007 12:54:29 +0000
Subject: [PATCH] bug 1131: Use uname -m instead of arch Always use 2>&1 (and
 never >&) Accept -jn in rubbuild and pass it correctly to dorubbuild

---
 autoconf_share/dorubbuild        | 4 +++-
 autoconf_share/lofar_aips++.m4   | 2 +-
 autoconf_share/lofar_external.m4 | 2 +-
 autoconf_share/lofar_init.m4     | 2 +-
 autoconf_share/rub               | 2 +-
 autoconf_share/rubbuild          | 8 ++++++--
 6 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/autoconf_share/dorubbuild b/autoconf_share/dorubbuild
index 650f6729aac..0abf847ca49 100755
--- a/autoconf_share/dorubbuild
+++ b/autoconf_share/dorubbuild
@@ -36,6 +36,8 @@ skipbuilt=$1
 shift
 kopt=$1
 shift
+jobsopt=$1
+shift
 buildmake=$1
 shift
 conf=$1
@@ -147,7 +149,7 @@ for pkg in $pkgs
 do
   echo "" >> $logfile
   if [ $skipbuilt = 1 ]; then
-    fgrep "$pkg " $resfile >& /dev/null
+    fgrep "$pkg " $resfile 2>&1 > /dev/null
     if [ $? = 0 ]; then
       echo "  skipping package $pkg; already built in a previous run" | tee -a $logfile
       continue
diff --git a/autoconf_share/lofar_aips++.m4 b/autoconf_share/lofar_aips++.m4
index a1bf394b126..1d1938a8678 100644
--- a/autoconf_share/lofar_aips++.m4
+++ b/autoconf_share/lofar_aips++.m4
@@ -174,7 +174,7 @@ if [ "$lfr_use_casa" = 1 ]; then
     AIPSPP_CPPFLAGS="$AIPSPP_CPPFLAGS -DAIPS_NO_TEMPLATE_SRC"
   fi
   # Check if we're on a x86-64 bit system.
-  if test "`arch`" = "x86_64"; then
+  if test "`uname -m`" = "x86_64"; then
     AIPSPP_CPPFLAGS="$AIPSPP_CPPFLAGS -DAIPS_64B"
   fi
 
diff --git a/autoconf_share/lofar_external.m4 b/autoconf_share/lofar_external.m4
index a73ec5b4296..08cda0e3f1a 100644
--- a/autoconf_share/lofar_external.m4
+++ b/autoconf_share/lofar_external.m4
@@ -281,7 +281,7 @@ else
 
 ## Use different lib directory on 64 bit systems.
   lfr_libdext=lib
-  if test "`arch`" = "x86_64"; then
+  if test "`uname -m`" = "x86_64"; then
     lfr_libdext=lib64;
   fi
 ## Put possible version into the library names.
diff --git a/autoconf_share/lofar_init.m4 b/autoconf_share/lofar_init.m4
index 5809b0fd283..42ab86549ab 100644
--- a/autoconf_share/lofar_init.m4
+++ b/autoconf_share/lofar_init.m4
@@ -412,7 +412,7 @@ AC_CHECK_FILE([$lfr_find], [lfr_var=yes], [lfr_var=no])
   [fi]
 
   # Make sure that libraries are installed in lib64 on x86_64 architectures.
-  if test "`arch`" == "x86_64"; then
+  if test "`uname -m`" == "x86_64"; then
     if test "$libdir" = '${exec_prefix}/lib'; then
       libdir='${exec_prefix}/lib64'
       AC_SUBST(libdir, "$libdir")
diff --git a/autoconf_share/rub b/autoconf_share/rub
index a7dd467ad23..15de8636e14 100755
--- a/autoconf_share/rub
+++ b/autoconf_share/rub
@@ -725,7 +725,7 @@ if [ $boot != 0 ]; then
   for pkg in $pkgs
   do
     if [ $skipbuilt = 1 ]; then
-      fgrep "$pkg " build.result >& /dev/null
+      fgrep "$pkg " build.result 2>&1 > /dev/null
       if [ $? = 0 ]; then
         echo "  package $pkg already bootstrapped in a previous run" | tee build.log
         continue
diff --git a/autoconf_share/rubbuild b/autoconf_share/rubbuild
index 2d6b76376c8..99f5932b630 100755
--- a/autoconf_share/rubbuild
+++ b/autoconf_share/rubbuild
@@ -190,6 +190,10 @@ do
     shift
   else
     case "$1" in
+    -j*)
+      jobsopt='-j'`echo $1 | sed -e 's/-j//'`
+      shift
+      ;;
     -*)
       echo "$1 is an unknown rubbuild option"
       exit 1
@@ -284,8 +288,8 @@ fi
 # dorubbuild writes the build output to a log file.
 if [ $bg = 1 ]; then
   echo "Building packages on `uname -n` in $buildvarpr in the background"
-  $pgmpath/dorubbuild "$srcdir" "$builddir" "$variant" "$skipbuilt" "$kopt" "$buildmake" "$conf" "$confopt" "$clean" "$bldtest" "$check" "$checktool" "$install" "$dist" "$distcheck" "$rpm" $pkgs >> /dev/null 2>&1 &
+  $pgmpath/dorubbuild "$srcdir" "$builddir" "$variant" "$skipbuilt" "$kopt" "$jobsopt" "$buildmake" "$conf" "$confopt" "$clean" "$bldtest" "$check" "$checktool" "$install" "$dist" "$distcheck" "$rpm" $pkgs >> /dev/null 2>&1 &
 else
   echo "Building packages in $buildvarpr ..."
-  $pgmpath/dorubbuild "$srcdir" "$builddir" "$variant" "$skipbuilt" "$kopt" "$buildmake" "$conf" "$confopt" "$clean" "$bldtest" "$check" "$checktool" "$install" "$dist" "$distcheck" "$rpm" $pkgs
+  $pgmpath/dorubbuild "$srcdir" "$builddir" "$variant" "$skipbuilt" "$kopt" "$jobsopt" "$buildmake" "$conf" "$confopt" "$clean" "$bldtest" "$check" "$checktool" "$install" "$dist" "$distcheck" "$rpm" $pkgs
 fi
-- 
GitLab