diff --git a/m4/ax_cc_maxopt.m4 b/m4/ax_cc_maxopt.m4
index 1917d7f53d6f8efb2cc9361dfa94f25d5a9db8d9..0d442612d161f18091aba6200ee965b85a797110 100644
--- a/m4/ax_cc_maxopt.m4
+++ b/m4/ax_cc_maxopt.m4
@@ -1,5 +1,5 @@
 # ===========================================================================
-#              http://autoconf-archive.cryp.to/ax_cc_maxopt.html
+#       http://www.gnu.org/software/autoconf-archive/ax_cc_maxopt.html
 # ===========================================================================
 #
 # SYNOPSIS
@@ -21,7 +21,7 @@
 #   by the code (e.g. for gcc's -fstrict-aliasing), and that floating-point
 #   computations can be re-ordered as needed.
 #
-#   Requires macros: AX_CHECK_COMPILER_FLAGS, AX_COMPILER_VENDOR,
+#   Requires macros: AX_CHECK_COMPILE_FLAG, AX_COMPILER_VENDOR,
 #   AX_GCC_ARCHFLAG, AX_GCC_X86_CPUID.
 #
 # LICENSE
@@ -55,14 +55,16 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
+#serial 16
+
 AC_DEFUN([AX_CC_MAXOPT],
 [
 AC_REQUIRE([AC_PROG_CC])
 AC_REQUIRE([AX_COMPILER_VENDOR])
 AC_REQUIRE([AC_CANONICAL_HOST])
 
-AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])],
-	acx_maxopt_portable=$withval, acx_maxopt_portable=no)
+AC_ARG_ENABLE(portable-binary, [AS_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])],
+	acx_maxopt_portable=$enableval, acx_maxopt_portable=no)
 
 # Try to determine "good" native compiler flags if none specified via CFLAGS
 if test "$ac_test_CFLAGS" != "set"; then
@@ -88,8 +90,8 @@ if test "$ac_test_CFLAGS" != "set"; then
 	 else
            xlc_opt="-qtune=auto"
 	 fi
-         AX_CHECK_COMPILER_FLAGS($xlc_opt,
-         	CFLAGS="-O3 -qansialias -w $xlc_opt",
+         AX_CHECK_COMPILE_FLAG($xlc_opt,
+		CFLAGS="-O3 -qansialias -w $xlc_opt",
                [CFLAGS="-O3 -qansialias -w"
                 echo "******************************************************"
                 echo "*  You seem to have the IBM  C compiler.  It is      *"
@@ -113,17 +115,25 @@ if test "$ac_test_CFLAGS" != "set"; then
 	      AX_GCC_X86_CPUID(0)
               AX_GCC_X86_CPUID(1)
 	      case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG
-                *:756e6547:*:*) # Intel
+                *:756e6547:6c65746e:49656e69) # Intel
                   case $ax_cv_gcc_x86_cpuid_1 in
-                    *6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";;
-                    *f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";;
-                    *f??:*:*:*) icc_flags="-xN -xW -xK";;
+		    *0?6[[78ab]]?:*:*:*|?6[[78ab]]?:*:*:*|6[[78ab]]?:*:*:*) icc_flags="-xK" ;;
+		    *0?6[[9d]]?:*:*:*|?6[[9d]]?:*:*:*|6[[9d]]?:*:*:*|*1?65?:*:*:*) icc_flags="-xSSE2 -xB -xK" ;;
+		    *0?6e?:*:*:*|?6e?:*:*:*|6e?:*:*:*) icc_flags="-xSSE3 -xP -xO -xB -xK" ;;
+		    *0?6f?:*:*:*|?6f?:*:*:*|6f?:*:*:*|*1?66?:*:*:*) icc_flags="-xSSSE3 -xT -xB -xK" ;;
+		    *1?6[[7d]]?:*:*:*) icc_flags="-xSSE4.1 -xS -xT -xB -xK" ;;
+		    *1?6[[aef]]?:*:*:*|*2?6[[5cef]]?:*:*:*) icc_flags="-xSSE4.2 -xS -xT -xB -xK" ;;
+		    *2?6[[ad]]?:*:*:*) icc_flags="-xAVX -SSE4.2 -xS -xT -xB -xK" ;;
+		    *3?6[[ae]]?:*:*:*) icc_flags="-xCORE-AVX-I -xAVX -SSE4.2 -xS -xT -xB -xK" ;;
+		    *3?6[[cf]]?:*:*:*|*4?6[[56]]?:*:*:*) icc_flags="-xCORE-AVX2 -xCORE-AVX-I -xAVX -SSE4.2 -xS -xT -xB -xK" ;;
+		    *000?f[[346]]?:*:*:*|?f[[346]]?:*:*:*|f[[346]]?:*:*:*) icc_flags="-xSSE3 -xP -xO -xN -xW -xK" ;;
+		    *00??f??:*:*:*|??f??:*:*:*|?f??:*:*:*|f??:*:*:*) icc_flags="-xSSE2 -xN -xW -xK" ;;
                   esac ;;
               esac ;;
           esac
           if test "x$icc_flags" != x; then
             for flag in $icc_flags; do
-              AX_CHECK_COMPILER_FLAGS($flag, [icc_archflag=$flag; break])
+              AX_CHECK_COMPILE_FLAG($flag, [icc_archflag=$flag; break])
             done
           fi
           AC_MSG_CHECKING([for icc architecture flag])
@@ -139,17 +149,22 @@ if test "$ac_test_CFLAGS" != "set"; then
      CFLAGS="-O3 -fomit-frame-pointer"
 
      # -malign-double for x86 systems
-     AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
+     AX_CHECK_COMPILE_FLAG(-malign-double, CFLAGS="$CFLAGS -malign-double")
 
      #  -fstrict-aliasing for gcc-2.95+
-     AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,
+     AX_CHECK_COMPILE_FLAG(-fstrict-aliasing,
 	CFLAGS="$CFLAGS -fstrict-aliasing")
 
      # note that we enable "unsafe" fp optimization with other compilers, too
-     AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
+     AX_CHECK_COMPILE_FLAG(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
 
      AX_GCC_ARCHFLAG($acx_maxopt_portable)
      ;;
+
+    microsoft)
+     # default optimization flags for MSVC opt builds
+     CFLAGS="-O2"
+     ;;
   esac
 
   if test -z "$CFLAGS"; then
@@ -163,7 +178,7 @@ if test "$ac_test_CFLAGS" != "set"; then
         CFLAGS="-O3"
   fi
 
