[cgma-dev] r3147 - cgm/trunk/m4

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Fri Sep 18 14:27:45 CDT 2009


Author: kraftche
Date: 2009-09-18 14:27:44 -0500 (Fri, 18 Sep 2009)
New Revision: 3147

Modified:
   cgm/trunk/m4/compiler.m4
   cgm/trunk/m4/cplusplus.m4
   cgm/trunk/m4/hdf5.m4
   cgm/trunk/m4/makevar.m4
   cgm/trunk/m4/netcdf.m4
Log:
sync autoconf stuff shared by MOAB and CGM

Modified: cgm/trunk/m4/compiler.m4
===================================================================
--- cgm/trunk/m4/compiler.m4	2009-09-18 19:27:31 UTC (rev 3146)
+++ cgm/trunk/m4/compiler.m4	2009-09-18 19:27:44 UTC (rev 3147)
@@ -6,7 +6,12 @@
 #  variable in which to store result
 #######################################################################################
 AC_DEFUN([ITAPS_LIBTOOL_VAR], [
-  $3=`./libtool --tag=$1 --config | sed -e 's/^$2=//p' -e 'd' | tr -d '"\n'`
+  echo "SED=$SED" > .tmp
+  ./libtool --tag=$1 --config >>.tmp
+  echo "echo \$$2" >> .tmp
+  chmod +x .tmp
+  $3=`./.tmp`
+  rm .tmp
 ])
 
 #######################################################################################
@@ -20,9 +25,23 @@
 #  CXXFLAGS - C++ compiler flags
 #  WITH_MPI - 'yes' if parallel support, 'no' otherwise
 #
+# Arguments:  three strings that msut be either "yes" or "no".
+#             - test for C compiler
+#             - test for C++ compiler
+#             - test for Fortran compiler
 #######################################################################################
 AC_DEFUN([SNL_CHECK_COMPILERS], [
 
+CHECK_CC="$1"
+CHECK_CXX="$2"
+CHECK_FC="$3"
+
+# If not specified or invalid value, change to yes.
+test "xno" = "x$CHECK_CC" || CHECK_CC=yes 
+test "xno" = "x$CHECK_CXX" || CHECK_CXX=yes 
+test "xno" = "x$CHECK_FC" || CHECK_FC=yes 
+
+
   # Save these before calling AC_PROG_CC or AC_PROG_CXX
   # because those macros will modify them, and we want
   # the original user values, not the autoconf defaults.
@@ -47,7 +66,7 @@
     F77_LIST="mpif77"
     ;;
   x*)
-    if test -z "$CC";then
+    if test "x" = "x$CC"; then
       for prog in mpicc mpcc; do
         if test -x ${WITH_MPI}/bin/$prog; then
           CC="${WITH_MPI}/bin/$prog"
@@ -57,7 +76,7 @@
     else
       CC_LIST="$CC"
     fi
-    if test -z "$CXX";then
+    if test "x" = "x$CXX"; then
       for prog in mpicxx mpiCC mpCC mpicxx; do
         if test -x ${WITH_MPI}/bin/$prog; then
           CXX="${WITH_MPI}/bin/$prog"
@@ -67,7 +86,7 @@
     else
       CXX_LIST="$CXX"
     fi
-    if test -z "$FC";then
+    if test "x" = "x$FC"; then
       for prog in mpif90; do
         if test -x ${WITH_MPI}/bin/$prog; then
           FC="${WITH_MPI}/bin/$prog"
@@ -77,7 +96,7 @@
     else
       FC_LIST="$FC"
     fi
-    if test -z "$F77";then
+    if test "x" = "x$F77";then
       for prog in mpif77; do
         if test -x ${WITH_MPI}/bin/$prog; then
           F77="${WITH_MPI}/bin/$prog"
@@ -90,17 +109,24 @@
     WITH_MPI=yes
     ;;
 esac
-AC_PROG_CC( [$CC_LIST] )
+
+if test "xno" != "x$CHECK_CC"; then
+  AC_PROG_CC( [$CC_LIST] )
+  SNL_CC_FLAGS
+fi
 AC_PROG_CPP
-AC_PROG_CXX( [$CXX_LIST] )
-AC_PROG_CXXCPP
-AC_PROG_FC( [$FC_LIST] )
-AC_PROG_F77( [$F77_LIST] )
+if test "xno" != "x$CHECK_CXX"; then
+  AC_PROG_CXX( [$CXX_LIST] )
+  AC_PROG_CXXCPP
+  SNL_CXX_FLAGS
+fi
+if test "xno" != "x$CHECK_FC"; then
+  AC_PROG_FC( [$FC_LIST] )
+  AC_PROG_F77( [$F77_LIST] )
+fi
 
 # Try to determine compiler-specific flags.  This must be done
 # before setting up libtool so that it can override libtool settings.
-SNL_CC_FLAGS
-SNL_CXX_FLAGS
 CFLAGS="$USER_CFLAGS $SNL_CC_SPECIAL"
 CXXFLAGS="$USER_CXXFLAGS $SNL_CXX_SPECIAL"
 
@@ -229,6 +255,8 @@
 # Autoconf does G++ for us
 if test x$GXX = xyes; then
   cxx_compiler=GNU
+  # Intel claims to be GCC, check for it here
+  SNL_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cxx_compiler=Intel])
 # Search for other compiler types
 # For efficiency, limit checks to relevant OSs
 else
