From 93823c1cf595a5fe7c28666226726944fe33b75b Mon Sep 17 00:00:00 2001
From: Thimo Neubauer <thimo@dune-project.org>
Date: Tue, 11 Nov 2003 10:07:15 +0000
Subject: [PATCH] copied compiler-switch from duneapps, now autogen.sh has the
 same interface in both directories (automagically calls ./configure)

[[Imported from SVN: r14]]
---
 autogen.sh | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 gcc.opts   | 17 ++++++++++++
 icc.opts   | 17 ++++++++++++
 3 files changed, 111 insertions(+), 1 deletion(-)
 create mode 100644 gcc.opts
 create mode 100644 icc.opts

diff --git a/autogen.sh b/autogen.sh
index cbae3b05b..b45d1dbec 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -4,6 +4,73 @@
 # barf on errors
 set -e
 
+DEFAULTCONFOPT=
+
+usage () {
+    echo "Usage: ./autogen.sh [options]"
+    echo "  -i, --intel        use intel compiler"
+    echo "  -g, --gnu          use gnu compiler (default)"
+    echo "  -m, --mpi          use mpicc"
+    echo "  --opts=FILE        use compiler-options from FILE"
+    echo "  -d, --debug        switch debug-opts on"
+    echo "  -n, --nodebug      switch debug-opts off"
+    echo "  -o, --optim        switch optimization on"
+    echo "  -h, --help         you already found this :)"
+}
+
+# no compiler set yet
+COMPSET=0
+for OPT in $* ; do
+
+    set +e
+    # stolen from configure...
+    # when no option is set, this returns an error code
+    arg=`expr "x$OPT" : 'x[^=]*=\(.*\)'`
+    set -e
+
+    case "$OPT" in
+	-i|--intel)   . ./icc.opts ; COMPSET=1 ;;
+	-g|--gnu)     . ./gcc.opts ; COMPSET=1 ;;
+	-m|--mpi)     . ./mpi.opts ; COMPSET=1 ;;
+	--opts=*)
+	    if [ -r $arg ] ; then
+	      echo "reading options from $arg..."
+	      . ./$arg ;
+	      COMPSET=1;
+	    else
+	      echo "Cannot open compiler options file $arg!" ;
+	      exit 1;
+	    fi ;;
+	-d|--debug)   DEBUG=1 ;;
+	-n|--nodebug) DEBUG=0 ;;
+	-o|--optim)   OPTIM=1 ;;
+	-h|--help) usage ; exit 0 ;;
+	# pass unknown opts to ./configure
+	*) CONFOPT="$CONFOPT $OPT" ;;
+    esac
+done
+
+# use the nonfree compiler as default :-(
+if [ "$COMPSET" != "1" ] ; then
+    echo "No compiler set, using Intel compiler as default"
+    . ./icc.opts
+fi
+
+# create flags
+COMPFLAGS="$FLAGS"
+
+# maybe add debug flag
+if [ "$DEBUG" = "1" ] ; then	
+    COMPFLAGS="$COMPFLAGS $DEBUGFLAGS"
+fi
+
+# maybe add optimization flag
+if [ "$OPTIM" = "1" ] ; then	
+    COMPFLAGS="$COMPFLAGS $OPTIMFLAGS"
+fi
+
+## run autotools
+
 echo "--> libtoolize..."
 # this script won't rewrite the files if they already exist. This is a
 # PITA when you want to upgrade libtool, thus I'm setting --force
@@ -23,4 +90,13 @@ automake --add-missing
 echo "--> autoconf..."
 autoconf
 
-echo "files successfully created, please run ./configure now"
\ No newline at end of file
+#### start configure with special environment
+
+export CC=$COMP
+export CXX=$CXXCOMP
+export CPP="$COMP -E"
+
+export CFLAGS="$COMPFLAGS"
+export CXXFLAGS="$COMPFLAGS"
+
+./configure $DEFAULTCONFOPT $CONFOPT
diff --git a/gcc.opts b/gcc.opts
new file mode 100644
index 000000000..d18773c9b
--- /dev/null
+++ b/gcc.opts
@@ -0,0 +1,17 @@
+# $Id$
+
+# options for gcc/g++
+# remember to run ./autogen.sh after changing these values!
+
+# name of compiler binaries
+COMP="gcc"
+CXXCOMP="g++"
+
+# flags set in any case
+FLAGS="-Wall"
+
+# additional flags for debugging
+DEBUGFLAGS="-g"
+
+# additional flags for optimization
+OPTIMFLAGS="-O2"
diff --git a/icc.opts b/icc.opts
new file mode 100644
index 000000000..0de1c67fb
--- /dev/null
+++ b/icc.opts
@@ -0,0 +1,17 @@
+# $Id$
+
+# options for icc
+# remember to run ./autogen.sh after changing these values!
+
+# name of compiler binaries
+COMP="icc"
+CXXCOMP="icc"
+
+# flags set in any case
+FLAGS=""
+
+# additional flags for debugging
+DEBUGFLAGS="-O0 -g"
+
+# additional flags for optimization
+OPTIMFLAGS="-O3"
-- 
GitLab