-  AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [
+  AX_CHECK_COMPILE_FLAG($CFLAGS, [], [
 	echo ""
         echo "********************************************************"
         echo "* WARNING: The guessed CFLAGS don't seem to work with  *"
diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4
index c3a8d695a1bcda95fd91cb6d8c03a94cdcb5b9c7..ca3639715e7243fa4343eb2e7f3de53927cc9d4a 100644
--- a/m4/ax_check_compile_flag.m4
+++ b/m4/ax_check_compile_flag.m4
@@ -4,7 +4,7 @@
 #
 # SYNOPSIS
 #
-#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
+#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
 #
 # DESCRIPTION
 #
@@ -19,6 +19,8 @@
 #   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
 #   force the compiler to issue an error when a bad flag is given.
 #
+#   INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
 #   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
 #   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
 #
@@ -53,19 +55,19 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
-#serial 2
+#serial 4
 
 AC_DEFUN([AX_CHECK_COMPILE_FLAG],
-[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
 AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
 AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
   ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
   _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+  AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
     [AS_VAR_SET(CACHEVAR,[yes])],
     [AS_VAR_SET(CACHEVAR,[no])])
   _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
-AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
+AS_VAR_IF(CACHEVAR,yes,
   [m4_default([$2], :)],
   [m4_default([$3], :)])
 AS_VAR_POPDEF([CACHEVAR])dnl
diff --git a/m4/ax_check_zlib.m4 b/m4/ax_check_zlib.m4
deleted file mode 100644
index ae5705f6241769bac82121ddb3eb37bfde265192..0000000000000000000000000000000000000000
--- a/m4/ax_check_zlib.m4
+++ /dev/null
@@ -1,142 +0,0 @@
-# ===========================================================================
-#       http://www.gnu.org/software/autoconf-archive/ax_check_zlib.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_CHECK_ZLIB([action-if-found], [action-if-not-found])
-#
-# DESCRIPTION
-#
-#   This macro searches for an installed zlib library. If nothing was
-#   specified when calling configure, it searches first in /usr/local and
-#   then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified,
-#   it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If
-#   --without-zlib is specified, the library is not searched at all.
-#
-#   If either the header file (zlib.h) or the library (libz) is not found,
-#   shell commands 'action-if-not-found' is run. If 'action-if-not-found' is
-#   not specified, the configuration exits on error, asking for a valid zlib
-#   installation directory or --without-zlib.
-#
-#   If both header file and library are found, shell commands
-#   'action-if-found' is run. If 'action-if-found' is not specified, the
-#   default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends
-#   '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls
-#   AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition
-#   for this symbol in a config.h file. Sample usage in a C/C++ source is as
-#   follows:
-#
-#     #ifdef HAVE_LIBZ
-#     #include <zlib.h>
-#     #endif /* HAVE_LIBZ */
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Loic Dachary <loic@senga.org>
-#   Copyright (c) 2010 Bastien Chevreux <bach@chevreux.org>
-#
-#   This program is free software; you can redistribute it and/or modify it
-#   under the terms of the GNU General Public License as published by the
-#   Free Software Foundation; either version 2 of the License, or (at your
-#   option) any later version.
-#
-#   This program is distributed in the hope that it will be useful, but
-#   WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-#   Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License along
-#   with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 14
-
-AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB])
-AC_DEFUN([AX_CHECK_ZLIB],
-#
-# Handle user hints
-#
-[AC_MSG_CHECKING(if zlib is wanted)
-zlib_places="/usr/local /usr /opt/local /sw"
-AC_ARG_WITH([zlib],
-[  --with-zlib=DIR         root directory path of zlib installation @<:@defaults to
-                          /usr/local or /usr if not found in /usr/local@:>@
-  --without-zlib          to disable zlib usage completely],
-[if test "$withval" != no ; then
-  AC_MSG_RESULT(yes)
-  if test -d "$withval"
-  then
-    zlib_places="$withval $zlib_places"
-  else
-    AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
-  fi
-else
-  zlib_places=
-  AC_MSG_RESULT(no)
-fi],
-[AC_MSG_RESULT(yes)])
-
-#
-# Locate zlib, if wanted
-#
-if test -n "${zlib_places}"
-then
-	# check the user supplied or any other more or less 'standard' place:
-	#   Most UNIX systems      : /usr/local and /usr
-	#   MacPorts / Fink on OSX : /opt/local respectively /sw
-	for ZLIB_HOME in ${zlib_places} ; do
-	  if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi
-	  ZLIB_HOME=""
-	done
-
-  ZLIB_OLD_LDFLAGS=$LDFLAGS
-  ZLIB_OLD_CPPFLAGS=$CPPFLAGS
-  if test -n "${ZLIB_HOME}"; then
-        LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
-        CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
-  fi
-  AC_LANG_SAVE
-  AC_LANG_C
-  AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no])
-  AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
-  AC_LANG_RESTORE
-  if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes"
-  then
-    #
-    # If both library and header were found, action-if-found
-    #
-    m4_ifblank([$1],[
-                CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
-                LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
-                LIBS="-lz $LIBS"
-                AC_DEFINE([HAVE_LIBZ], [1],
-                          [Define to 1 if you have `z' library (-lz)])
-               ],[
-                # Restore variables
-                LDFLAGS="$ZLIB_OLD_LDFLAGS"
-                CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
-                $1
-               ])
-  else
-    #
-    # If either header or library was not found, action-if-not-found
-    #
-    m4_default([$2],[
-                AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib])
-                ])
-  fi
-fi
-])
diff --git a/m4/ax_compiler_vendor.m4 b/m4/ax_compiler_vendor.m4
index 2519a5fbb937bc97510816809ce48da309e81f51..39ca3c0f3378267d13cfb2ad3dd8ffa4854fb772 100644
--- a/m4/ax_compiler_vendor.m4
+++ b/m4/ax_compiler_vendor.m4
@@ -1,5 +1,5 @@
 # ===========================================================================
-#           http://autoconf-archive.cryp.to/ax_compiler_vendor.html
+#    http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
 # ===========================================================================
 #
 # SYNOPSIS
@@ -44,18 +44,44 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
+#serial 15
+
 AC_DEFUN([AX_COMPILER_VENDOR],
-[
-AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
- [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
-  # note: don't check for gcc first since some other compilers define __GNUC__
-  for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale:__PATHCC__,__PATHSCALE__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
-    vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
+[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
+  dnl Please add if possible support to ax_compiler_version.m4
+  [# note: don't check for gcc first since some other compilers define __GNUC__
+  vendors="intel:     __ICC,__ECC,__INTEL_COMPILER
+           ibm:       __xlc__,__xlC__,__IBMC__,__IBMCPP__
+           pathscale: __PATHCC__,__PATHSCALE__
+           clang:     __clang__
+           cray:      _CRAYC
+           fujitsu:   __FUJITSU
+           gnu:       __GNUC__
+           sun:       __SUNPRO_C,__SUNPRO_CC
+           hp:        __HP_cc,__HP_aCC
+           dec:       __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
+           borland:   __BORLANDC__,__CODEGEARC__,__TURBOC__
+           comeau:    __COMO__
+           kai:       __KCC
+           lcc:       __LCC__
+           sgi:       __sgi,sgi
+           microsoft: _MSC_VER
+           metrowerks: __MWERKS__
+           watcom:    __WATCOMC__
+           portland:  __PGI
+	   tcc:       __TINYC__
+           unknown:   UNKNOWN"
+  for ventest in $vendors; do
+    case $ventest in
+      *:) vendor=$ventest; continue ;;
+      *)  vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;;
+    esac
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
-#if !($vencpp)
-      thisisanerror;
-#endif
-])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
+      #if !($vencpp)
+        thisisanerror;
+      #endif
+    ])], [break])
   done
+  ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1`
  ])
 ])
diff --git a/m4/ax_ext.m4 b/m4/ax_ext.m4
index 98233a3b31c12503361842b529915ef4a92ae2e0..86fb3985aaf6b94485e8135972e9fb9984971231 100644
--- a/m4/ax_ext.m4
+++ b/m4/ax_ext.m4
@@ -9,9 +9,9 @@
 # DESCRIPTION
 #
 #   Find supported SIMD extensions by requesting cpuid. When an SIMD
-#   extension is found, the -m"simdextensionname" is added to SIMD_FLAGS
-#   (only if compilator support it) (ie : if "sse2" is available "-msse2" is
-#   added to SIMD_FLAGS)
+#   extension is found, the -m"simdextensionname" is added to SIMD_FLAGS if
+#   compiler supports it. For example, if "sse2" is available, then "-msse2"
+#   is added to SIMD_FLAGS.
 #
 #   This macro calls:
 #
@@ -19,131 +19,225 @@
 #
 #   And defines:
 #
-#     HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3 /
-#     HAVE_SSE41 / HAVE_SSE42 / HAVE_AVX
+#     HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3 / HAVE_SSE4.1 / HAVE_SSE4.2 / HAVE_AVX
 #
 # LICENSE
 #
-#   Copyright (c) 2008 Christophe Tournayre <turn3r@users.sourceforge.net>
+#   Copyright (c) 2007 Christophe Tournayre <turn3r@users.sourceforge.net>
+#   Copyright (c) 2013 Michael Petch <mpetch@capp-sysware.com>
 #
 #   Copying and distribution of this file, with or without modification, are
 #   permitted in any medium without royalty provided the copyright notice
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 9
+#serial 13
 
 AC_DEFUN([AX_EXT],
 [
-  AC_REQUIRE([AX_GCC_X86_CPUID])
-
-  AX_GCC_X86_CPUID(0x00000001)
-  ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3`
-  edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4`
-
- AC_CACHE_CHECK([whether mmx is supported], [ax_cv_have_mmx_ext],
-  [
-    ax_cv_have_mmx_ext=no
-    if test "$((0x$edx>>23&0x01))" = 1; then
-      ax_cv_have_mmx_ext=yes
-    fi
-  ])
-
- AC_CACHE_CHECK([whether sse is supported], [ax_cv_have_sse_ext],
-  [
-    ax_cv_have_sse_ext=no
-    if test "$((0x$edx>>25&0x01))" = 1; then
-      ax_cv_have_sse_ext=yes
-    fi
-  ])
-
- AC_CACHE_CHECK([whether sse2 is supported], [ax_cv_have_sse2_ext],
-  [
-    ax_cv_have_sse2_ext=no
-    if test "$((0x$edx>>26&0x01))" = 1; then
-      ax_cv_have_sse2_ext=yes
-    fi
-  ])
-
- AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
-  [
-    ax_cv_have_sse3_ext=no
-    if test "$((0x$ecx&0x01))" = 1; then
-      ax_cv_have_sse3_ext=yes
-    fi
-  ])
-
- AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
-  [
-    ax_cv_have_ssse3_ext=no
-    if test "$((0x$ecx>>9&0x01))" = 1; then
-      ax_cv_have_ssse3_ext=yes
-    fi
-  ])
-
- AC_CACHE_CHECK([whether sse4.1 is supported], [ax_cv_have_sse41_ext],
-  [
-    ax_cv_have_sse41_ext=no
-    if test "$((0x$ecx>>19&0x01))" = 1; then
-      ax_cv_have_sse41_ext=yes
-    fi
-  ])
-
- AC_CACHE_CHECK([whether sse4.2 is supported], [ax_cv_have_sse42_ext],
-  [
-    ax_cv_have_sse42_ext=no
-    if test "$((0x$ecx>>20&0x01))" = 1; then
-      ax_cv_have_sse42_ext=yes
-    fi
-  ])
-
- AC_CACHE_CHECK([whether avx is supported], [ax_cv_have_avx_ext],
-  [
-    ax_cv_have_avx_ext=no
-    if test "$((0x$ecx>>28&0x01))" = 1; then
-      ax_cv_have_avx_ext=yes
-    fi
-  ])
-
-  if test "$ax_cv_have_mmx_ext" = yes; then
-    AC_DEFINE(HAVE_MMX,, [Support MMX instructions])
-    AX_CHECK_COMPILE_FLAG(-mmmx, SIMD_FLAGS="$SIMD_FLAGS -mmmx", [])
-  fi
-
-  if test "$ax_cv_have_sse_ext" = yes; then
-    AC_DEFINE(HAVE_SSE,, [Support SSE (Streaming SIMD Extensions) instructions])
-    AX_CHECK_COMPILE_FLAG(-msse, SIMD_FLAGS="$SIMD_FLAGS -msse", [])
-  fi
-
-  if test "$ax_cv_have_sse2_ext" = yes; then
-    AC_DEFINE(HAVE_SSE2,, [Support SSE2 (Streaming SIMD Extensions 2) instructions])
-    AX_CHECK_COMPILE_FLAG(-msse2, SIMD_FLAGS="$SIMD_FLAGS -msse2", [])
-  fi
-
-  if test "$ax_cv_have_sse3_ext" = yes; then
-    AC_DEFINE(HAVE_SSE3,, [Support SSE3 (Streaming SIMD Extensions 3) instructions])
-    AX_CHECK_COMPILE_FLAG(-msse3, SIMD_FLAGS="$SIMD_FLAGS -msse3", [])
-  fi
-
-  if test "$ax_cv_have_ssse3_ext" = yes; then
-    AC_DEFINE(HAVE_SSSE3,, [Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])
-    AX_CHECK_COMPILE_FLAG(-mssse3, SIMD_FLAGS="$SIMD_FLAGS -mssse3", [])
-  fi
-
-  if test "$ax_cv_have_sse41_ext" = yes; then
-    AC_DEFINE(HAVE_SSE41,, [Support SSE4.1 (Streaming SIMD Extensions 4.1) instructions])
-    AX_CHECK_COMPILE_FLAG(-msse4.1, SIMD_FLAGS="$SIMD_FLAGS -msse4.1", [])
-  fi
-
-  if test "$ax_cv_have_sse42_ext" = yes; then
-    AC_DEFINE(HAVE_SSE42, 1,[Support SSE4.2 (Streaming SIMD Extensions 4.2) instructions])
-    AX_CHECK_COMPILE_FLAG(-msse4.2, SIMD_FLAGS="$SIMD_FLAGS -msse4.2", [])
-  fi
-
-  if test "$ax_cv_have_avx_ext" = yes; then
-    AC_DEFINE(HAVE_AVX,,[Support AVX (Advanced Vector Extensions) instructions])
-    AX_CHECK_COMPILE_FLAG(-mavx, SIMD_FLAGS="$SIMD_FLAGS -mavx", [])
-  fi
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
+  case $host_cpu in
+    powerpc*)
+      AC_CACHE_CHECK([whether altivec is supported], [ax_cv_have_altivec_ext],
+          [
+            if test `/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.optional.altivec` != 0; then
+                if test `/usr/sbin/sysctl -n hw.optional.altivec` = 1; then
+                  ax_cv_have_altivec_ext=yes
+                fi
+            fi
+          ])
+
+          if test "$ax_cv_have_altivec_ext" = yes; then
+            AC_DEFINE(HAVE_ALTIVEC,,[Support Altivec instructions])
+            AX_CHECK_COMPILE_FLAG(-faltivec, SIMD_FLAGS="$SIMD_FLAGS -faltivec", [])
+          fi
+    ;;
+
+
+    i[[3456]]86*|x86_64*|amd64*)
+
+      AC_REQUIRE([AX_GCC_X86_CPUID])
+      AC_REQUIRE([AX_GCC_X86_AVX_XGETBV])
+
+      AX_GCC_X86_CPUID(0x00000001)
+      ecx=0
+      edx=0
+      if test "$ax_cv_gcc_x86_cpuid_0x00000001" != "unknown";
+      then
+        ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3`
+        edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4`
+      fi
+
+      AC_CACHE_CHECK([whether mmx is supported], [ax_cv_have_mmx_ext],
+      [
+        ax_cv_have_mmx_ext=no
+        if test "$((0x$edx>>23&0x01))" = 1; then
+          ax_cv_have_mmx_ext=yes
+        fi
+      ])
+
+      AC_CACHE_CHECK([whether sse is supported], [ax_cv_have_sse_ext],
+      [
+        ax_cv_have_sse_ext=no
+        if test "$((0x$edx>>25&0x01))" = 1; then
+          ax_cv_have_sse_ext=yes
+        fi
+      ])
+
+      AC_CACHE_CHECK([whether sse2 is supported], [ax_cv_have_sse2_ext],
+      [
+        ax_cv_have_sse2_ext=no
+        if test "$((0x$edx>>26&0x01))" = 1; then
+          ax_cv_have_sse2_ext=yes
+        fi
+      ])
+
+      AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
+      [
+        ax_cv_have_sse3_ext=no
+        if test "$((0x$ecx&0x01))" = 1; then
+          ax_cv_have_sse3_ext=yes
+        fi
+      ])
+
+      AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
+      [
+        ax_cv_have_ssse3_ext=no
+        if test "$((0x$ecx>>9&0x01))" = 1; then
+          ax_cv_have_ssse3_ext=yes
+        fi
+      ])
+
+      AC_CACHE_CHECK([whether sse4.1 is supported], [ax_cv_have_sse41_ext],
+      [
+        ax_cv_have_sse41_ext=no
+        if test "$((0x$ecx>>19&0x01))" = 1; then
+          ax_cv_have_sse41_ext=yes
+        fi
+      ])
+
+      AC_CACHE_CHECK([whether sse4.2 is supported], [ax_cv_have_sse42_ext],
+      [
+        ax_cv_have_sse42_ext=no
+        if test "$((0x$ecx>>20&0x01))" = 1; then
+          ax_cv_have_sse42_ext=yes
+        fi
+      ])
+
+      AC_CACHE_CHECK([whether avx is supported by processor], [ax_cv_have_avx_cpu_ext],
+      [
+        ax_cv_have_avx_cpu_ext=no
+        if test "$((0x$ecx>>28&0x01))" = 1; then
+          ax_cv_have_avx_cpu_ext=yes
+        fi
+      ])
+
+      if test x"$ax_cv_have_avx_cpu_ext" = x"yes"; then
+        AX_GCC_X86_AVX_XGETBV(0x00000000)
+
+        xgetbv_eax="0"
+        if test x"$ax_cv_gcc_x86_avx_xgetbv_0x00000000" != x"unknown"; then
+          xgetbv_eax=`echo $ax_cv_gcc_x86_avx_xgetbv_0x00000000 | cut -d ":" -f 1`
+        fi
+
+        AC_CACHE_CHECK([whether avx is supported by operating system], [ax_cv_have_avx_ext],
+        [
+          ax_cv_have_avx_ext=no
+
+          if test "$((0x$ecx>>27&0x01))" = 1; then
+            if test "$((0x$xgetbv_eax&0x6))" = 6; then
+              ax_cv_have_avx_ext=yes
+            fi
+          fi
+        ])
+        if test x"$ax_cv_have_avx_ext" = x"no"; then
+          AC_MSG_WARN([Your processor supports AVX, but your operating system doesn't])
+        fi
+      fi
+
+      if test "$ax_cv_have_mmx_ext" = yes; then
+        AX_CHECK_COMPILE_FLAG(-mmmx, ax_cv_support_mmx_ext=yes, [])
+        if test x"$ax_cv_support_mmx_ext" = x"yes"; then
+          SIMD_FLAGS="$SIMD_FLAGS -mmmx"
+          AC_DEFINE(HAVE_MMX,,[Support mmx instructions])
+        else
+          AC_MSG_WARN([Your processor supports mmx instructions but not your compiler, can you try another compiler?])
+        fi
+      fi
+
+      if test "$ax_cv_have_sse_ext" = yes; then
+        AX_CHECK_COMPILE_FLAG(-msse, ax_cv_support_sse_ext=yes, [])
+        if test x"$ax_cv_support_sse_ext" = x"yes"; then
+          SIMD_FLAGS="$SIMD_FLAGS -msse"
+          AC_DEFINE(HAVE_SSE,,[Support SSE (Streaming SIMD Extensions) instructions])
+        else
+          AC_MSG_WARN([Your processor supports sse instructions but not your compiler, can you try another compiler?])
+        fi
+      fi
+
+      if test "$ax_cv_have_sse2_ext" = yes; then
+        AX_CHECK_COMPILE_FLAG(-msse2, ax_cv_support_sse2_ext=yes, [])
+        if test x"$ax_cv_support_sse2_ext" = x"yes"; then
+          SIMD_FLAGS="$SIMD_FLAGS -msse2"
+          AC_DEFINE(HAVE_SSE2,,[Support SSE2 (Streaming SIMD Extensions 2) instructions])
+        else
+          AC_MSG_WARN([Your processor supports sse2 instructions but not your compiler, can you try another compiler?])
+        fi
+      fi
+
+      if test "$ax_cv_have_sse3_ext" = yes; then
+        AX_CHECK_COMPILE_FLAG(-msse3, ax_cv_support_sse3_ext=yes, [])
+        if test x"$ax_cv_support_sse3_ext" = x"yes"; then
+          SIMD_FLAGS="$SIMD_FLAGS -msse3"
+          AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) instructions])
+        else
+          AC_MSG_WARN([Your processor supports sse3 instructions but not your compiler, can you try another compiler?])
+        fi
+      fi
+
+      if test "$ax_cv_have_ssse3_ext" = yes; then
+        AX_CHECK_COMPILE_FLAG(-mssse3, ax_cv_support_ssse3_ext=yes, [])
+        if test x"$ax_cv_support_ssse3_ext" = x"yes"; then
+          SIMD_FLAGS="$SIMD_FLAGS -mssse3"
+          AC_DEFINE(HAVE_SSSE3,,[Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])
+        else
+          AC_MSG_WARN([Your processor supports ssse3 instructions but not your compiler, can you try another compiler?])
+        fi
+      fi
+
+      if test "$ax_cv_have_sse41_ext" = yes; then
+        AX_CHECK_COMPILE_FLAG(-msse4.1, ax_cv_support_sse41_ext=yes, [])
+        if test x"$ax_cv_support_sse41_ext" = x"yes"; then
+          SIMD_FLAGS="$SIMD_FLAGS -msse4.1"
+          AC_DEFINE(HAVE_SSE4_1,,[Support SSSE4.1 (Streaming SIMD Extensions 4.1) instructions])
+        else
+          AC_MSG_WARN([Your processor supports sse4.1 instructions but not your compiler, can you try another compiler?])
+        fi
+      fi
+
+      if test "$ax_cv_have_sse42_ext" = yes; then
+        AX_CHECK_COMPILE_FLAG(-msse4.2, ax_cv_support_sse42_ext=yes, [])
+        if test x"$ax_cv_support_sse42_ext" = x"yes"; then
+          SIMD_FLAGS="$SIMD_FLAGS -msse4.2"
+          AC_DEFINE(HAVE_SSE4_2,,[Support SSSE4.2 (Streaming SIMD Extensions 4.2) instructions])
+        else
+          AC_MSG_WARN([Your processor supports sse4.2 instructions but not your compiler, can you try another compiler?])
+        fi
+      fi
+
+      if test "$ax_cv_have_avx_ext" = yes; then
+        AX_CHECK_COMPILE_FLAG(-mavx, ax_cv_support_avx_ext=yes, [])
+        if test x"$ax_cv_support_avx_ext" = x"yes"; then
+          SIMD_FLAGS="$SIMD_FLAGS -mavx"
+          AC_DEFINE(HAVE_AVX,,[Support AVX (Advanced Vector Extensions) instructions])
+        else
+          AC_MSG_WARN([Your processor supports avx instructions but not your compiler, can you try another compiler?])
+        fi
+      fi
+
+  ;;
+  esac
 
   AC_SUBST(SIMD_FLAGS)
 ])