@@ -300,6 +328,11 @@
   GNU:*)
     SNL_CXX_SPECIAL="$EXTRA_GNU_FLAGS"
     ;;
+  Intel:*)
+    SNL_CXX_32BIT=-m32
+    SNL_CXX_64BIT=-m64
+    SNL_CXX_SPECIAL="$EXTRA_GNU_FLAGS -wd981 -wd383"
+    ;;
   VisualAge:*)
     SNL_CXX_32BIT=-q32
     SNL_CXX_64BIT=-q64
@@ -355,6 +388,8 @@
 # Autoconf does gcc for us
 if test x$GCC = xyes; then
   cc_compiler=GNU
+  # Intel claims to be GCC, check for it here
+  SNL_TRY_COMPILER_DEFINE([__INTEL_COMPILER],[cc_compiler=Intel])
 # Search for other compiler types
 # For efficiency, limit checks to relevant OSs
 else
@@ -416,6 +451,11 @@
     SNL_CC_64BIT=-m64
     SNL_CC_SPECIAL="$EXTRA_GNU_FLAGS"
     ;;
+  Intel:*)
+    SNL_CC_32BIT=-m32
+    SNL_CC_64BIT=-m64
+    SNL_CC_SPECIAL="$EXTRA_GNU_FLAGS -wd981 -wd383"
+    ;;
   GNU:mips*)
     SNL_CC_32BIT="-mips32 -mabi=32"
     SNL_CC_64BIT="-mips64 -mabi=64"

Modified: cgm/trunk/m4/cplusplus.m4
===================================================================
--- cgm/trunk/m4/cplusplus.m4	2009-09-18 19:27:31 UTC (rev 3146)
+++ cgm/trunk/m4/cplusplus.m4	2009-09-18 19:27:44 UTC (rev 3147)
@@ -1,4 +1,38 @@
 #######################################################################################
