[cig-commits] r13836 - cs/cigma/trunk/config
luis at geodynamics.org
luis at geodynamics.org
Mon Jan 12 14:10:02 PST 2009
Author: luis
Date: 2009-01-12 14:10:02 -0800 (Mon, 12 Jan 2009)
New Revision: 13836
Added:
cs/cigma/trunk/config/cigma_netcdf.m4
Log:
Added autoconf macros for configuring the NetCDF library
This adds the option --with-netcdf to the configure script,
defines the NETCDF_{INCLUDES,LIBS,LDFLAGS} variables, as well
as the HAVE_NETCDF preprocessor variable. By default, we assume
the option --without-netcdf (or --with-netcdf=no). Otherwise,
if the appropriate installation prefix is specified, this autoconf
macro will search for the NetCDF C++ API and fail if it doesn't
find it.
Added: cs/cigma/trunk/config/cigma_netcdf.m4
===================================================================
--- cs/cigma/trunk/config/cigma_netcdf.m4 (rev 0)
+++ cs/cigma/trunk/config/cigma_netcdf.m4 2009-01-12 22:10:02 UTC (rev 13836)
@@ -0,0 +1,83 @@
+###############################################################################
+# -*- Autoconf -*-
+#
+
+#######################
+# CIGMA_OPTIONS_NETCDF
+AC_DEFUN([CIGMA_OPTIONS_NETCDF], [
+ AC_ARG_WITH([netcdf],
+ [AC_HELP_STRING([--with-netcdf],
+ [The prefix where NetCDF is installed])],
+ [with_netcdf="$withval"],
+ [with_netcdf="no"])
+])
+
+####################
+# CIGMA_PATH_NETCDF
+AC_DEFUN([CIGMA_PATH_NETCDF], [
+
+ if [[ $with_netcdf = "yes" ]]; then
+ dnl In case user wrote --with-netcdf=yes
+ with_netcdf="/usr"
+ fi
+
+ if [[ $with_netcdf != "no" ]]; then
+
+ NETCDF_PREFIX="$with_netcdf"
+
+ AC_CHECK_FILE([$NETCDF_PREFIX/include/netcdfcpp.h], [netcdfFound="OK"])
+ AC_MSG_CHECKING([if NetCDF is installed in $NETCDF_PREFIX])
+
+ if [[ -z "$netcdfFound" ]]; then
+
+ dnl netcdf not found!
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([NetCDF C++ header not found; try CPPFLAGS="-I<netcdf include dir>"])
+
+ else
+
+ AC_MSG_RESULT([yes])
+
+ NETCDF_LIBS="-lnetcdf_c++ -lnetcdf"
+
+ if [[ $NETCDF_PREFIX != "/usr" ]]; then
+ NETCDF_INCLUDES="-I$NETCDF_PREFIX/include"
+ NETCDF_LDFLAGS="-L$NETCDF_PREFIX/lib $NETCDF_LIBS"
+ fi
+
+ OLD_CXXFLAGS="$CXXFLAGS"
+ OLD_LIBS="$LIBS"
+
+ CXXFLAGS="$NETCDF_INCLUDES"
+ LIBS="$NETCDF_LIBS"
+
+ AC_CHECK_LIB([netcdf],[main],[netcdf_lib=yes])
+ AC_CHECK_LIB([netcdf_c++],[main],[ncetcdf_cpplib=yes])
+ AC_CHECK_HEADERS([netcdfcpp.h],,AC_MSG_ERROR([NetCDF C++ header not found]))
+
+ AC_MSG_CHECKING([for NcFile in -lnetcdf_c++])
+ AC_REQUIRE_CPP
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <netcdfcpp.h>]],
+ [[NcFile ncfile("filename"); ]])],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+ AC_MSG_ERROR([netcdfc++ library not found; try LDFLAGS="-L<netcdf lib dir>"])
+ ])
+
+ CXXFLAGS="$OLD_CXXFLAGS"
+ LIBS="$OLD_LIBS"
+
+ dnl Define the preprocessor variable HAVE_NETCDF
+ AC_DEFINE([HAVE_NETCDF],,[define if the NetCDF library is available])
+ fi
+ fi
+
+ dnl Substitute the values of our NetCDF flags
+ AC_SUBST(NETCDF_INCLUDES)
+ AC_SUBST(NETCDF_LIBS)
+ AC_SUBST(NETCDF_LDFLAGS)
+
+])
+
+# vim: syntax=config
More information about the CIG-COMMITS
mailing list