diff --git a/m4/ax_func_posix_memalign.m4 b/m4/ax_func_posix_memalign.m4
index eeca0a7fe3f946eb48564749886669570c7d4304..bd60adcbc81a5ce5c9e68f71081e6872e5139b0a 100644
--- a/m4/ax_func_posix_memalign.m4
+++ b/m4/ax_func_posix_memalign.m4
@@ -1,5 +1,5 @@
 # ===========================================================================
-#         http://autoconf-archive.cryp.to/ax_func_posix_memalign.html
+#  http://www.gnu.org/software/autoconf-archive/ax_func_posix_memalign.html
 # ===========================================================================
 #
 # SYNOPSIS
@@ -19,7 +19,10 @@
 #
 #   Copying and distribution of this file, with or without modification, are
 #   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved.
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 7
 
 AC_DEFUN([AX_FUNC_POSIX_MEMALIGN],
 [AC_CACHE_CHECK([for working posix_memalign],
diff --git a/m4/ax_gcc_archflag.m4 b/m4/ax_gcc_archflag.m4
index 590015b15f97bf8e56da76c081222da278550304..0d0bf431138689487a5fb63a419dfc58ae70d5d0 100644
--- a/m4/ax_gcc_archflag.m4
+++ b/m4/ax_gcc_archflag.m4
@@ -1,5 +1,5 @@
 # ===========================================================================
-#            http://autoconf-archive.cryp.to/ax_gcc_archflag.html
+#      http://www.gnu.org/software/autoconf-archive/ax_gcc_archflag.html
 # ===========================================================================
 #
 # SYNOPSIS
@@ -11,7 +11,7 @@
 #   This macro tries to guess the "native" arch corresponding to the target
 #   architecture for use with gcc's -march=arch or -mtune=arch flags. If
 #   found, the cache variable $ax_cv_gcc_archflag is set to this flag and
-#   ACTION-SUCCESS is executed; otherwise $ax_cv_gcc_archflag is is set to
+#   ACTION-SUCCESS is executed; otherwise $ax_cv_gcc_archflag is set to
 #   "unknown" and ACTION-FAILURE is executed. The default ACTION-SUCCESS is
 #   to add $ax_cv_gcc_archflag to the end of $CFLAGS.
 #
@@ -27,7 +27,7 @@
 #   When cross-compiling, or if $CC is not gcc, then ACTION-FAILURE is
 #   called unless the user specified --with-gcc-arch manually.
 #
-#   Requires macros: AX_CHECK_COMPILER_FLAGS, AX_GCC_X86_CPUID
+#   Requires macros: AX_CHECK_COMPILE_FLAG, AX_GCC_X86_CPUID
 #
 #   (The main emphasis here is on recent CPUs, on the principle that doing
 #   high-performance computing on old hardware is uncommon.)
@@ -36,6 +36,7 @@
 #
 #   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
 #   Copyright (c) 2008 Matteo Frigo
+#   Copyright (c) 2014 Tsukasa Oi
 #
 #   This program is free software: you can redistribute it and/or modify it
 #   under the terms of the GNU General Public License as published by the
@@ -63,11 +64,15 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
+#serial 17
+
 AC_DEFUN([AX_GCC_ARCHFLAG],
 [AC_REQUIRE([AC_PROG_CC])
 AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([AC_PROG_SED])
+AC_REQUIRE([AX_COMPILER_VENDOR])
 
-AC_ARG_WITH(gcc-arch, [AC_HELP_STRING([--with-gcc-arch=<arch>], [use architecture <arch> for gcc -march/-mtune, instead of guessing])],
+AC_ARG_WITH(gcc-arch, [AS_HELP_STRING([--with-gcc-arch=<arch>], [use architecture <arch> for gcc -march/-mtune, instead of guessing])],
 	ax_gcc_arch=$withval, ax_gcc_arch=yes)
 
 AC_MSG_CHECKING([for gcc architecture flag])
@@ -82,54 +87,70 @@ if test "x$ax_gcc_arch" = xyes; then
 ax_gcc_arch=""
 if test "$cross_compiling" = no; then
 case $host_cpu in
-  i[[3456]]86*|x86_64*) # use cpuid codes, in part from x86info-1.7 by D. Jones
+  i[[3456]]86*|x86_64*|amd64*) # use cpuid codes
      AX_GCC_X86_CPUID(0)
      AX_GCC_X86_CPUID(1)
      case $ax_cv_gcc_x86_cpuid_0 in
-       *:756e6547:*:*) # Intel
+       *:756e6547:6c65746e:49656e69) # Intel
           case $ax_cv_gcc_x86_cpuid_1 in
-	    *5[[48]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;;
+	    *5[[4578]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;;
+	    *5[[123]]?:*:*:*) ax_gcc_arch=pentium ;;
+	    *0?61?:*:*:*|?61?:*:*:*|61?:*:*:*) ax_gcc_arch=pentiumpro ;;
+	    *0?6[[356]]?:*:*:*|?6[[356]]?:*:*:*|6[[356]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
+	    *0?6[[78ab]]?:*:*:*|?6[[78ab]]?:*:*:*|6[[78ab]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
+	    *0?6[[9d]]?:*:*:*|?6[[9d]]?:*:*:*|6[[9d]]?:*:*:*|*1?65?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;;
+	    *0?6e?:*:*:*|?6e?:*:*:*|6e?:*:*:*) ax_gcc_arch="yonah pentium-m pentium3 pentiumpro" ;;
+	    *0?6f?:*:*:*|?6f?:*:*:*|6f?:*:*:*|*1?66?:*:*:*) ax_gcc_arch="core2 pentium-m pentium3 pentiumpro" ;;
+	    *1?6[[7d]]?:*:*:*) ax_gcc_arch="penryn core2 pentium-m pentium3 pentiumpro" ;;
+	    *1?6[[aef]]?:*:*:*|*2?6e?:*:*:*) ax_gcc_arch="nehalem corei7 core2 pentium-m pentium3 pentiumpro" ;;
+	    *2?6[[5cf]]?:*:*:*) ax_gcc_arch="westmere corei7 core2 pentium-m pentium3 pentiumpro" ;;
+	    *2?6[[ad]]?:*:*:*) ax_gcc_arch="sandybridge corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
+	    *3?6[[ae]]?:*:*:*) ax_gcc_arch="ivybridge core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
+	    *3?6[[cf]]?:*:*:*|*4?6[[56]]?:*:*:*) ax_gcc_arch="haswell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
+	    *3?6d?:*:*:*) ax_gcc_arch="broadwell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
+	    *1?6c?:*:*:*|*2?6[[67]]?:*:*:*|*3?6[[56]]?:*:*:*) ax_gcc_arch="bonnell atom core2 pentium-m pentium3 pentiumpro" ;;
+	    *3?67?:*:*:*|*[[45]]?6[[ad]]?:*:*:*) ax_gcc_arch="silvermont atom core2 pentium-m pentium3 pentiumpro" ;;
+	    *000?f[[012]]?:*:*:*|?f[[012]]?:*:*:*|f[[012]]?:*:*:*) ax_gcc_arch="pentium4 pentiumpro" ;;
+	    *000?f[[346]]?:*:*:*|?f[[346]]?:*:*:*|f[[346]]?:*:*:*) ax_gcc_arch="nocona prescott pentium4 pentiumpro" ;;
+	    # fallback
 	    *5??:*:*:*) ax_gcc_arch=pentium ;;