+# Check for existance unordered_map in either std:: or std::tr1:: namespace
+# Executes first argument if found, second if not found.  If unordered_map
+# is found, the variable 'result' will contain its namespace.
+#######################################################################################
+AC_DEFUN([MK_CHECK_UNORDERED_MAP],[
+
+AC_CACHE_CHECK([for C++ unordered_map],
+               [mk_cv_cxx_unordered_map],
+               [AC_LANG_PUSH(C++)
+                mk_cv_cxx_unordered_map=no
+                AC_TRY_COMPILE([#include <unordered_map>],
+                               [std::unordered_map<int,int> map],
+                               [mk_cv_cxx_unordered_map="std"; incdir=])
+                if test "xno" == "x$mk_cv_cxx_unordered_map"; then
+                  AC_TRY_COMPILE([#include <tr1/unordered_map>],
+                                 [std::tr1::unordered_map<int,int> map],
+                                 [mk_cv_cxx_unordered_map="std::tr1"; incdir=tr1/])
+                fi
+                if test "xno" == "x$mk_cv_cxx_unordered_map"; then
+                  AC_TRY_COMPILE([#include <boost/unordered_map>],
+                                 [boost::unordered_map<int,int> map],
+                                 [mk_cv_cxx_unordered_map="boost"; incdir=boost/])
+                fi
+                AC_LANG_POP(C++)])
+if test "xno" != "x$mk_cv_cxx_unordered_map"; then
+  result="$mk_cv_cxx_unordered_map"
+  $1
+else
+  result=
+  $2
+fi
+])  
+
+#######################################################################################
 # Check for existance of new no-file-extension C++ headers.
 # Conditinionally sets the following preprocessor macros:
 #   CANT_USE_STD

Modified: cgm/trunk/m4/hdf5.m4
===================================================================
--- cgm/trunk/m4/hdf5.m4	2009-09-18 19:27:31 UTC (rev 3146)
+++ cgm/trunk/m4/hdf5.m4	2009-09-18 19:27:44 UTC (rev 3147)
@@ -26,7 +26,7 @@
 esac
 HAVE_ZLIB=no
 if test "x$WITH_ZLIB" != "xno"; then
-  old_LDFLAGS="$LIBS"
+  old_LDFLAGS="$LDFLAGS"
   LDFLAGS="$LDFLAGS $HDF5_LDFLAGS"
   AC_CHECK_LIB([z],[deflate],[HAVE_ZLIB=yes],
     [if test "x$WITH_ZLIB" != "x"; then AC_MSG_ERROR([Could not find zlib]); fi])
@@ -59,7 +59,7 @@
 fi
 
   # CLI option for extra HDF5 link flags
-AC_ARG_WITH([--with-hdf5-ldflags],[AC_HELP_STRING([--with-hdf5-ldflags=...],
+AC_ARG_WITH([hdf5-ldflags],[AC_HELP_STRING([--with-hdf5-ldflags=...],
  [Extra LDFLAGS required for HDF5 library (e.g. parallel IO lib)])],
  [HDF5_LDFLAGS_WITHVAL="$withval"; 
  DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-hdf5-ldflags=\"${withval}\""
@@ -99,10 +99,15 @@
   if test "x$WITH_MPI" != "xno"; then
     AC_CHECK_LIB([gpfs],[gpfs_stat],[HDF5_LIBS="-lgpfs $HDF5_LIBS"])
   fi
+  
+  HDF5_LIBNAME=hdf5
 
     # if a path is specified, update LIBS and INCLUDES accordingly
   if test "xyes" != "x$HDF5_ARG" && test "x" != "x$HDF5_ARG"; then
-    if test -d "${HDF5_ARG}/lib"; then
+    if test -d "${HDF5_ARG}/dll"; then
+      HDF5_LDFLAGS="$HDF5_LDFLAGS -L${HDF5_ARG}/dll"
+      HDF5_LIBNAME=hdf5dll
+    elif test -d "${HDF5_ARG}/lib"; then
       HDF5_LDFLAGS="$HDF5_LDFLAGS -L${HDF5_ARG}/lib"
     elif test -d "${HDF5_ARG}"; then
       HDF5_LDFLAGS="$HDF5_LDFLAGS -L${HDF5_ARG}"
@@ -132,24 +137,27 @@
   AC_CHECK_HEADERS( [hdf5.h], [], [HAVE_HDF5=no] )
   
   HAVE_LIB_HDF5=no
-  AC_CHECK_LIB( [hdf5], [H5Fopen], [HAVE_LIB_HDF5=yes] )
+  AC_CHECK_LIB( [$HDF5_LIBNAME], [H5Fopen], [HAVE_LIB_HDF5=yes] )
   if test $HAVE_LIB_HDF5 = no; then
     if test $HAVE_ZLIB = yes; then
-      unset ac_cv_lib_hdf5_H5Fopen
-      AC_CHECK_LIB( [hdf5], [H5Fopen], [HAVE_LIB_HDF5=yes; HDF5_LIBS="-lz $HDF5_LIBS"], [], [-lz] )
+      unset "ac_cv_lib_${HDF5_LIBNAME}_H5Fopen"
+      unset "ac_cv_lib_${HDF5_LIBNAME}___H5Fopen"
+      AC_CHECK_LIB( [${HDF5_LIBNAME}], [H5Fopen], [HAVE_LIB_HDF5=yes; HDF5_LIBS="$HDF5_LIBS -lz"], [], [-lz] )
     fi
   fi
   if test $HAVE_LIB_HDF5 = no; then
     if test $HAVE_SZIP = yes; then
-      unset ac_cv_lib_hdf5_H5Fopen
-      AC_CHECK_LIB( [hdf5], [H5Fopen], [HAVE_LIB_HDF5=yes; HDF5_LIBS="-lsz $HDF5_LIBS"], [], [-lsz] )
+      unset "ac_cv_lib_${HDF5_LIBNAME}_H5Fopen"
+      unset "ac_cv_lib_${HDF5_LIBNAME}___H5Fopen"
+      AC_CHECK_LIB( [$HDF5_LIBNAME], [H5Fopen], [HAVE_LIB_HDF5=yes; HDF5_LIBS="$HDF5_LIBS -lsz"], [], [-lsz] )
     fi
   fi
   if test $HAVE_LIB_HDF5 = no; then
     if test $HAVE_SZIP = yes; then
       if test $HAVE_ZLIB = yes; then
-        unset ac_cv_lib_hdf5_H5Fopen
-        AC_CHECK_LIB( [hdf5], [H5Fopen], [HAVE_LIB_HDF5=yes; HDF5_LIBS="-lsz -lz $HDF5_LIBS"], [], [-lz -lsz] )
+        unset "ac_cv_lib_${HDF5_LIBNAME}_H5Fopen"
+        unset "ac_cv_lib_${HDF5_LIBNAME}___H5Fopen"
+        AC_CHECK_LIB( [$HDF5_LIBNAME], [H5Fopen], [HAVE_LIB_HDF5=yes; HDF5_LIBS="$HDF5_LIBS -lsz -lz"], [], [-lz -lsz] )
       fi
     fi
   fi
@@ -167,7 +175,7 @@
     HDF5_LDFLAGS=
     HDF5_LIBS=
   else
-    HDF5_LIBS="$HDF5_LIBS -lhdf5"
+    HDF5_LIBS="$HDF5_LIBS -l$HDF5_LIBNAME"
   fi
   
   CPPFLAGS="$old_CPPFLAGS"

Modified: cgm/trunk/m4/makevar.m4
===================================================================
--- cgm/trunk/m4/makevar.m4	2009-09-18 19:27:31 UTC (rev 3146)
+++ cgm/trunk/m4/makevar.m4	2009-09-18 19:27:44 UTC (rev 3147)
@@ -23,7 +23,7 @@
 include $1
 SNL_END_OF_MAKEFILE
 if make -f $snl_makefile > /dev/null 2>&1; then
-  make_val=`make -f $snl_makefile`
+  make_val=`make -s -f $snl_makefile`
   rm -f $snl_makefile
   $3
 else

Modified: cgm/trunk/m4/netcdf.m4
===================================================================
--- cgm/trunk/m4/netcdf.m4	2009-09-18 19:27:31 UTC (rev 3146)
+++ cgm/trunk/m4/netcdf.m4	2009-09-18 19:27:44 UTC (rev 3147)
@@ -1,7 +1,10 @@
 #######################################################################################
 # Check for NetCDF library ((C++)
 # Sets HAVE_NETCDF to 'yes' or 'no'
-# If HAVE_NETCDF == yes, then exports NETCDF_CPPFLAGS and NETCDF_LDFLAGS
+# If HAVE_NETCDF == yes, then exports:
+#   NETCDF_CPPFLAGS
+#   NETCDF_LDFLAGS
+#   NETCDF_LIBS
 #######################################################################################
 AC_DEFUN([SNL_CHECK_NETCDF],[
 
@@ -82,14 +85,20 @@
   LIBS="$LIBS -lnetcdf_c++ -lnetcdf"
   AC_TRY_LINK(
     [#include <netcdf.hh>], [NcFile ncf("foo",NcFile::ReadOnly);],
-    [AC_MSG_RESULT([yes])], 
-    [AC_MSG_RESULT([no]); 
-     AC_MSG_WARN([NetCDF C++ API not found])
-     HAVE_NETCDF=no] )
+    [AC_MSG_RESULT([yes]); NETCDF_LIBS="-lnetcdf_c++ -lnetcdf"], 
+    [AC_MSG_RESULT([no]);
+     AC_MSG_CHECKING([for netcdf_c++ library requiring HDF5-high-level])
+     LIBS="$LIBS -lhdf5_hl $HDF5_LIBS"
+     AC_TRY_LINK(
+           [#include <netcdf.hh>], [NcFile ncf("foo",NcFile::ReadOnly);],
+           [AC_MSG_RESULT([yes]); NETCDF_LIBS="-lnetcdf_c++ -lnetcdf -lhdf5_hl"], 
+           [AC_MSG_RESULT([no]); HAVE_NETCDF=no] )    
+     ])
   LIBS="$old_LIBS"
   AC_LANG_RESTORE
   CPPFLAGS="$old_CPPFLAGS"
   LDFLAGS="$old_LDFLAGS"
+
   if test "x$HAVE_NETCDF" = "xno"; then
     if test "x$NETCDF_ARG" != "x"; then 
       AC_MSG_ERROR("NetCDF not found or not working")



More information about the cgma-dev mailing list