From 8c01107cd6db0ddbc6a1cb1c085e27fc111fe3ca Mon Sep 17 00:00:00 2001
From: Markus Blatt <markus@dr-blatt.de>
Date: Wed, 29 Jan 2014 14:00:39 +0100
Subject: [PATCH] [dunecontrol] Fixes multiarch detection issues.

This patch fixes two issues:
- Faulty an non-posix sed expression
- Precendence issue (multiarch was extracted before compiler was set.)
---
 bin/dunecontrol | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/bin/dunecontrol b/bin/dunecontrol
index efefe8c06..8e49d25c4 100755
--- a/bin/dunecontrol
+++ b/bin/dunecontrol
@@ -229,12 +229,11 @@ extract_multiarch(){
   fi
   if test "x$USE_CMAKE" = "xyes"; then
     load_opts "cmake"
-    my_cxx_compiler=`echo $CMAKE_FLAGS | $GREP CXX | $SED "s/.*CXX=[\"']\?\([$BLANK'\"]*\)[\"']\?.*/\1/"`
   fi
   if test "x$my_cxx_compiler" == "x"; then
     load_opts "configure"
-    my_cxx_compiler=`echo $CONFIGURE_FLAGS | $GREP CXX| $SED "s/.*CXX=[\"']\?\([^$BLANK'\"]*\)[\"']\?.*/\1/"`
   fi
+  my_cxx_compiler=`echo $CMD_FLAGS | $GREP CXX | $SED "s/.*CXX=[\"']\{0,1\}\([^$BLANK'\"]*\)[\"']\{0,1\}.*/\1/"`
   if test "x$my_cxx_compiler" == "x"; then
     set +e #error in the multiarch detection should not be fatal.
     $(which cc &>/dev/null)
@@ -254,15 +253,6 @@ extract_multiarch(){
 
 export PREFIX_DIR="`canonicalpath "$0"`/.."
 
-extract_multiarch
-
-# create PKG_CONFIG_PATH for installed dune modules
-for i in $MULTIARCH_LIBDIR lib64 lib32 lib; do
-  if test -d "$PREFIX_DIR/$i/pkgconfig"; then
-    export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX_DIR/$i/pkgconfig"
-  fi
-done
-
 # Read the modules find part
 . "$PREFIX_DIR/lib/dunemodules.lib"
 
@@ -996,6 +986,15 @@ while test $# -gt 0; do
     shift
 done
 
+extract_multiarch
+
+# create PKG_CONFIG_PATH for installed dune modules
+for i in $MULTIARCH_LIBDIR lib64 lib32 lib; do
+  if test -d "$PREFIX_DIR/$i/pkgconfig"; then
+    export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX_DIR/$i/pkgconfig"
+  fi
+done
+
 # we assume there should be a command...
 if test "x$command" = "x"; then
   usage
-- 
GitLab