-	    *6[[3456]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
-	    *6a?:*[[01]]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
-	    *6a?:*[[234]]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
-	    *6[[9d]]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;;
-	    *6[[78b]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
+	    *??6??:*:*:*) ax_gcc_arch="core2 pentiumpro" ;;
 	    *6??:*:*:*) ax_gcc_arch=pentiumpro ;;
-            *f3[[347]]:*:*:*|*f4[1347]:*:*:*)
-		case $host_cpu in
-                  x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;;
-                  *) ax_gcc_arch="prescott pentium4 pentiumpro" ;;
-                esac ;;
-            *f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";;
+	    *00??f??:*:*:*|??f??:*:*:*|?f??:*:*:*|f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro" ;;
           esac ;;
-       *:68747541:*:*) # AMD
+       *:68747541:444d4163:69746e65) # AMD
           case $ax_cv_gcc_x86_cpuid_1 in
 	    *5[[67]]?:*:*:*) ax_gcc_arch=k6 ;;
-	    *5[[8d]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;;
-	    *5[[9]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;;
-	    *60?:*:*:*) ax_gcc_arch=k7 ;;
+	    *5[[8]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;;
+	    *5[[9d]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;;
 	    *6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;;
 	    *6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;;
-	    *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;;
-	    *6[[68a]]?:*:*:*)
-	       AX_GCC_X86_CPUID(0x80000006) # L2 cache size
-	       case $ax_cv_gcc_x86_cpuid_0x80000006 in
-                 *:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256
-			ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;;
-                 *) ax_gcc_arch="athlon-4 athlon k7" ;;
-	       esac ;;
-	    *f[[4cef8b]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;;
-	    *f5?:*:*:*) ax_gcc_arch="opteron k8" ;;
-	    *f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;;
-	    *f??:*:*:*) ax_gcc_arch="k8" ;;
+	    *6[[678a]]?:*:*:*) ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;;
+	    *000?f[[4578bcef]]?:*:*:*|?f[[4578bcef]]?:*:*:*|f[[4578bcef]]?:*:*:*|*001?f[[4578bcf]]?:*:*:*|1?f[[4578bcf]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;;
+	    *002?f[[13457bcf]]?:*:*:*|2?f[[13457bcf]]?:*:*:*|*004?f[[138bcf]]?:*:*:*|4?f[[138bcf]]?:*:*:*|*005?f[[df]]?:*:*:*|5?f[[df]]?:*:*:*|*006?f[[8bcf]]?:*:*:*|6?f[[8bcf]]?:*:*:*|*007?f[[cf]]?:*:*:*|7?f[[cf]]?:*:*:*|*00c?f1?:*:*:*|c?f1?:*:*:*|*020?f3?:*:*:*|20?f3?:*:*:*) ax_gcc_arch="athlon64-sse3 k8-sse3 athlon64 k8" ;;
+	    *010?f[[245689a]]?:*:*:*|10?f[[245689a]]?:*:*:*|*030?f1?:*:*:*|30?f1?:*:*:*) ax_gcc_arch="barcelona amdfam10 k8" ;;
+	    *050?f[[12]]?:*:*:*|50?f[[12]]?:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;;
+	    *060?f1?:*:*:*|60?f1?:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;;
+	    *060?f2?:*:*:*|60?f2?:*:*:*|*061?f[[03]]?:*:*:*|61?f[[03]]?:*:*:*) ax_gcc_arch="bdver2 bdver1 amdfam10 k8" ;;
+	    *063?f0?:*:*:*|63?f0?:*:*:*) ax_gcc_arch="bdver3 bdver2 bdver1 amdfam10 k8" ;;
+	    *07[[03]]?f0?:*:*:*|7[[03]]?f0?:*:*:*) ax_gcc_arch="btver2 btver1 amdfam10 k8" ;;
+	    # fallback
+	    *0[[13]]??f??:*:*:*|[[13]]??f??:*:*:*) ax_gcc_arch="barcelona amdfam10 k8" ;;
+	    *020?f??:*:*:*|20?f??:*:*:*) ax_gcc_arch="athlon64-sse3 k8-sse3 athlon64 k8" ;;
+	    *05??f??:*:*:*|5??f??:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;;
+	    *060?f??:*:*:*|60?f??:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;;
+	    *061?f??:*:*:*|61?f??:*:*:*) ax_gcc_arch="bdver2 bdver1 amdfam10 k8" ;;
+	    *06??f??:*:*:*|6??f??:*:*:*) ax_gcc_arch="bdver3 bdver2 bdver1 amdfam10 k8" ;;
+	    *070?f??:*:*:*|70?f??:*:*:*) ax_gcc_arch="btver2 btver1 amdfam10 k8" ;;
+	    *???f??:*:*:*) ax_gcc_arch="amdfam10 k8" ;;
           esac ;;
