From 26dd2dbe34e9fe1f5a423927ee3b8befbde71052 Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Tue, 13 Oct 2009 20:52:02 +0000
Subject: [PATCH] Many m4 cleanup, credits go to Elias

[[Imported from SVN: r5646]]
---
 m4/dune.m4           | 204 ++++++++++++++++++++++---------------------
 m4/dune_all.m4       |  14 ++-
 m4/dune_autobuild.m4 |  17 ++--
 m4/dune_common.m4    |  18 ++--
 m4/dune_compiler.m4  |  30 +++----
 m4/dune_docu.m4      |  18 ++--
 m4/dune_exprtmpl.m4  |   9 +-
 m4/dune_griddim.m4   |  44 +++++-----
 m4/dune_mpi.m4       |  40 ++++-----
 m4/dune_streams.m4   |   2 +-
 10 files changed, 191 insertions(+), 205 deletions(-)

diff --git a/m4/dune.m4 b/m4/dune.m4
index 6c4cf6bff..e3717b722 100644
--- a/m4/dune.m4
+++ b/m4/dune.m4
@@ -14,7 +14,7 @@ AC_DEFUN([DUNE_DISABLE_LIBCHECK],[
   # check only for the headers and not for the libs. This feature is used
   # when building the web page, because we don't need the libs in this case
 
-  AC_ARG_ENABLE(dunelibcheck,[],,enable_dunelibcheck=yes)
+  AC_ARG_ENABLE([dunelibcheck],[])
 ])
 
 AC_DEFUN([DUNE_MODULE_ADD_SUMMARY_ENTRY],[
@@ -22,12 +22,12 @@ AC_DEFUN([DUNE_MODULE_ADD_SUMMARY_ENTRY],[
   m4_pushdef([_dune_module], [m4_translit(_dune_name, [-], [_])])
   m4_pushdef([_DUNE_MODULE], [m4_toupper(_dune_module)])
   result="$with_[]_dune_module"
-  if test "x$_DUNE_MODULE[]_ROOT" != "x"; then
+  AS_IF([test -n "$_DUNE_MODULE[]_ROOT"],[
 	result="$result ($_DUNE_MODULE[]_ROOT)"
-  fi
-  if test "x$_DUNE_MODULE[]_VERSION" != "x"; then
+  ])
+  AS_IF([test -n "$_DUNE_MODULE[]_VERSION"],[
 	result="$result version $_DUNE_MODULE[]_VERSION"
-  fi
+  ])
   DUNE_ADD_SUMMARY_MOD_ENTRY(_dune_name,[$result])
 ])
 
@@ -79,7 +79,7 @@ AC_DEFUN([DUNE_CHECK_MODULES],[
 
   # the usual option...
   AC_ARG_WITH(_dune_name,
-    AC_HELP_STRING([--with-_dune_name=PATH],[_dune_module directory]))
+    AS_HELP_STRING([--with-_dune_name=PATH],[_dune_module directory]))
 
   # backup of flags
   ac_save_CPPFLAGS="$CPPFLAGS"
@@ -95,17 +95,17 @@ AC_DEFUN([DUNE_CHECK_MODULES],[
   AC_MSG_CHECKING([for $1 installation or source tree])
 
   # is a directory set?
-  if test x$with_[]_dune_module = x ; then
+  AS_IF([test -z "$with_[]_dune_module"],[
     #
     # search module $1 via pkg-config
     #
     with_[]_dune_module="global installation"
-    if test -z "$PKG_CONFIG"; then
+    AS_IF([test -z "$PKG_CONFIG"],[
       AC_MSG_RESULT([failed])
       AC_MSG_NOTICE([could not search for module _dune_name])
       AC_MSG_ERROR([pkg-config is required for using installed modules])
-    fi
-    if AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+    ])
+    AS_IF(AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]),[
       _DUNE_MODULE[]_CPPFLAGS="`$PKG_CONFIG --cflags _dune_name`" 2>/dev/null
       _DUNE_MODULE[]_ROOT="`$PKG_CONFIG --variable=prefix _dune_name`" 2>/dev/null 
       _DUNE_MODULE[]_VERSION="`$PKG_CONFIG --modversion _dune_name`" 2>/dev/null
@@ -114,29 +114,28 @@ AC_DEFUN([DUNE_CHECK_MODULES],[
         _DUNE_MODULE[]_LIBS="-l[]_dune_lib"
       ])
       HAVE_[]_DUNE_MODULE=1
-      AC_MSG_RESULT([
-        global installation in $_DUNE_MODULE[]_ROOT])
-    else
+      AC_MSG_RESULT([global installation in $_DUNE_MODULE[]_ROOT])
+    ],[
       HAVE_[]_DUNE_MODULE=0
       AC_MSG_RESULT([not found])
-    fi
-  else
+    ])
+  ],[
     #
     # path for module $1 is specified via command line
     #
-    if test -d $with_[]_dune_module ; then
+    AS_IF([test -d "$with_[]_dune_module"],[
       # expand tilde / other stuff
       _DUNE_MODULE[]_ROOT=`cd $with_[]_dune_module && pwd`
 
       # expand search path (otherwise empty CPPFLAGS)
-      if test -d $_DUNE_MODULE[]_ROOT/include/dune; then
+      AS_IF([test -d "$_DUNE_MODULE[]_ROOT/include/dune"],[
         # Dune was installed into directory given by with-dunecommon
         _DUNE_MODULE[]_CPPFLAGS="-I$_DUNE_MODULE[]_ROOT/include"
 	_DUNE_MODULE[]_VERSION="`PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$_DUNE_MODULE[]_ROOT/lib/pkgconfig $PKG_CONFIG --modversion _dune_name`" 2>/dev/null
-      else
+      ],[
         _DUNE_MODULE[]_CPPFLAGS="-I$_DUNE_MODULE[]_ROOT"
 	_DUNE_MODULE[]_VERSION="`grep Version $_DUNE_MODULE[]_ROOT/dune.module | sed -e 's/^Version: *//'`" 2>/dev/null
-      fi
+      ])
       ifelse(_dune_symbol,,,[
         _DUNE_MODULE[]_LDFLAGS="-L$_DUNE_MODULE[]_ROOT/lib"
         _DUNE_MODULE[]_LIBS="-l[]_dune_lib"
@@ -144,14 +143,13 @@ AC_DEFUN([DUNE_CHECK_MODULES],[
       # set expanded module path
       with_[]_dune_module="$_DUNE_MODULE[]_ROOT"
       HAVE_[]_DUNE_MODULE=1
-      AC_MSG_RESULT([
-        found in $_DUNE_MODULE[]_ROOT])
-    else
+      AC_MSG_RESULT([found in $_DUNE_MODULE[]_ROOT])
+    ],[
       HAVE_[]_DUNE_MODULE=0
       AC_MSG_RESULT([not found])
       AC_MSG_ERROR([_dune_name-directory $with_[]_dune_module does not exist])
-    fi
-  fi
+    ])
+  ])
 
   DUNE_CPPFLAGS="$DUNE_CPPFLAGS $_DUNE_MODULE[]_CPPFLAGS"
   CPPFLAGS="$DUNE_CPPFLAGS"
@@ -165,57 +163,66 @@ AC_DEFUN([DUNE_CHECK_MODULES],[
      _DUNE_MODULE[]_CPPFLAGS="$SET_CPPFLAGS"],
     [HAVE_[]_DUNE_MODULE=0
      _DUNE_MODULE[]_CPPFLAGS=""
-     if test x$_DUNE_MODULE[]_ROOT != x; then
-       AC_MSG_WARN([$_DUNE_MODULE[]_ROOT does not seem to contain a valid _dune_name (dune/[]_dune_header not found)])]
-     fi
+     AS_IF([test -n "$_DUNE_MODULE[]_ROOT"],[
+       AC_MSG_WARN([$_DUNE_MODULE[]_ROOT does not seem to contain a valid _dune_name (dune/[]_dune_header not found)])
+     ])
+    ]
   )
 
   ##
   ## check for lib (if lib name was provided)
   ##
-  ifelse(_dune_symbol,,AC_MSG_NOTICE([_dune_name does not provide libs]),[
-    if test "x$enable_dunelibcheck" != "xyes"; then
-      AC_MSG_WARN([library check for _dune_name is disabled. DANGEROUS!])
-    fi
-    if test x$HAVE_[]_DUNE_MODULE = x1 -a x$enable_dunelibcheck = "xyes"; then
+  ifelse(_dune_symbol,,
+    AC_MSG_NOTICE([_dune_name does not provide libs]),
 
-      # save current LDFLAGS
-      ac_save_LDFLAGS="$LDFLAGS"
-      ac_save_LIBS="$LIBS"
-      ac_save_CXX="$CXX"
-      HAVE_[]_DUNE_MODULE=0
-
-      # define LTCXXCOMPILE like it will be defined in the Makefile
-      LTCXXLINK="./libtool --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS"
-      CXX="$LTCXXLINK"
-
-      # use module LDFLAGS
-      LDFLAGS="$LDFLAGS $DUNE_PKG_LDFLAGS $_DUNE_MODULE[]_LDFLAGS"
-      LIBS="$DUNE_LIBS $_DUNE_MODULE[]_LIBS"
-
-      AC_MSG_CHECKING([for lib[]_dune_lib])
-      AC_TRY_LINK(dnl
-        [#]include<dune/[]_dune_header>,
-        _dune_symbol,
-          [AC_MSG_RESULT([yes])
-           HAVE_[]_DUNE_MODULE=1
-           _DUNE_MODULE[]_LIBS="$LIBS"],
-          [AC_MSG_RESULT([no])
-           HAVE_[]_DUNE_MODULE=0
-		   if test x$_DUNE_MODULE[]_ROOT != x; then
-             AC_MSG_WARN([$with_[]_dune_module does not seem to contain a valid _dune_name (failed to link with lib[]_dune_lib[].la)])]
-           fi
-      )
+    AS_IF([test "x$enable_dunelibcheck" = "xno"],[
+      AC_MSG_WARN([library check for _dune_name is disabled. DANGEROUS!])
+    ],[
+      AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[
+
+        # save current LDFLAGS
+        ac_save_LDFLAGS="$LDFLAGS"
+
+        ac_save_LIBS="$LIBS"
+        ac_save_CXX="$CXX"
+        HAVE_[]_DUNE_MODULE=0
+
+        # define LTCXXCOMPILE like it will be defined in the Makefile
+        LTCXXLINK="./libtool --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS"
+        CXX="$LTCXXLINK"
+
+        # use module LDFLAGS
+        LDFLAGS="$LDFLAGS $DUNE_PKG_LDFLAGS $_DUNE_MODULE[]_LDFLAGS"
+        LIBS="$DUNE_LIBS $_DUNE_MODULE[]_LIBS"
+
+        AC_MSG_CHECKING([for lib[]_dune_lib])
+
+        AC_TRY_LINK(dnl
+          [#]include<dune/[]_dune_header>,
+          _dune_symbol,
+          [
+            AC_MSG_RESULT([yes])
+            HAVE_[]_DUNE_MODULE=1
+            _DUNE_MODULE[]_LIBS="$LIBS"
+          ],[
+            AC_MSG_RESULT([no])
+            HAVE_[]_DUNE_MODULE=0
+            AS_IF([test -n "$_DUNE_MODULE[]_ROOT"],[
+             AC_MSG_WARN([$with_[]_dune_module does not seem to contain a valid _dune_name (failed to link with lib[]_dune_lib[].la)])
+            ])
+          ]
+        )
+      ])
 
       # reset variables
       LDFLAGS="$ac_save_LDFLAGS"
       LIBS="$ac_save_LIBS"
       CXX="$ac_save_CXX"
-    fi
-  ])
+    ])
+  )
 
   # did we succeed?
-  if test x$HAVE_[]_DUNE_MODULE = x1; then
+  AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[
     # set variables for our modules
     AC_SUBST(_DUNE_MODULE[]_CPPFLAGS, "$_DUNE_MODULE[]_CPPFLAGS")
     AC_SUBST(_DUNE_MODULE[]_LDFLAGS, "$_DUNE_MODULE[]_LDFLAGS")
@@ -237,9 +244,9 @@ AC_DEFUN([DUNE_CHECK_MODULES],[
     DUNE_PKG_LDFLAGS="$DUNE_PKG_LDFLAGS $_DUNE_MODULE[]_LDFLAGS"
 
     with_[]_dune_module="yes"
-  else
+  ],[
     with_[]_dune_module="no"
-  fi
+  ])
 
   AM_CONDITIONAL(HAVE_[]_DUNE_MODULE, test x$HAVE_[]_DUNE_MODULE = x1)
 
@@ -265,76 +272,75 @@ AC_DEFUN([DUNE_CHECK_MODULES],[
 
 AC_DEFUN([DUNE_DEV_MODE],[
   AC_ARG_ENABLE(dunedevel,
-    AC_HELP_STRING([--enable-dunedevel],[activate Dune-Developer-mode]))
+    AS_HELP_STRING([--enable-dunedevel],[activate Dune-Developer-mode]))
 
-  if test x"$enable_dunedevel" = xyes ; then
-    AC_DEFINE(DUNE_DEVEL_MODE, 1, [Activates developer output])
-  fi
+  AS_IF([test "x$enable_dunedevel" = "xyes"],
+    AC_DEFINE(DUNE_DEVEL_MODE, 1, [Activates developer output]))
 ])
 
 AC_DEFUN([DUNE_SYMLINK],[
-  AC_MSG_WARN([Module is using the deprecated 'dune' symlink.])
+  AC_MSG_WARN([Module is using the deprecated \'dune\' symlink.])
   # create symlink for consistent paths even when $(top_srcdir) is not
   # called dune/ (if filesystem/OS supports symlinks)
   AC_PROG_LN_S
-  if test x"$LN_S" = x"ln -s" ; then
+  AS_IF([test "x$LN_S" = "xln -s"],[
     # Symlinks possible!
  
     # Note: we are currently in the build directory which may be != the
     # source directory
  
     # does a file already exist?
-    if test -e dune ; then
+    AS_IF([test -e "dune"],[
       # exists: is a symlink?
-      if test -L dune ; then
-        if ! test -r dune/$ac_unique_file ; then
-          AC_MSG_ERROR([Symlink 'dune' exists but appears to be wrong! Please remove it manually])
-        fi
-      fi
-    else
+      AS_IF([test -L "dune"],[
+        AS_IF([! test -r dune/$ac_unique_file],[
+          AC_MSG_ERROR([Symlink \'dune\' exists but appears to be wrong\! Please remove it manually])
+        ])
+      ])
+    ],[
       echo Creating dune-symlink...
       # set symlink in build directory to sources
       ln -s $srcdir dune
 
       # sanity check
-      if ! test -r dune/$ac_unique_file ; then
+      AS_IF([! test -r "dune/$ac_unique_file"],[
         AC_MSG_ERROR([Sanity check for symlink failed! Please send a bugreport to dune@dune-project.org])
-      fi
-    fi 
-  else
+      ])
+    ])
+  ],[
     # no symlinks possible... check name of directory
     AC_MSG_ERROR([No symlinks supported! You have to install dune. No inplace usage possible!])
-  fi
+  ])
 ])
 
 AC_DEFUN([DUNE_WEB],
 [
   # special variable to include the documentation into the website
   AC_ARG_WITH(duneweb,
-    AC_HELP_STRING([--with-duneweb=PATH],[Only needed for website-generation, path to checked out version of dune-web]))
-
-  if test x$with_duneweb != x; then
-     if test x$with_duneweb != xno; then
-       # parameter is set. Check it
-       AC_MSG_CHECKING([whether passed Dune-Web ($with_duneweb) directory appears correct])
-       WEBTESTFILE="$with_duneweb/layout/default.wml"
-       if test -d "$with_duneweb" && test -e "$WEBTESTFILE" ; then
+    AS_HELP_STRING([--with-duneweb=PATH],[Only needed for website-generation, path to checked out version of dune-web]))
+
+  AS_IF([test -n "$with_duneweb"],[
+    AS_IF([test "x$with_duneweb" != "xno"],[
+      # parameter is set. Check it
+      AC_MSG_CHECKING([whether passed Dune-Web ($with_duneweb) directory appears correct])
+      WEBTESTFILE="$with_duneweb/layout/default.wml"
+      AS_IF([test -d "$with_duneweb" -a -e "$WEBTESTFILE"],[
          AC_MSG_RESULT([ok])
          # normalize path
          with_duneweb=`(cd $with_duneweb && pwd)` ;
-       else
-         if test -d "$with_duneweb" ; then
+      ],[
+         AS_IF([test -d "$with_duneweb"],[
            AC_MSG_ERROR([$WEBTESTFILE not found in Dune-web dir $with_duneweb!])
-         else
+         ],[
            AC_MSG_ERROR([Dune-Web directory $with_duneweb not found!])
-         fi
+         ])
 		 with_duneweb=no
-	   fi
-     fi
+      ])
+    ])
 	 DUNE_ADD_SUMMARY_ENTRY([dune web],[$with_duneweb])
-  else
+  ],[
     with_duneweb=no
-  fi
+  ])
   AC_SUBST(DUNEWEBDIR, $with_duneweb)
-  AM_CONDITIONAL(DUNEWEB, test x$with_duneweb != xno)
+  AM_CONDITIONAL(DUNEWEB, [test "x$with_duneweb" != "xno"])
 ])
diff --git a/m4/dune_all.m4 b/m4/dune_all.m4
index 8dd835694..918e7d64b 100644
--- a/m4/dune_all.m4
+++ b/m4/dune_all.m4
@@ -13,15 +13,11 @@ AC_DEFUN([DUNE_CHECK_ALL],[
   AC_REQUIRE([DUNE_WEB])
 
   AC_ARG_ENABLE(enabledist,
-    AC_HELP_STRING([--enable-dist],
-                 [go into create-tarballs-mode [[default=no]]]),
-    [enabledist=$enableval],
-    [enabledist=no]
-  )
-  AM_CONDITIONAL(MAKEDIST, test x$enabledist = xyes)
-  if test x$enabledist = xyes; then
-    AM_CONDITIONAL(DUNEWEB, false)
-  fi
+    AS_HELP_STRING([--enable-dist],
+                 [go into create-tarballs-mode [[default=no]]]))
+  AM_CONDITIONAL(MAKEDIST, [test "x$enabledist" = "xyes"])
+  AS_IF([test "x$enabledist" = "xyes"],[
+    AM_CONDITIONAL(DUNEWEB, false)])
 
   dnl check dependencies of this module
   dnl this test is autogenerated for each module
diff --git a/m4/dune_autobuild.m4 b/m4/dune_autobuild.m4
index 94f146d71..827d5d91b 100644
--- a/m4/dune_autobuild.m4
+++ b/m4/dune_autobuild.m4
@@ -5,21 +5,24 @@
 AC_DEFUN([DUNE_AUTOBUILD_FLAGS],[
   # special settings for check-log
   AC_ARG_WITH([hostid],
-    AC_HELP_STRING([--with-hostid=HOST_IDENTIFIER],
+    AS_HELP_STRING([--with-hostid=HOST_IDENTIFIER],
                  [host identifier used for automated test runs]))
-  if test "x$with_hostid" = "xno" ; then 
+  AS_IF([test "x$with_hostid" = "xno"],[
     with_hostid="$ac_hostname (`uname -sm`, $COMPILER_NAME)";
-  fi
+  ])
 
   AC_SUBST([hostid], [$with_hostid])
   AC_ARG_WITH([tag],
-    AC_HELP_STRING([--with-tag=TAG],
+    AS_HELP_STRING([--with-tag=TAG],
                  [tag to use for automated test runs]))
-  if test "x$with_tag" = "xno" ; then with_tag=foo; fi
+  AS_IF([test "x$with_tag" = "xno"],[
+    with_tag=foo
+  ])
     AC_SUBST([tag], [$with_tag])
   AC_ARG_WITH([revision],
-    AC_HELP_STRING([--with-revision=TAG],
+    AS_HELP_STRING([--with-revision=TAG],
                  [revision to use for automated test runs]))
-  if test "x$with_revision" = "xno" ; then with_revision=bar; fi
+  AS_IF([test "x$with_revision" = "xno"],[
+    with_revision=bar])
   AC_SUBST([revision], [$with_revision])
 ])
\ No newline at end of file
diff --git a/m4/dune_common.m4 b/m4/dune_common.m4
index 127c51d69..8489cf39f 100644
--- a/m4/dune_common.m4
+++ b/m4/dune_common.m4
@@ -29,16 +29,14 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
   dnl check for programs
   AC_REQUIRE([AC_PROG_CC])
   # add -Wall if the compiler is gcc
-  if test "$ac_test_CFLAGS" != set && \
-    test "$GCC" = yes; then
+  AS_IF([test "x$ac_test_CFLAGS" != "xset" -a "x$GCC" = "xyes"],[
     CFLAGS="$CFLAGS -Wall"
-  fi
+  ])
   # add -Wall if the compiler is g++
   AC_REQUIRE([AC_PROG_CXX])
-  if test "$ac_test_CXXFLAGS" != set && \
-    test "$GXX" = yes; then
+  AS_IF([test "x$ac_test_CXXFLAGS" != "xset" -a "x$GXX" = "xyes"],[
     CXXFLAGS="$CXXFLAGS -Wall"
-  fi
+  ])
 
   dnl checks for header files.
   AC_REQUIRE([AC_HEADER_STDC])
@@ -48,12 +46,12 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
 
   # Allow disabling tr1 headers. E.g. needed for broken xlc on Blue Gene
   AC_ARG_ENABLE(tr1-headers, 
-	AC_HELP_STRING([--disable-tr1-headers], 
+	AS_HELP_STRING([--disable-tr1-headers],
 	[Prevents checking for  tr1 headers like tuple, array, etc. 
-	This might be needed for broken compilers like xlc on Blue Gene]), 
-	[], [    
+	This might be needed for broken compilers like xlc on Blue Gene]))
+  AS_IF([test "x$enable_tr1_headers" = "xyes"],
 	  AC_CHECK_HEADERS([type_traits tr1/type_traits array tr1/array tuple tr1/tuple])
-	  ])
+  )
   
   AC_LANG_POP([C++])
 
diff --git a/m4/dune_compiler.m4 b/m4/dune_compiler.m4
index 6f8e17da2..28639212f 100644
--- a/m4/dune_compiler.m4
+++ b/m4/dune_compiler.m4
@@ -4,11 +4,8 @@
 AC_DEFUN([DUNE_CHECK_COMPILER],[
 
 AC_ARG_ENABLE(compilercheck,
-  AC_HELP_STRING([--enable-compilercheck],
-                 [check for supported compilers [[default=yes]]]),
-  [compilercheck=$enableval],
-  [compilercheck=yes]
-)
+  AS_HELP_STRING([--enable-compilercheck],
+                 [check for supported compilers [[default=yes]]]))
 
 SUPPORTED_COMPILER="gcc (>= 3.4.1) or icc (>= 7.0)"
 
@@ -39,20 +36,17 @@ int main() {
 }
 _ACEOF
 
-if test "x$compilercheck" != "xyes" ; then
-  AC_MSG_WARN([compilercheck is disabled. DANGEROUS!])    
-else
-  if $CXX conftest.cc -o conftest.$ac_exeext >&5; then
-	COMPILER_NAME=`./conftest.$ac_exeext`
-    rm -f conftest.$ac_exeext
-  else
+AS_IF([test "x$compilercheck" != "xno"],[
+  AC_MSG_WARN([compilercheck is disabled. DANGEROUS!])],[
+  AS_IF([$CXX conftest.cc -o conftest.$ac_exeext >&5],[
+    COMPILER_NAME=`./conftest.$ac_exeext`;
+    rm -f conftest.$ac_exeext],[
     AC_MSG_ERROR([Your compiler is not officially supported by dune
                   dune is known to work with $SUPPORTED_COMPILER])
-  fi
-fi
-
-if test "x$COMPILER_NAME" = "x"; then
-	COMPILER_NAME="unknown compiler"
-fi
+    ]
+  )]
+)
 
+AS_IF([test -z "$COMPILER_NAME"],[
+	COMPILER_NAME="unknown compiler"])
 ])
diff --git a/m4/dune_docu.m4 b/m4/dune_docu.m4
index cdd36b94a..fcacd67fb 100644
--- a/m4/dune_docu.m4
+++ b/m4/dune_docu.m4
@@ -5,18 +5,16 @@ AC_DEFUN([DUNE_DOCUMENTATION],[
   # documentation then disable documentation 
   # option by default 
   DOCU_TAG_FILE="no-documentation.tag"
-  if test -f doc/$DOCU_TAG_FILE ; then 
-    HAS_DOCUMENTATION="no"
-  else 
+  AS_IF([test -f "doc/$DOCU_TAG_FILE"],[
+    HAS_DOCUMENTATION="no"],[
     # check whether option is chosen or not 
-    if test x$enable_documentation != xno; then 
-      HAS_DOCUMENTATION="yes"
-    else 
+    AS_IF([test "x$enable_documentation" != "xno"],[
+      HAS_DOCUMENTATION="yes"],[
       HAS_DOCUMENTATION="no"
-    fi
-  fi
+    ])
+  ])
   AC_SUBST(DOCUMENTATION_TAG_FILE, $DOCU_TAG_FILE )
   AC_ARG_ENABLE(documentation,
-   AC_HELP_STRING([--disable-documentation],[don't generate docs, speeds up the build]))
-  AM_CONDITIONAL(BUILD_DOCS, test x$HAS_DOCUMENTATION = xyes)
+   AS_HELP_STRING([--disable-documentation],[don\'t generate docs, speeds up the build]))
+  AM_CONDITIONAL(BUILD_DOCS, [test "x$HAS_DOCUMENTATION" = "xyes"])
 ])
diff --git a/m4/dune_exprtmpl.m4 b/m4/dune_exprtmpl.m4
index e57ce43bd..f983677d4 100644
--- a/m4/dune_exprtmpl.m4
+++ b/m4/dune_exprtmpl.m4
@@ -1,11 +1,10 @@
 AC_DEFUN([DUNE_EXPRTMPL],[
   # enable experimental features
   AC_ARG_ENABLE(expressiontemplates,
-   AC_HELP_STRING([--enable-expressiontemplates],[enable experimental expressiontemplates in dune]))
-  if test x$enable_expressiontemplates = xyes; then
+   AS_HELP_STRING([--enable-expressiontemplates],[enable experimental expressiontemplates in dune]))
+  AS_IF([test "x$enable_expressiontemplates" = "xyes"],[
     AC_DEFINE([DUNE_EXPRESSIONTEMPLATES], [1], 
-      [Define to 1 if the experimental expression templates should be used])
-  fi
+      [Define to 1 if the experimental expression templates should be used])])
   AM_CONDITIONAL([EXPRESSIONTEMPLATES],
-    [test x$enable_expressiontemplates = xyes])
+    [test "x$enable_expressiontemplates" = "xyes"])
 ])
\ No newline at end of file
diff --git a/m4/dune_griddim.m4 b/m4/dune_griddim.m4
index 9ecd27596..c61f6bd1e 100644
--- a/m4/dune_griddim.m4
+++ b/m4/dune_griddim.m4
@@ -5,58 +5,58 @@ AC_DEFUN([DUNE_GRID_DIMENSION],[
 
 # default is disabled 
   AC_ARG_WITH(grid_dim,
-              AC_HELP_STRING([--with-grid-dim=1|2|3],
+              AS_HELP_STRING([--with-grid-dim=1|2|3],
                              [dimension of grid; mainly used to determine grid
                               dimension during compilation (default=disabled)]),
                               , with_grid_dim=0)
   AC_ARG_WITH(world_dim,
-              AC_HELP_STRING([-with-world-dim=1|2|3],
+              AS_HELP_STRING([-with-world-dim=1|2|3],
                              [dimension of world; mainly used to determine grid
                               dimension during compilation (default=grid-dim)]),
               , with_world_dim=0)
 
   AC_ARG_WITH(grid_type,
-            AC_HELP_STRING([--with-grid-type= ALBERTAGRID | ALUGRID_CUBE | ALUGRID_SIMPLEX | ALUGRID_CONFORM | ONEDGRID | SGRID | UGGRID | YASPGRID],
+            AS_HELP_STRING([--with-grid-type= ALBERTAGRID | ALUGRID_CUBE | ALUGRID_SIMPLEX | ALUGRID_CONFORM | ONEDGRID | SGRID | UGGRID | YASPGRID],
           [only enabled if grid-dim is given, sets type of grid (default=YASPGRID)]),, with_grid_type=YASPGRID)
           
-if test x$with_grid_dim != x0 ; then 
+AS_IF([test "x$with_grid_dim" != "x0"],[
   
   AC_MSG_CHECKING([grid-dim and grid-type])
   # make sure that given grid dim is valid 
-  if test x$with_grid_dim != x1 && test x$with_grid_dim != x2 && test x$with_grid_dim != x3 ; then 
+  AS_IF([test "x$with_grid_dim" != "x1" -a "x$with_grid_dim" != "x2" -a "x$with_grid_dim" != "x3"],[
     AC_MSG_ERROR([Delivered grid-dim = $with_grid_dim is not valid. Valid are only 1, 2, or 3 .])
-  fi
+  ])
 
   # make sure that given grid type is valid 
-  if test $with_grid_type != "ALBERTAGRID" && 
-     test $with_grid_type != "ALUGRID_CUBE" &&
-     test $with_grid_type != "ALUGRID_SIMPLEX" &&
-     test $with_grid_type != "ALUGRID_CONFORM" &&
-     test $with_grid_type != "ONEDGRID" &&
-     test $with_grid_type != "SGRID" &&
-     test $with_grid_type != "UGGRID" &&
-     test $with_grid_type != "YASPGRID" ; then 
+  AS_IF([test "x$with_grid_type" != "xALBERTAGRID" -a
+              "x$with_grid_type" != "xALUGRID_CUBE" -a
+              "x$with_grid_type" != "xALUGRID_SIMPLEX" -a
+              "x$with_grid_type" != "xALUGRID_CONFORM" -a
+              "x$with_grid_type" != "xONEDGRID" -a
+              "x$with_grid_type" != "xSGRID" -a
+              "x$with_grid_type" != "xUGGRID" -a
+              "x$with_grid_type" != "xYASPGRID"],[
     AC_MSG_ERROR([Delivered grid-type = $with_grid_type is not valid. Run ./configure --help for valid values.])
-  fi
+  ])
 
   variable_griddim="$``(``GRIDDIM``)``"
   variable_worlddim="$``(``WORLDDIM``)``"
   griddim_cppflags="-DGRIDDIM=$``(``GRIDDIM``)`` -DWORLDDIM=$``(``WORLDDIM``)`` -D$``(``GRIDTYPE``)``"
   AC_SUBST(GRIDDIM, $with_grid_dim)
-  if test x$with_world_dim = x0 ; then
+  AS_IF([test "x$with_world_dim" = "x0"],[
     AC_SUBST(WORLDDIM, $variable_griddim)
-  else
+  ],[
     AC_SUBST(WORLDDIM, $with_world_dim)
-  fi
+  ])
   AC_SUBST(GRIDDIMGRID, $variable_griddim )
   AC_SUBST(GRIDDIMWORLD, $variable_worlddim )
   AC_SUBST(GRIDTYPE, $with_grid_type )
   AC_SUBST(GRIDDIM_CPPFLAGS, $griddim_cppflags)
   DUNE_PKG_CPPFLAGS="$DUNE_PKG_CPPFLAGS $griddim_cppflags"
-  if test x$with_world_dim = x0 ; then
+  AS_IF([test "x$with_world_dim" = "x0"],[
     AC_MSG_RESULT([yes (GRIDDIM=$GRIDDIM, WORLDDIM=GRIDDIM and GRIDTYPE=$GRIDTYPE)])
-  else
+  ].[
     AC_MSG_RESULT([yes (GRIDDIM=$GRIDDIM, WORLDDIM=$WORLDDIM and GRIDTYPE=$GRIDTYPE)])
-  fi
-fi 
+])
+])
 ])
diff --git a/m4/dune_mpi.m4 b/m4/dune_mpi.m4
index f90191d59..5490a1afb 100644
--- a/m4/dune_mpi.m4
+++ b/m4/dune_mpi.m4
@@ -65,28 +65,21 @@ AC_DEFUN([DUNE_MPI],[
 
   # enable/disable parallel features
   AC_ARG_ENABLE(parallel,
-    AC_HELP_STRING([--enable-parallel],
+    AS_HELP_STRING([--enable-parallel],
       [Enable the parallel features of Dune. If enabled
        configure will try to determine your MPI automatically. You can
-       overwrite this setting by specifying the MPICC variable]),
-    [with_parallel=$enableval],
-    [with_parallel=no]
-  )
-  AC_SUBST(ENABLE_PARALLEL, "$with_parallel")
+       overwrite this setting by specifying the MPICC variable]))
+  AC_SUBST(ENABLE_PARALLEL, "$enable_parallel")
 
   # disable runtest if we have a queuing system
   AC_ARG_ENABLE(mpiruntest,
-    AC_HELP_STRING([--disable-mpiruntest],
-      [Don't try to run a MPI program during configure. (This is needed if you depend on a queuing system)]),
-    [mpiruntest=${enableval}],
-    [mpiruntest=yes]
-  )
+    AS_HELP_STRING([--disable-mpiruntest],
+      [Don\'t try to run a MPI program during configure. (This is needed if you depend on a queuing system)]))
 
   with_mpi="no"
 
   ## do nothing if --disable-parallel is used
-  if test x$with_parallel = xyes ; then
-  
+  AS_IF([test "x$enable_parallel" = "xyes"],[
     ACX_MPI([
       MPICOMP="$MPICC"
 
@@ -97,11 +90,10 @@ AC_DEFUN([DUNE_MPI],[
     ],[
       # ACX_MPI didn't find anything
       with_mpi="no"
-    ])
-  fi # end of MPI identification
+    ])])
 
   # if an MPI implementation was found..
-  if test x"$with_mpi" != xno ; then
+  AS_IF([test "x$with_mpi" != "xno"],[
     ### do a sanity check: can we compile and link a trivial MPI program?
     AC_MSG_CHECKING([whether compiling with $dune_MPI_VERSION works])
 
@@ -129,9 +121,9 @@ AC_DEFUN([DUNE_MPI],[
           with_mpi=no]
     )
 
-    if test "x$mpiruntest" != "xyes" ; then
+    AS_IF([test "x$mpiruntest" != "xyes"],[
       AC_MSG_WARN([Diabled test whether running with $dune_MPI_VERSION works.])    
-    else
+    ],[
       AC_MSG_CHECKING([whether running with $dune_MPI_VERSION works])
       AC_RUN_IFELSE(
         AC_LANG_SOURCE(
@@ -152,7 +144,7 @@ AC_DEFUN([DUNE_MPI],[
             See config.log for details])
             with_mpi=no]
       )
-    fi
+    ])
     AC_LANG_POP
 
     # Check for MPI-2 Standard
@@ -163,22 +155,22 @@ AC_DEFUN([DUNE_MPI],[
     # restore variables
     LIBS="$ac_save_LIBS"
     CPPFLAGS="$ac_save_CPPFLAGS"
-  fi
+  ])
     
   # set flags
-  if test x"$with_mpi" != xno ; then
+  AS_IF([test "x$with_mpi" != "xno"],[
     AC_SUBST(MPI_CPPFLAGS, $MPI_CPPFLAGS)
     AC_SUBST(MPI_LDFLAGS, $MPI_LDFLAGS)
     AC_SUBST(MPI_VERSION, $dune_MPI_VERSION)
     AC_DEFINE(HAVE_MPI,ENABLE_MPI,[Define if you have the MPI library.
     This is only true if MPI was found by configure 
     _and_ if the application uses the MPI_CPPFLAGS])
-  else
+  ],[
     AC_SUBST(MPI_CPPFLAGS, "")
     AC_SUBST(MPI_LDFLAGS, "")
-  fi
+  ])
 
-  AM_CONDITIONAL(MPI, test x"$with_mpi" != xno)
+  AM_CONDITIONAL(MPI, [test "x$with_mpi" != "xno"])
 
   DUNE_ADD_SUMMARY_ENTRY([MPI],[$with_mpi])
 
diff --git a/m4/dune_streams.m4 b/m4/dune_streams.m4
index 3eb5510ab..688560521 100644
--- a/m4/dune_streams.m4
+++ b/m4/dune_streams.m4
@@ -12,7 +12,7 @@ AC_DEFUN([DUNE_SET_MINIMAL_DEBUG_LEVEL],[
   # GRAVE_DEBUG_LEVEL = 5;
 
   AC_ARG_WITH(minimal_debug_level,
-    AC_HELP_STRING([--with-minimal-debug-level=[grave|warn|info|verb|vverb]],
+    AS_HELP_STRING([--with-minimal-debug-level=[grave|warn|info|verb|vverb]],
      [set the MINIMAL_DEBUG_LEVEL. Standard debug streams with level below 
       MINIMAL_DEBUG_LEVEL will collapse to doing nothing if output is 
       requested. (default=warn)]
-- 
GitLab