-	*:746e6543:*:*) # IDT
+	*:746e6543:736c7561:48727561) # IDT / VIA (Centaur)
 	   case $ax_cv_gcc_x86_cpuid_1 in
 	     *54?:*:*:*) ax_gcc_arch=winchip-c6 ;;
-	     *58?:*:*:*) ax_gcc_arch=winchip2 ;;
+	     *5[[89]]?:*:*:*) ax_gcc_arch=winchip2 ;;
+	     *66?:*:*:*) ax_gcc_arch=winchip2 ;;
 	     *6[[78]]?:*:*:*) ax_gcc_arch=c3 ;;
-	     *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;;
+	     *6[[9adf]]?:*:*:*) ax_gcc_arch="c3-2 c3" ;;
 	   esac ;;
      esac
      if test x"$ax_gcc_arch" = x; then # fallback
@@ -143,7 +164,7 @@ case $host_cpu in
   sparc*)
      AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/])
      cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null`
-     cputype=`echo "$cputype" | tr -d ' -' |tr $as_cr_LETTERS $as_cr_letters`
+     cputype=`echo "$cputype" | tr -d ' -' | $SED 's/SPARCIIi/SPARCII/' |tr $as_cr_LETTERS $as_cr_letters`
      case $cputype in
          *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;;
          *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;;
@@ -165,8 +186,8 @@ case $host_cpu in
   alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;;
 
   powerpc*)
-     cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null`
-     cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'`
+     cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | $SED 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null`
+     cputype=`echo $cputype | $SED -e 's/ppc//g;s/ *//g'`
      case $cputype in
        *750*) ax_gcc_arch="750 G3" ;;
        *740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;;
@@ -185,17 +206,23 @@ fi # not cross-compiling
 fi # guess arch
 
 if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then
-for arch in $ax_gcc_arch; do
-  if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code
-    flags="-mtune=$arch"
-    # -mcpu=$arch and m$arch generate nonportable code on every arch except
-    # x86.  And some other arches (e.g. Alpha) don't accept -mtune.  Grrr.
-    case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac
-  else
-    flags="-march=$arch -mcpu=$arch -m$arch"
-  fi
-  for flag in $flags; do
-    AX_CHECK_COMPILER_FLAGS($flag, [ax_cv_gcc_archflag=$flag; break])
+if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code
+  flag_prefixes="-mtune="
+  if test "x$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" = xclang; then flag_prefixes="-march="; fi
+  # -mcpu=$arch and m$arch generate nonportable code on every arch except
+  # x86.  And some other arches (e.g. Alpha) don't accept -mtune.  Grrr.
+  case $host_cpu in i*86|x86_64*|amd64*) flag_prefixes="$flag_prefixes -mcpu= -m";; esac
+else
+  flag_prefixes="-march= -mcpu= -m"
+fi
+for flag_prefix in $flag_prefixes; do
+  for arch in $ax_gcc_arch; do
+    flag="$flag_prefix$arch"
+    AX_CHECK_COMPILE_FLAG($flag, [if test "x$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" = xclang; then
+      if test "x[]m4_default([$1],yes)" = xyes; then
+	if test "x$flag" = "x-march=$arch"; then flag=-mtune=$arch; fi
+      fi
+    fi; ax_cv_gcc_archflag=$flag; break])
   done
   test "x$ax_cv_gcc_archflag" = xunknown || break
 done
diff --git a/m4/ax_check_compiler_flags.m4 b/m4/ax_gcc_x86_avx_xgetbv.m4
similarity index 50%
rename from m4/ax_check_compiler_flags.m4
rename to m4/ax_gcc_x86_avx_xgetbv.m4
index 21f9e6fda1dab4747ea37e6885dbd08b8cb624a7..0624eebc9ab03e24ede44a868096c3430e1a11ab 100644
--- a/m4/ax_check_compiler_flags.m4
+++ b/m4/ax_gcc_x86_avx_xgetbv.m4
@@ -1,24 +1,32 @@
 # ===========================================================================
-#        http://autoconf-archive.cryp.to/ax_check_compiler_flags.html
+#   http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_avx_xgetbv.html
 # ===========================================================================
 #
 # SYNOPSIS
 #
-#   AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
+#   AX_GCC_X86_AVX_XGETBV
 #
 # DESCRIPTION
 #
-#   Check whether the given compiler FLAGS work with the current language's
-#   compiler, or whether they give an error. (Warnings, however, are
-#   ignored.)
+#   On later x86 processors with AVX SIMD support, with gcc or a compiler
+#   that has a compatible syntax for inline assembly instructions, run a
+#   small program that executes the xgetbv instruction with input OP. This
+#   can be used to detect if the OS supports AVX instruction usage.
 #
-#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
-#   success/failure.
+#   On output, the values of the eax and edx registers are stored as
+#   hexadecimal strings as "eax:edx" in the cache variable
+#   ax_cv_gcc_x86_avx_xgetbv.
+#
+#   If the xgetbv instruction fails (because you are running a
+#   cross-compiler, or because you are not using gcc, or because you are on
+#   a processor that doesn't have this instruction),
+#   ax_cv_gcc_x86_avx_xgetbv_OP is set to the string "unknown".
+#
+#   This macro mainly exists to be used in AX_EXT.
 #
 # LICENSE
 #
-#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
-#   Copyright (c) 2009 Matteo Frigo
+#   Copyright (c) 2013 Michael Petch <mpetch@capp-sysware.com>
 #
 #   This program is free software: you can redistribute it and/or modify it
 #   under the terms of the GNU General Public License as published by the
@@ -46,29 +54,26 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
-AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
-[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
-AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
-dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
-AS_LITERAL_IF([$1],
-  [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1]), [
-      ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
-      _AC_LANG_PREFIX[]FLAGS="$1"
-      AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-        AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
-        AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
-      _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
-  [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
-   _AC_LANG_PREFIX[]FLAGS="$1"
-   AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-     eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
-     eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
-   _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
-eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])
-AC_MSG_RESULT($ax_check_compiler_flags)
-if test "x$ax_check_compiler_flags" = xyes; then
-	m4_default([$2], :)
-else
-	m4_default([$3], :)
-fi
-])dnl AX_CHECK_COMPILER_FLAGS
+#serial 1
+
+AC_DEFUN([AX_GCC_X86_AVX_XGETBV],
+[AC_REQUIRE([AC_PROG_CC])
+AC_LANG_PUSH([C])
+AC_CACHE_CHECK(for x86-AVX xgetbv $1 output, ax_cv_gcc_x86_avx_xgetbv_$1,
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
+     int op = $1, eax, edx;
+     FILE *f;
+      /* Opcodes for xgetbv */
+      __asm__(".byte 0x0f, 0x01, 0xd0"
+        : "=a" (eax), "=d" (edx)
+        : "c" (op));
+     f = fopen("conftest_xgetbv", "w"); if (!f) return 1;
+     fprintf(f, "%x:%x\n", eax, edx);
+     fclose(f);
+     return 0;
+])],
+     [ax_cv_gcc_x86_avx_xgetbv_$1=`cat conftest_xgetbv`; rm -f conftest_xgetbv],
+     [ax_cv_gcc_x86_avx_xgetbv_$1=unknown; rm -f conftest_xgetbv],
+     [ax_cv_gcc_x86_avx_xgetbv_$1=unknown])])
+AC_LANG_POP([C])
+])
diff --git a/m4/ax_gcc_x86_cpuid.m4 b/m4/ax_gcc_x86_cpuid.m4
index 321dce72dbfa59ed46e1ec5e82642f364efb12f0..7d46fee0219e970f98e960a5b0717a9ec061ee95 100644
--- a/m4/ax_gcc_x86_cpuid.m4
+++ b/m4/ax_gcc_x86_cpuid.m4
@@ -1,5 +1,5 @@
 # ===========================================================================
-#            http://autoconf-archive.cryp.to/ax_gcc_x86_cpuid.html
+#     http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
 # ===========================================================================
 #
 # SYNOPSIS
@@ -55,6 +55,8 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
+#serial 7
+
 AC_DEFUN([AX_GCC_X86_CPUID],
 [AC_REQUIRE([AC_PROG_CC])
 AC_LANG_PUSH([C])
diff --git a/m4/ax_lib_hdf5.m4 b/m4/ax_lib_hdf5.m4
index d698069590342f18c7101b845f1886c3628a6663..3174385fc7394a927f7a136c06aab74a875ef296 100644
--- a/m4/ax_lib_hdf5.m4
+++ b/m4/ax_lib_hdf5.m4
@@ -20,15 +20,17 @@
 #
 #     no   - do not check for the HDF5 library.
 #     yes  - do check for HDF5 library in standard locations.
-#     path - complete path to where lib/libhdf5* libraries and
-#            include/H5* include files reside.
+#     path - complete path to the HDF5 helper script h5cc or h5pcc.
 #
 #   If HDF5 is successfully found, this macro calls
 #
 #     AC_SUBST(HDF5_VERSION)
+#     AC_SUBST(HDF5_CC)
 #     AC_SUBST(HDF5_CFLAGS)
 #     AC_SUBST(HDF5_CPPFLAGS)
 #     AC_SUBST(HDF5_LDFLAGS)
+#     AC_SUBST(HDF5_LIBS)
+#     AC_SUBST(HDF5_FC)
 #     AC_SUBST(HDF5_FFLAGS)
 #     AC_SUBST(HDF5_FLIBS)
 #     AC_DEFINE(HAVE_HDF5)
@@ -62,6 +64,16 @@
 #
 #     echo "HDF5 support:  $with_hdf5"
 #
+#   You could also for example, override the default CC in "configure.ac" to
+#   enforce compilation with the compiler that HDF5 uses:
+#
+#     AX_LIB_HDF5([parallel])
+#     if test "$with_hdf5" = "yes"; then
+#             CC="$HDF5_CC"
+#     else
+#             AC_MSG_ERROR([Unable to find HDF5, we need parallel HDF5.])
+#     fi
+#
 # LICENSE
 #
 #   Copyright (c) 2009 Timothy Brown <tbrown@freeshell.org>
@@ -72,7 +84,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 6
+#serial 11
 
 AC_DEFUN([AX_LIB_HDF5], [
 
@@ -116,10 +128,13 @@ AC_ARG_WITH([hdf5],
 )
 
 dnl Set defaults to blank
+HDF5_CC=""
 HDF5_VERSION=""
 HDF5_CFLAGS=""
 HDF5_CPPFLAGS=""
 HDF5_LDFLAGS=""
+HDF5_LIBS=""
+HDF5_FC=""
 HDF5_FFLAGS=""
 HDF5_FLIBS=""
 
@@ -139,7 +154,7 @@ if test "$with_hdf5" = "yes"; then
         AC_MSG_RESULT([$H5CC])
     fi
     AC_MSG_CHECKING([for HDF5 libraries])
-    if test ! -x "$H5CC"; then
+    if test ! -f "$H5CC" || test ! -x "$H5CC"; then
         AC_MSG_RESULT([no])
         AC_MSG_WARN(m4_case(m4_normalize([$1]),
             [serial],  [
@@ -158,122 +173,85 @@ HDF5 support is being disabled (equivalent to --with-hdf5=no).
         with_hdf5="no"
         with_hdf5_fortran="no"
     else
+        dnl Get the h5cc output
+        HDF5_SHOW=$(eval $H5CC -show)
+
+        dnl Get the actual compiler used
+        HDF5_CC=$(eval $H5CC -show | $AWK '{print $[]1}')
+        if test "$HDF5_CC" = "ccache"; then
+            HDF5_CC=$(eval $H5CC -show | $AWK '{print $[]2}')
+        fi
+
         dnl h5cc provides both AM_ and non-AM_ options
         dnl depending on how it was compiled either one of
         dnl these are empty. Lets roll them both into one.
 
         dnl Look for "HDF5 Version: X.Y.Z"
-        HDF5_VERSION=$(eval $H5CC -showconfig | grep 'HDF5 Version:' \
+        HDF5_VERSION=$(eval $H5CC -showconfig | $GREP 'HDF5 Version:' \
             | $AWK '{print $[]3}')
 
-dnl A ideal situation would be where everything we needed was
-dnl in the AM_* variables. However most systems are not like this
-dnl and seem to have the values in the non-AM variables.
-dnl
-dnl We try the following to find the flags:
-dnl (1) Look for "NAME:" tags
-dnl (2) Look for "NAME/H5_NAME:" tags
-dnl (3) Look for "AM_NAME:" tags
-dnl
-        dnl (1)
-        dnl Look for "CFLAGS: "
-        HDF5_CFLAGS=$(eval $H5CC -showconfig | grep '\bCFLAGS:'   \
-            | $AWK -F: '{print $[]2}')
-        dnl Look for "CPPFLAGS"
-        HDF5_CPPFLAGS=$(eval $H5CC -showconfig | grep '\bCPPFLAGS:' \
-            | $AWK -F: '{print $[]2}')
-        dnl Look for "FFLAGS: "
-        HDF5_FFLAGS=$(eval $H5CC -showconfig | grep '\bFFLAGS:'   \
-            | $AWK -F: '{print $[]2}')
-        dnl Look for "LD_FLAGS"
-        HDF5_LDFLAGS=$(eval $H5CC -showconfig | grep '\bLDFLAGS:'   \
-            | $AWK -F: '{print $[]2}')
+        dnl A ideal situation would be where everything we needed was
+        dnl in the AM_* variables. However most systems are not like this
+        dnl and seem to have the values in the non-AM variables.
+        dnl
+        dnl We try the following to find the flags:
+        dnl (1) Look for "NAME:" tags
+        dnl (2) Look for "H5_NAME:" tags
+        dnl (3) Look for "AM_NAME:" tags
+        dnl
+        HDF5_tmp_flags=$(eval $H5CC -showconfig \
+            | $GREP 'FLAGS\|Extra libraries:' \
+            | $AWK -F: '{printf("%s "), $[]2}' )
 
-        dnl (2)
-        dnl CFLAGS/H5_CFLAGS: .../....
-        dnl We could use $SED with something like the following
-        dnl 's/CFLAGS.*\/H5_CFLAGS.*[:]\(.*\)\/\(.*\)/\1/p'
-        if test -z "$HDF5_CFLAGS"; then
-            HDF5_CFLAGS=$(eval $H5CC -showconfig \
-                | $SED -n 's/CFLAGS.*[:]\(.*\)\/\(.*\)/\1/p')
-        fi
-        dnl Look for "CPPFLAGS"
-        if test -z "$HDF5_CPPFLAGS"; then
-            HDF5_CPPFLAGS=$(eval $H5CC -showconfig \
-                | $SED -n 's/CPPFLAGS.*[:]\(.*\)\/\(.*\)/\1/p')
-        fi
-        dnl Look for "FFLAGS"
-        if test -z "$HDF5_FFLAGS"; then
-            HDF5_FFLAGS=$(eval $H5CC -showconfig \
-                | $SED -n 's/FFLAGS.*[:]\(.*\)\/\(.*\)/\1/p')
-        fi
-        dnl Look for "LD_FLAGS"
-        if test -z "$HDF5_LDFLAGS"; then
-            HDF5_LDFLAGS=$(eval $H5CC -showconfig \
-                | $SED -n 's/LDFLAGS.*[:]\(.*\)\/\(.*\)/\1/p')
-        fi
+        dnl Find the installation directory and append include/
+        HDF5_tmp_inst=$(eval $H5CC -showconfig \
+            | $GREP 'Installation point:' \
+            | $AWK '{print $[]NF}' )
 
-        dnl (3)
-        dnl Check to see if these are not empty strings. If so
-        dnl find the AM_ versions and use them.
-        if test -z "$HDF5_CFLAGS"; then
-            HDF5_CFLAGS=$(eval $H5CC -showconfig \
-                | grep 'AM_CFLAGS:' | $AWK -F: '{print $[]2}')
-        fi
-        if test -z "$HDF5_CPPFLAGS"; then
-            HDF5_CPPFLAGS=$(eval $H5CC -showconfig \
-                | grep 'AM_CPPFLAGS:' | $AWK -F: '{print $[]2}')
-        fi
-        dnl No equivalent AM_FFLAGS test in h5cc -showconfig
-        if test -z "$HDF5_LDFLAGS"; then
-            HDF5_LDFLAGS=$(eval $H5CC -showconfig \
-                | grep 'AM_LDFLAGS:' | $AWK -F: '{print $[]2}')
-        fi
+        dnl Add this to the CPPFLAGS
+        HDF5_CPPFLAGS="-I${HDF5_tmp_inst}/include"
 
-        dnl Frustratingly, the necessary -Idir,-Ldir still may not be found!
-        dnl Attempt to pry any more required include directories from wrapper.
-        for arg in `$H5CC -c -show` # Wrapper compile mode
-        do
-          case "$arg" in #(
+        dnl Now sort the flags out based upon their prefixes
+        for arg in $HDF5_SHOW $HDF5_tmp_flags ; do
+          case "$arg" in
             -I*) echo $HDF5_CPPFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \
                   || HDF5_CPPFLAGS="$arg $HDF5_CPPFLAGS"
               ;;
-          esac
-        done
-        for arg in `$H5CC -show` # Wrapper link mode
-        do
-          case "$arg" in #(
             -L*) echo $HDF5_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \
                   || HDF5_LDFLAGS="$arg $HDF5_LDFLAGS"
               ;;
+            -l*) echo $HDF5_LIBS | $GREP -e "$arg" 2>&1 >/dev/null \
+                  || HDF5_LIBS="$arg $HDF5_LIBS"
+              ;;
           esac
         done
 
+        HDF5_LIBS="$HDF5_LIBS -lhdf5"
         AC_MSG_RESULT([yes (version $[HDF5_VERSION])])
 
-        dnl Look for any extra libraries also needed to link properly
-        EXTRA_LIBS=$(eval $H5CC -showconfig | grep 'Extra libraries:'\
-            | $AWK -F: '{print $[]2}')
-
-        dnl Look for HDF5's high level library
-        ax_lib_hdf5_save_LDFLAGS=$LDFLAGS
+        dnl See if we can compile
+        ax_lib_hdf5_save_CC=$CC
+        ax_lib_hdf5_save_CPPFLAGS=$CPPFLAGS
         ax_lib_hdf5_save_LIBS=$LIBS
+        ax_lib_hdf5_save_LDFLAGS=$LDFLAGS
+        CC=$HDF5_CC
+        CPPFLAGS=$HDF5_CPPFLAGS
+        LIBS=$HDF5_LIBS
         LDFLAGS=$HDF5_LDFLAGS
-        AC_HAVE_LIBRARY([hdf5_hl],
-                        [HDF5_LDFLAGS="$HDF5_LDFLAGS -lhdf5_hl"],
-                        [],
-                        [-lhdf5 $EXTRA_LIBS])
+        AC_CHECK_HEADER([hdf5.h], [ac_cv_hadf5_h=yes], [ac_cv_hadf5_h=no])
+        AC_CHECK_LIB([hdf5], [H5Fcreate], [ac_cv_libhdf5=yes],
+                     [ac_cv_libhdf5=no])
+        if test "$ac_cv_hadf5_h" = "no" && test "$ac_cv_libhdf5" = "no" ; then
+          AC_MSG_WARN([Unable to compile HDF5 test program])
+        fi
+        dnl Look for HDF5's high level library
+        AC_HAVE_LIBRARY([hdf5_hl], [HDF5_LIBS="$HDF5_LIBS -lhdf5_hl"], [], [])
+
+        CC=$ax_lib_hdf5_save_CC
+        CPPFLAGS=$ax_lib_hdf5_save_CPPFLAGS
         LIBS=$ax_lib_hdf5_save_LIBS
         LDFLAGS=$ax_lib_hdf5_save_LDFLAGS
 
-        dnl Add the HDF5 library itself
-        HDF5_LDFLAGS="$HDF5_LDFLAGS -lhdf5"
-
-        dnl Add any EXTRA_LIBS afterwards
-        if test "$EXTRA_LIBS"; then
-            HDF5_LDFLAGS="$HDF5_LDFLAGS $EXTRA_LIBS"
-        fi
-
         AC_MSG_CHECKING([for matching HDF5 Fortran wrapper])
         dnl Presume HDF5 Fortran wrapper is just a name variant from H5CC
         H5FC=$(eval echo -n $H5CC | $SED -n 's/cc$/fc/p')
@@ -300,7 +278,7 @@ dnl
             done
 
             dnl Make Fortran link line by inserting Fortran libraries
-            for arg in $HDF5_LDFLAGS
+            for arg in $HDF5_LIBS
             do
               case "$arg" in #(
                 -lhdf5_hl) HDF5_FLIBS="$HDF5_FLIBS -lhdf5hl_fortran $arg"
@@ -317,13 +295,15 @@ dnl
         fi
 
 	AC_SUBST([HDF5_VERSION])
+	AC_SUBST([HDF5_CC])
 	AC_SUBST([HDF5_CFLAGS])
 	AC_SUBST([HDF5_CPPFLAGS])
 	AC_SUBST([HDF5_LDFLAGS])
+	AC_SUBST([HDF5_LIBS])
+	AC_SUBST([HDF5_FC])
 	AC_SUBST([HDF5_FFLAGS])
 	AC_SUBST([HDF5_FLIBS])
 	AC_DEFINE([HAVE_HDF5], [1], [Defined if you have HDF5 support])
     fi
 fi
-
 ])
diff --git a/m4/ax_prog_doxygen.m4 b/m4/ax_prog_doxygen.m4
index 6d4950cc1ad6dc1effbd9b998fab721d89a6e744..fd145991e636d4d47a3bf7000a222c41f0614104 100644
--- a/m4/ax_prog_doxygen.m4
+++ b/m4/ax_prog_doxygen.m4
@@ -1,5 +1,5 @@
 # ===========================================================================
-#            http://autoconf-archive.cryp.to/ax_prog_doxygen.html
+#      http://www.gnu.org/software/autoconf-archive/ax_prog_doxygen.html
 # ===========================================================================
 #
 # SYNOPSIS
@@ -161,19 +161,19 @@
 #     doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps
 #
 #     @DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag
-#   	  cd @DX_DOCDIR@/latex; \
-#   	  rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
-#   	  $(DX_LATEX) refman.tex; \
-#   	  $(MAKEINDEX_PATH) refman.idx; \
-#   	  $(DX_LATEX) refman.tex; \
-#   	  countdown=5; \
-#   	  while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
-#   			    refman.log > /dev/null 2>&1 \
-#   	     && test $$countdown -gt 0; do \
-#   	      $(DX_LATEX) refman.tex; \
-#   	      countdown=`expr $$countdown - 1`; \
-#   	  done; \
-#   	  $(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi
+#         cd @DX_DOCDIR@/latex; \
+#         rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
+#         $(DX_LATEX) refman.tex; \
+#         $(MAKEINDEX_PATH) refman.idx; \
+#         $(DX_LATEX) refman.tex; \
+#         countdown=5; \
+#         while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
+#                           refman.log > /dev/null 2>&1 \
+#            && test $$countdown -gt 0; do \
+#             $(DX_LATEX) refman.tex; \
+#             countdown=`expr $$countdown - 1`; \
+#         done; \
+#         $(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi
 #
 #     endif DX_COND_ps
 #
@@ -190,19 +190,19 @@
 #     doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf
 #
 #     @DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag
-#   	  cd @DX_DOCDIR@/latex; \
-#   	  rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
-#   	  $(DX_PDFLATEX) refman.tex; \
-#   	  $(DX_MAKEINDEX) refman.idx; \
-#   	  $(DX_PDFLATEX) refman.tex; \
-#   	  countdown=5; \
-#   	  while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
-#   			    refman.log > /dev/null 2>&1 \
-#   	     && test $$countdown -gt 0; do \
-#   	      $(DX_PDFLATEX) refman.tex; \
-#   	      countdown=`expr $$countdown - 1`; \
-#   	  done; \
-#   	  mv refman.pdf ../@PACKAGE@.pdf
+#         cd @DX_DOCDIR@/latex; \
+#         rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
+#         $(DX_PDFLATEX) refman.tex; \
+#         $(DX_MAKEINDEX) refman.idx; \
+#         $(DX_PDFLATEX) refman.tex; \
+#         countdown=5; \
+#         while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
+#                           refman.log > /dev/null 2>&1 \
+#            && test $$countdown -gt 0; do \
+#             $(DX_PDFLATEX) refman.tex; \
+#             countdown=`expr $$countdown - 1`; \
+#         done; \
+#         mv refman.pdf ../@PACKAGE@.pdf
 #
 #     endif DX_COND_pdf
 #
@@ -225,8 +225,9 @@
 #     doxygen-doc: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL)
 #
 #     @DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS)
-#   	  rm -rf @DX_DOCDIR@
-#   	  $(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG)
+#         rm -rf @DX_DOCDIR@
+#         $(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG)
+#         echo Timestamp >$@
 #
 #     DX_CLEANFILES = \
 #         @DX_DOCDIR@/@PACKAGE@.tag \
@@ -251,7 +252,10 @@
 #
 #   Copying and distribution of this file, with or without modification, are
 #   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved.
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 13
 
 ## ----------##
 ## Defaults. ##
@@ -259,7 +263,7 @@
 
 DX_ENV=""
 AC_DEFUN([DX_FEATURE_doc],  ON)
-AC_DEFUN([DX_FEATURE_dot],  ON)
+AC_DEFUN([DX_FEATURE_dot],  OFF)
 AC_DEFUN([DX_FEATURE_man],  OFF)
 AC_DEFUN([DX_FEATURE_html], ON)
 AC_DEFUN([DX_FEATURE_chm],  OFF)
@@ -361,12 +365,11 @@ if DX_TEST_FEATURE([$1]); then
     $5
     :
 fi
+AM_CONDITIONAL(DX_COND_$1, DX_TEST_FEATURE([$1]))
 if DX_TEST_FEATURE([$1]); then
-    AM_CONDITIONAL(DX_COND_$1, :)
     $6
     :
 else
-    AM_CONDITIONAL(DX_COND_$1, false)
     $7
     :
 fi
@@ -379,6 +382,7 @@ fi
 # DX_XXX_FEATURE(DEFAULT_STATE)
 # -----------------------------
 AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc],  [$1])])
+AC_DEFUN([DX_DOT_FEATURE],     [AC_DEFUN([DX_FEATURE_dot], [$1])])
 AC_DEFUN([DX_MAN_FEATURE],     [AC_DEFUN([DX_FEATURE_man],  [$1])])
 AC_DEFUN([DX_HTML_FEATURE],    [AC_DEFUN([DX_FEATURE_html], [$1])])
 AC_DEFUN([DX_CHM_FEATURE],     [AC_DEFUN([DX_FEATURE_chm],  [$1])])
@@ -491,11 +495,10 @@ DX_ARG_ABLE(pdf, [generate doxygen PDF documentation],
              DX_REQUIRE_PROG([DX_EGREP], egrep)])
 
 # LaTeX generation for PS and/or PDF:
+AM_CONDITIONAL(DX_COND_latex, DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf))
 if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then
-    AM_CONDITIONAL(DX_COND_latex, :)
     DX_ENV_APPEND(GENERATE_LATEX, YES)
 else
-    AM_CONDITIONAL(DX_COND_latex, false)
     DX_ENV_APPEND(GENERATE_LATEX, NO)
 fi