From 2a79bb2fe29bd32f4b27f64cf49ad617ba717284 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 27 Jun 2012 11:10:25 +0200 Subject: [PATCH 1/3] opm-core: make it work nicely with clang --- opm/core/eclipse/EclipseGridParser.cpp | 18 +---- opm/core/eclipse/EclipseGridParser.hpp | 76 ++++++++++----------- opm/core/simulator/SimulatorTwophase.cpp | 12 ++-- opm/core/simulator/SimulatorTwophase.hpp | 2 +- opm/core/utility/Factory.hpp | 2 +- opm/core/utility/MonotCubicInterpolator.hpp | 16 ++--- 6 files changed, 56 insertions(+), 70 deletions(-) diff --git a/opm/core/eclipse/EclipseGridParser.cpp b/opm/core/eclipse/EclipseGridParser.cpp index fd5f5ef5..45017a46 100644 --- a/opm/core/eclipse/EclipseGridParser.cpp +++ b/opm/core/eclipse/EclipseGridParser.cpp @@ -191,21 +191,7 @@ namespace { return us; } - inline std::string readKeyword(std::istream& is) - { - std::string keyword_candidate; - while (!is.eof()) { - is >> keyword_candidate; - if(keyword_candidate.find("--") == 0) { - is >> ignoreLine; // This line is a comment - } else { - return upcase(keyword_candidate); - } - } - return "CONTINUE"; // Last line in included file is a comment - } - - inline bool readKeywordNew(std::istream& is, std::string& keyword) + inline bool readKeyword(std::istream& is, std::string& keyword) { char buf[9]; int i, j; @@ -377,7 +363,7 @@ void EclipseGridParser::readImpl(istream& is) std::string keyword; while (is.good()) { is >> ignoreWhitespace; - bool ok = readKeywordNew(is, keyword); + bool ok = readKeyword(is, keyword); if (ok) { //#ifdef VERBOSE cout << "Keyword found: " << keyword << endl; diff --git a/opm/core/eclipse/EclipseGridParser.hpp b/opm/core/eclipse/EclipseGridParser.hpp index 56e9ee4f..9f66e9ae 100644 --- a/opm/core/eclipse/EclipseGridParser.hpp +++ b/opm/core/eclipse/EclipseGridParser.hpp @@ -129,47 +129,47 @@ public: { return dynamic_cast(*getSpecialValue(#keyword)); } // Support for special fields. - SPECIAL_FIELD(SPECGRID); - SPECIAL_FIELD(FAULTS); - SPECIAL_FIELD(MULTFLT); - SPECIAL_FIELD(TITLE); - SPECIAL_FIELD(START); - SPECIAL_FIELD(DATES); - SPECIAL_FIELD(DENSITY); - SPECIAL_FIELD(PVDG); - SPECIAL_FIELD(PVDO); - SPECIAL_FIELD(PVTG); - SPECIAL_FIELD(PVTO); - SPECIAL_FIELD(PVTW); - SPECIAL_FIELD(SGOF); - SPECIAL_FIELD(SWOF); - SPECIAL_FIELD(ROCK); - SPECIAL_FIELD(ROCKTAB); - SPECIAL_FIELD(WELSPECS); - SPECIAL_FIELD(COMPDAT); - SPECIAL_FIELD(WCONINJE); - SPECIAL_FIELD(WCONPROD); - SPECIAL_FIELD(WELTARG); - SPECIAL_FIELD(WELOPEN); - SPECIAL_FIELD(EQUIL); - SPECIAL_FIELD(PVCDO); - SPECIAL_FIELD(TSTEP); - SPECIAL_FIELD(PLYVISC); - SPECIAL_FIELD(PLYROCK); - SPECIAL_FIELD(PLYADS); - SPECIAL_FIELD(PLYMAX); - SPECIAL_FIELD(TLMIXPAR); - SPECIAL_FIELD(WPOLYMER); - SPECIAL_FIELD(GRUPTREE); - SPECIAL_FIELD(GCONINJE); - SPECIAL_FIELD(GCONPROD); - SPECIAL_FIELD(WGRUPCON); + SPECIAL_FIELD(SPECGRID) + SPECIAL_FIELD(FAULTS) + SPECIAL_FIELD(MULTFLT) + SPECIAL_FIELD(TITLE) + SPECIAL_FIELD(START) + SPECIAL_FIELD(DATES) + SPECIAL_FIELD(DENSITY) + SPECIAL_FIELD(PVDG) + SPECIAL_FIELD(PVDO) + SPECIAL_FIELD(PVTG) + SPECIAL_FIELD(PVTO) + SPECIAL_FIELD(PVTW) + SPECIAL_FIELD(SGOF) + SPECIAL_FIELD(SWOF) + SPECIAL_FIELD(ROCK) + SPECIAL_FIELD(ROCKTAB) + SPECIAL_FIELD(WELSPECS) + SPECIAL_FIELD(COMPDAT) + SPECIAL_FIELD(WCONINJE) + SPECIAL_FIELD(WCONPROD) + SPECIAL_FIELD(WELTARG) + SPECIAL_FIELD(WELOPEN) + SPECIAL_FIELD(EQUIL) + SPECIAL_FIELD(PVCDO) + SPECIAL_FIELD(TSTEP) + SPECIAL_FIELD(PLYVISC) + SPECIAL_FIELD(PLYROCK) + SPECIAL_FIELD(PLYADS) + SPECIAL_FIELD(PLYMAX) + SPECIAL_FIELD(TLMIXPAR) + SPECIAL_FIELD(WPOLYMER) + SPECIAL_FIELD(GRUPTREE) + SPECIAL_FIELD(GCONINJE) + SPECIAL_FIELD(GCONPROD) + SPECIAL_FIELD(WGRUPCON) // The following fields only have a dummy implementation // that allows us to ignore them. - SPECIAL_FIELD(SWFN); - SPECIAL_FIELD(SOF2); - SPECIAL_FIELD(TUNING); + SPECIAL_FIELD(SWFN) + SPECIAL_FIELD(SOF2) + SPECIAL_FIELD(TUNING) #undef SPECIAL_FIELD diff --git a/opm/core/simulator/SimulatorTwophase.cpp b/opm/core/simulator/SimulatorTwophase.cpp index 9c1f9023..43913095 100644 --- a/opm/core/simulator/SimulatorTwophase.cpp +++ b/opm/core/simulator/SimulatorTwophase.cpp @@ -89,9 +89,9 @@ namespace Opm const RockCompressibility* rock_comp_; const Wells* wells_; const std::vector& src_; - const FlowBoundaryConditions* bcs_; - const LinearSolverInterface& linsolver_; - const double* gravity_; + //const FlowBoundaryConditions* bcs_; + //const LinearSolverInterface& linsolver_; + //const double* gravity_; // Solvers IncompTpfa psolver_; TransportModelTwophase tsolver_; @@ -207,9 +207,9 @@ namespace Opm rock_comp_(rock_comp), wells_(wells), src_(src), - bcs_(bcs), - linsolver_(linsolver), - gravity_(gravity), + //bcs_(bcs), + //linsolver_(linsolver), + //gravity_(gravity), psolver_(grid, props, rock_comp, linsolver, param.getDefault("nl_pressure_residual_tolerance", 0.0), param.getDefault("nl_pressure_change_tolerance", 1.0), diff --git a/opm/core/simulator/SimulatorTwophase.hpp b/opm/core/simulator/SimulatorTwophase.hpp index 5baa161e..818d40db 100644 --- a/opm/core/simulator/SimulatorTwophase.hpp +++ b/opm/core/simulator/SimulatorTwophase.hpp @@ -36,7 +36,7 @@ namespace Opm class SimulatorTimer; class TwophaseState; class WellState; - class SimulatorReport; + struct SimulatorReport; /// Class collecting all necessary components for a two-phase simulation. class SimulatorTwophase diff --git a/opm/core/utility/Factory.hpp b/opm/core/utility/Factory.hpp index eb73d208..124b5b44 100644 --- a/opm/core/utility/Factory.hpp +++ b/opm/core/utility/Factory.hpp @@ -86,7 +86,7 @@ namespace Opm template static void addCreator(const std::string& type) { - instance().doAddCreator(type); + instance().template doAddCreator(type); } private: diff --git a/opm/core/utility/MonotCubicInterpolator.hpp b/opm/core/utility/MonotCubicInterpolator.hpp index 7e1c6710..fb635ac7 100644 --- a/opm/core/utility/MonotCubicInterpolator.hpp +++ b/opm/core/utility/MonotCubicInterpolator.hpp @@ -73,7 +73,7 @@ class MonotCubicInterpolator { if (!read(datafilename)) { throw("Unable to constuct MonotCubicInterpolator from file.") ; } ; - } ; + } /** @@ -94,7 +94,7 @@ class MonotCubicInterpolator { if (!read(std::string(datafilename))) { throw("Unable to constuct MonotCubicInterpolator from file.") ; } ; - } ; + } /** @@ -110,7 +110,7 @@ class MonotCubicInterpolator { if (!read(std::string(datafilename),xColumn,fColumn)) { throw("Unable to constuct MonotCubicInterpolator from file.") ; } ; - } ; + } /** @param datafilename data file @@ -125,7 +125,7 @@ class MonotCubicInterpolator { if (!read(datafilename,xColumn,fColumn)) { throw("Unable to constuct MonotCubicInterpolator from file.") ; } ; - } ; + } /** @param x vector of x values @@ -144,7 +144,7 @@ class MonotCubicInterpolator { This object must be treated with care until populated. */ - MonotCubicInterpolator() {;} ; + MonotCubicInterpolator() { } @@ -163,7 +163,7 @@ class MonotCubicInterpolator { */ bool read(const std::string & datafilename) { return read(datafilename,1,2) ; - } ; + } /** @param datafilename data file @@ -188,7 +188,7 @@ class MonotCubicInterpolator { @return f(x) for a given x */ - double operator () (double x) const { return evaluate(x) ; } ; + double operator () (double x) const { return evaluate(x) ; } /** @param x x value @@ -485,7 +485,7 @@ class MonotCubicInterpolator { */ void shrinkFlatAreas() { shrinkFlatAreas(1e-14); - }; + } From 31d0681a667c4d68bdbe53b854fa52b24b63c778 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 14 Jun 2012 18:13:56 +0200 Subject: [PATCH 2/3] opm-core: make it a usable in conjunction wit dunecontrol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows projects which use the DUNE build system and want to use OPM-Core to specify a dependency in their dune.module file. (i.e. they don't have to worry about compiler and linker flags anymore.) opm-core can still be used without having DUNE installed, though. This means that for users which do not need/want a dependency on DUNE, nothing changes. v2: avoid naming conflict of the AX_BOOST_BASE macro with dune-common by renaming it to OPM_BOOST_BASE. v3: make the library detection work nicely v4: Use AX_BOOST_BASE M4 macro from opm-core instead from dune-common as base for OPM_BOOST_BASE to get rid of a few bugs, reworded commit message. Thanks to Bård Skaflestad for the review. --- configure.ac | 51 +-- dune.module | 7 + m4/{ax_boost_base.m4 => opm_boost_base.m4} | 4 +- m4/opm_core.m4 | 346 +++++++++++++++++++++ m4/opm_dynlink_boost_test.m4 | 2 +- 5 files changed, 357 insertions(+), 53 deletions(-) create mode 100644 dune.module rename m4/{ax_boost_base.m4 => opm_boost_base.m4} (98%) create mode 100644 m4/opm_core.m4 diff --git a/configure.ac b/configure.ac index ef5fc0d8..e979c9a3 100644 --- a/configure.ac +++ b/configure.ac @@ -28,59 +28,10 @@ m4_ifdef([LT_INIT], AC_PROG_FC[]dnl ])[]dnl -# Checks for libraries. - -# Bring in numerics support (standard library component) -AC_SEARCH_LIBS([sqrt], [m]) - -OPM_LAPACK - -AX_BOOST_BASE([1.37]) -AX_BOOST_SYSTEM -AX_BOOST_DATE_TIME -AX_BOOST_FILESYSTEM -AX_BOOST_UNIT_TEST_FRAMEWORK - -AX_DUNE_ISTL -OPM_AGMG +OPM_CORE_CHECKS OPM_DYNLINK_BOOST_TEST -# Checks for header files. -AC_CHECK_HEADERS([float.h limits.h stddef.h stdlib.h string.h]) - -AC_CHECK_HEADERS([suitesparse/umfpack.h], - [umfpack_header=yes], - [umfpack_header=no]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL -AC_TYPE_SIZE_T -AC_CHECK_TYPES([ptrdiff_t]) - -# Checks for library functions. -AC_CHECK_FUNCS([floor memset memmove strchr strtol sqrt pow]) -AC_FUNC_STRTOD - -# Search for UMFPACK direct sparse solver. -AC_SEARCH_LIBS([amd_free], [amd]) -AC_SEARCH_LIBS([camd_free], [camd]) -AC_SEARCH_LIBS([colamd_set_defaults], [colamd]) -AC_SEARCH_LIBS([ccolamd_set_defaults], [ccolamd]) -AC_SEARCH_LIBS([cholmod_l_start], [cholmod]) -AC_SEARCH_LIBS([umfpack_dl_solve], [umfpack],dnl - [umfpack_lib=yes], [umfpack_lib=no]) - -AM_CONDITIONAL([UMFPACK], - [test "x$umfpack_header" != "xno" -a "x$umfpack_lib" != "xno"]) - -m4_ifdef([AM_COND_IF], -[AM_COND_IF([UMFPACK], [], - [AC_MSG_NOTICE([Found no working installation of UMFPACK. - UMFPACK support is disabled.])]) -]) - - AC_CONFIG_FILES([ Makefile tests/Makefile diff --git a/dune.module b/dune.module new file mode 100644 index 00000000..7deeedde --- /dev/null +++ b/dune.module @@ -0,0 +1,7 @@ +#dune module information file# +############################## + +#Name of the module +Module: opm-core +Version: 0.1 +Maintainer: atgeirr@sintef.no diff --git a/m4/ax_boost_base.m4 b/m4/opm_boost_base.m4 similarity index 98% rename from m4/ax_boost_base.m4 rename to m4/opm_boost_base.m4 index 54a2a1be..cabbd339 100644 --- a/m4/ax_boost_base.m4 +++ b/m4/opm_boost_base.m4 @@ -4,7 +4,7 @@ # # SYNOPSIS # -# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# OPM_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # DESCRIPTION # @@ -35,7 +35,7 @@ #serial 20 -AC_DEFUN([AX_BOOST_BASE], +AC_DEFUN([OPM_BOOST_BASE], [ AC_ARG_WITH([boost], [AS_HELP_STRING([--with-boost@<:@=ARG@:>@], diff --git a/m4/opm_core.m4 b/m4/opm_core.m4 new file mode 100644 index 00000000..c1a4bbc5 --- /dev/null +++ b/m4/opm_core.m4 @@ -0,0 +1,346 @@ +dnl -*- autoconf -*- +# Macros needed to find OPM-core and dependent libraries. They are called by +# the macros in ${top_src_dir}/dependencies.m4, which is generated by +# "dunecontrol autogen" +AC_DEFUN([OPM_CORE_CHECKS], +[ + +# Checks for libraries. + +# Bring in numerics support (standard library component) +AC_SEARCH_LIBS([sqrt], [m]) + +OPM_LAPACK + +OPM_BOOST_BASE([1.37]) +AX_BOOST_SYSTEM +AX_BOOST_DATE_TIME +AX_BOOST_FILESYSTEM +AX_BOOST_UNIT_TEST_FRAMEWORK + +AX_DUNE_ISTL +OPM_AGMG + +# Checks for header files. +AC_CHECK_HEADERS([float.h limits.h stddef.h stdlib.h string.h]) + +AC_CHECK_HEADERS([suitesparse/umfpack.h], + [umfpack_header=yes], + [umfpack_header=no]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_TYPE_SIZE_T +AC_CHECK_TYPES([ptrdiff_t]) + +# Checks for library functions. +AC_CHECK_FUNCS([floor memset memmove strchr strtol sqrt pow]) +AC_FUNC_STRTOD + +# Search for UMFPACK direct sparse solver. +AC_SEARCH_LIBS([amd_free], [amd]) +AC_SEARCH_LIBS([camd_free], [camd]) +AC_SEARCH_LIBS([colamd_set_defaults], [colamd]) +AC_SEARCH_LIBS([ccolamd_set_defaults], [ccolamd]) +AC_SEARCH_LIBS([cholmod_l_start], [cholmod]) +AC_SEARCH_LIBS([umfpack_dl_solve], [umfpack],dnl + [umfpack_lib=yes], [umfpack_lib=no]) + +AM_CONDITIONAL([UMFPACK], + [test "x$umfpack_header" != "xno" -a "x$umfpack_lib" != "xno"]) + +m4_ifdef([AM_COND_IF], +[AM_COND_IF([UMFPACK], [], + [AC_MSG_NOTICE([Found no working installation of UMFPACK. + UMFPACK support is disabled.])]) +]) + +]) + +# OPM_CORE_CHECK_MODULES(NAME, HEADER, SYMBOL) +# +# THIS MACRO IS JUST A COPY OF DUNE_CHECK_MODULES WITH THE REQUIREMENT THAT ALL +# HEADERS MUST RESIDE IN $MODULE_ROOT/dune REMOVED. REMOVE THIS MACRO AS SOON AS DUNE +# DOES NOT ENFORCE THIS ANYMORE. +# +# Generic check for dune modules. This macro should not be used directly, but +# in the modules m4/{module}.m4 in the {MODULE}_CHECK_MODULE macro. The +# {MODULE}_CHECK_MODULE macro knows the parameters to call this +# DUNE_CHECK_MODULES macro with, and it does not take any parameters itself, +# so it may be used with AC_REQUIRE. +# +# NAME Name of the module, lowercase with dashes (like "dune-common"). The +# value must be known when autoconf runs, so shell variables in the +# value are not permissible. +# +# HEADER Header to check for. The check will really be for , +# so the header must reside within a directory called "dune". +# +# SYMBOL Symbol to check for in the module's library. If this argument is +# empty or missing, it is assumed that the module does not provide a +# library. The value must be known when autoconf runs, so shell +# variables in the value are not permissible. This value is actually +# handed to AC_TRY_LINK unchanged as the FUNCTION-BODY argument, so it +# may contain more complex stuff than a simple symbol. +# +# The name of the library is assumed to be the same as the module name, +# with any occurance of "-" removed. The path of the library is +# obtained from pkgconfig for installed modules, or assumed to be the +# directory "lib" within the modules root for non-installed modules. +# +# In the following, {module} is {NAME} with any "-" replaced by "_" and +# {MODULE} is the uppercase version of {module}. +# +# configure options: +# --with-{NAME} +# +# configure/shell variables: +# {MODULE}_ROOT, {MODULE}_LIBDIR +# HAVE_{MODULE} (1 or 0) +# with_{module} ("yes" or "no") +# DUNE_CPPFLAGS, DUNE_LDFLAGS, DUNE_LIBS (adds the modules values here, +# substitution done by DUNE_CHECK_ALL) +# ALL_PKG_CPPFLAGS, ALL_PKG_LDFLAGS, ALL_PKG_LIBS (adds the modules values +# here, substitution done by DUNE_CHECK_ALL) +# {MODULE}_VERSION +# {MODULE}_VERSION_MAJOR +# {MODULE}_VERSION_MINOR +# {MODULE}_VERSION_REVISION +# +# configure substitutions/makefile variables: +# {MODULE}_CPPFLAGS, {MODULE}_LDFLAGS, {MODULE}_LIBS +# {MODULE}_ROOT +# {MODULE}_LIBDIR (only if modules provides a library) +# +# preprocessor defines: +# HAVE_{MODULE} (1 or undefined) +# {MODULE}_VERSION +# {MODULE}_VERSION_MAJOR +# {MODULE}_VERSION_MINOR +# {MODULE}_VERSION_REVISION +# +# automake conditionals: +# HAVE_{MODULE} +AC_DEFUN([OPM_CORE_CHECK_MODULES],[ + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PROG_CXXCPP]) + AC_REQUIRE([PKG_PROG_PKG_CONFIG]) + AC_REQUIRE([DUNE_DISABLE_LIBCHECK]) + AC_REQUIRE([LT_OUTPUT]) + + # ____DUNE_CHECK_MODULES_____ ($1) + + m4_pushdef([_dune_name], [$1]) + m4_pushdef([_dune_module], [m4_translit(_dune_name, [-], [_])]) + m4_pushdef([_dune_header], [$2]) + m4_pushdef([_dune_ldpath], [lib]) + m4_pushdef([_dune_lib], [m4_translit(_dune_name, [-], [])]) + m4_pushdef([_dune_symbol], [$3]) + m4_pushdef([_DUNE_MODULE], [m4_toupper(_dune_module)]) + + # switch tests to c++ + AC_LANG_PUSH([C++]) + + # the usual option... + AC_ARG_WITH(_dune_name, + AS_HELP_STRING([--with-_dune_name=PATH],[_dune_module directory])) + + # backup of flags + ac_save_CPPFLAGS="$CPPFLAGS" + ac_save_LIBS="$LIBS" + ac_save_LDFLAGS="$LDFLAGS" + CPPFLAGS="" + LIBS="" + + ## + ## Where is the module $1? + ## + + AC_MSG_CHECKING([for $1 installation or source tree]) + + # is a directory set? + AS_IF([test -z "$with_[]_dune_module"],[ + # + # search module $1 via pkg-config + # + with_[]_dune_module="global installation" + 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]) + ]) + AS_IF(AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]),[ + _dune_cm_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 + _dune_cm_LDFLAGS="" + ifelse(_dune_symbol,, + [_DUNE_MODULE[]_LIBDIR="" + _dune_cm_LIBS=""], + [_DUNE_MODULE[]_LIBDIR=`$PKG_CONFIG --variable=libdir _dune_name 2>/dev/null` + _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) + HAVE_[]_DUNE_MODULE=1 + AC_MSG_RESULT([global installation in $_DUNE_MODULE[]_ROOT]) + ],[ + HAVE_[]_DUNE_MODULE=0 + AC_MSG_RESULT([not found]) + ]) + ],[ + # + # path for module $1 is specified via command line + # + 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) + AS_IF([test -d "$_DUNE_MODULE[]_ROOT/include/dune"],[ + # Dune was installed into directory given by with-dunecommon + _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_ROOT/include" + _DUNE_MODULE[]_BUILDDIR=_DUNE_MODULE[]_ROOT + _DUNE_MODULE[]_VERSION="`PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$_DUNE_MODULE[]_ROOT/lib/pkgconfig $PKG_CONFIG --modversion _dune_name`" 2>/dev/null + ],[ + _DUNE_MODULE[]_SRCDIR=$_DUNE_MODULE[]_ROOT + # extract src and build path from Makefile, if found + AS_IF([test -f $_DUNE_MODULE[]_ROOT/Makefile],[ + _DUNE_MODULE[]_SRCDIR="`sed -ne '/^abs_top_srcdir = /{s/^abs_top_srcdir = //; p;}' $_DUNE_MODULE[]_ROOT/Makefile`" + ]) + _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_SRCDIR" + _DUNE_MODULE[]_VERSION="`grep Version $_DUNE_MODULE[]_SRCDIR/dune.module | sed -e 's/^Version: *//'`" 2>/dev/null + ]) + _dune_cm_LDFLAGS="" + ifelse(_dune_symbol,, + [_DUNE_MODULE[]_LIBDIR="" + _dune_cm_LIBS=""], + [_DUNE_MODULE[]_LIBDIR="$_DUNE_MODULE[]_ROOT" + _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) + # set expanded module path + with_[]_dune_module="$_DUNE_MODULE[]_ROOT" + HAVE_[]_DUNE_MODULE=1 + 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]) + ]) + ]) + + CPPFLAGS="$ac_save_CPPFLAGS $DUNE_CPPFLAGS $_dune_cm_CPPFLAGS" + ## + ## check for an arbitrary header + ## + AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ + AC_CHECK_HEADER([[]_dune_header], + [HAVE_[]_DUNE_MODULE=1], [HAVE_[]_DUNE_MODULE=0]) + ]) + + AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ + 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]), + + 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_CXX="$CXX" + HAVE_[]_DUNE_MODULE=0 + + # define LTCXXLINK like it will be defined in the Makefile + CXX="./libtool --tag=CXX --mode=link $ac_save_CXX" + + # use module LDFLAGS + LDFLAGS="$ac_save_LDFLAGS $DUNE_LDFLAGS $_dune_cm_LDFLAGS" + LIBS="$_dune_cm_LIBS $DUNE_LIBS $LIBS" + + AC_MSG_CHECKING([for lib[]_dune_lib]) + + AC_TRY_LINK(dnl + [#]include<_dune_header>, + _dune_symbol, + [ + AC_MSG_RESULT([yes]) + HAVE_[]_DUNE_MODULE=1 + ],[ + 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 + CXX="$ac_save_CXX" + ]) + ) + + # did we succeed? + AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[ + # add the module's own flags and libs to the modules and the global + # variables + DUNE_ADD_MODULE_DEPS(m4_defn([_dune_name]), m4_defn([_dune_name]), + [$_dune_cm_CPPFLAGS], [$_dune_cm_LDFLAGS], [$_dune_cm_LIBS]) + + # set variables for our modules + AC_SUBST(_DUNE_MODULE[]_CPPFLAGS, "$_DUNE_MODULE[]_CPPFLAGS") + AC_SUBST(_DUNE_MODULE[]_LDFLAGS, "$_DUNE_MODULE[]_LDFLAGS") + AC_SUBST(_DUNE_MODULE[]_LIBS, "$_DUNE_MODULE[]_LIBS") + AC_SUBST(_DUNE_MODULE[]_ROOT, "$_DUNE_MODULE[]_ROOT") + ifelse(m4_defn([_dune_symbol]),, + [], + [AC_SUBST(_DUNE_MODULE[]_LIBDIR) + ]) + AC_DEFINE(HAVE_[]_DUNE_MODULE, 1, [Define to 1 if] _dune_name [was found]) + + DUNE_PARSE_MODULE_VERSION(_dune_name, $_DUNE_MODULE[]_VERSION) + + # set DUNE_* variables + # This should actually be unneccesary, but I'm keeping it in here for now + # for backward compatibility + DUNE_LDFLAGS="$DUNE_LDFLAGS $_DUNE_MODULE[]_LDFLAGS" + DUNE_LIBS="$_DUNE_MODULE[]_LIBS $DUNE_LIBS" + + with_[]_dune_module="yes" + ],[ + with_[]_dune_module="no" + ]) + + AM_CONDITIONAL(HAVE_[]_DUNE_MODULE, test x$HAVE_[]_DUNE_MODULE = x1) + + # reset previous flags + CPPFLAGS="$ac_save_CPPFLAGS" + LDFLAGS="$ac_save_LDFLAGS" + LIBS="$ac_save_LIBS" + + # add this module to DUNE_SUMMARY + DUNE_MODULE_ADD_SUMMARY_ENTRY(_dune_name) + + # remove local variables + m4_popdef([_dune_name]) + m4_popdef([_dune_module]) + m4_popdef([_dune_header]) + m4_popdef([_dune_ldpath]) + m4_popdef([_dune_lib]) + m4_popdef([_dune_symbol]) + m4_popdef([_DUNE_MODULE]) + + # restore previous language settings (leave C++) + AC_LANG_POP([C++]) +]) + +# Additional checks needed to find eWoms +# This macro should be invoked by every module which depends on dumux, but +# not by dumux itself +AC_DEFUN([OPM_CORE_CHECK_MODULE], +[ + OPM_CORE_CHECK_MODULES([opm-core],[opm/core/grid.h],[create_grid_empty()]) +]) diff --git a/m4/opm_dynlink_boost_test.m4 b/m4/opm_dynlink_boost_test.m4 index 89c82908..93d918bd 100644 --- a/m4/opm_dynlink_boost_test.m4 +++ b/m4/opm_dynlink_boost_test.m4 @@ -38,7 +38,7 @@ dnl ------------------------------------------------------------------- # system uses dynamic linking of Boost.Test . AC_DEFUN([OPM_DYNLINK_BOOST_TEST], [ -AC_REQUIRE([AX_BOOST_BASE]) +AC_REQUIRE([OPM_BOOST_BASE]) AC_REQUIRE([AX_BOOST_UNIT_TEST_FRAMEWORK]) _opm_LIBS_SAVE="$LIBS" From 3a25c11544bddcf1ff7cde14a00a0315f16cfbd8 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Tue, 3 Jul 2012 15:42:01 +0200 Subject: [PATCH 3/3] factor out OPM_CORE_CHECK_MODULES into a separate file thanks to Roland Kaufmann for suggesting this. --- m4/opm_core.m4 | 282 +---------------------------------- m4/opm_core_check_modules.m4 | 281 ++++++++++++++++++++++++++++++++++ 2 files changed, 282 insertions(+), 281 deletions(-) create mode 100644 m4/opm_core_check_modules.m4 diff --git a/m4/opm_core.m4 b/m4/opm_core.m4 index c1a4bbc5..efb75c13 100644 --- a/m4/opm_core.m4 +++ b/m4/opm_core.m4 @@ -1,5 +1,5 @@ dnl -*- autoconf -*- -# Macros needed to find OPM-core and dependent libraries. They are called by + # Macros needed to find OPM-core and dependent libraries. They are called by # the macros in ${top_src_dir}/dependencies.m4, which is generated by # "dunecontrol autogen" AC_DEFUN([OPM_CORE_CHECKS], @@ -57,286 +57,6 @@ m4_ifdef([AM_COND_IF], ]) -# OPM_CORE_CHECK_MODULES(NAME, HEADER, SYMBOL) -# -# THIS MACRO IS JUST A COPY OF DUNE_CHECK_MODULES WITH THE REQUIREMENT THAT ALL -# HEADERS MUST RESIDE IN $MODULE_ROOT/dune REMOVED. REMOVE THIS MACRO AS SOON AS DUNE -# DOES NOT ENFORCE THIS ANYMORE. -# -# Generic check for dune modules. This macro should not be used directly, but -# in the modules m4/{module}.m4 in the {MODULE}_CHECK_MODULE macro. The -# {MODULE}_CHECK_MODULE macro knows the parameters to call this -# DUNE_CHECK_MODULES macro with, and it does not take any parameters itself, -# so it may be used with AC_REQUIRE. -# -# NAME Name of the module, lowercase with dashes (like "dune-common"). The -# value must be known when autoconf runs, so shell variables in the -# value are not permissible. -# -# HEADER Header to check for. The check will really be for , -# so the header must reside within a directory called "dune". -# -# SYMBOL Symbol to check for in the module's library. If this argument is -# empty or missing, it is assumed that the module does not provide a -# library. The value must be known when autoconf runs, so shell -# variables in the value are not permissible. This value is actually -# handed to AC_TRY_LINK unchanged as the FUNCTION-BODY argument, so it -# may contain more complex stuff than a simple symbol. -# -# The name of the library is assumed to be the same as the module name, -# with any occurance of "-" removed. The path of the library is -# obtained from pkgconfig for installed modules, or assumed to be the -# directory "lib" within the modules root for non-installed modules. -# -# In the following, {module} is {NAME} with any "-" replaced by "_" and -# {MODULE} is the uppercase version of {module}. -# -# configure options: -# --with-{NAME} -# -# configure/shell variables: -# {MODULE}_ROOT, {MODULE}_LIBDIR -# HAVE_{MODULE} (1 or 0) -# with_{module} ("yes" or "no") -# DUNE_CPPFLAGS, DUNE_LDFLAGS, DUNE_LIBS (adds the modules values here, -# substitution done by DUNE_CHECK_ALL) -# ALL_PKG_CPPFLAGS, ALL_PKG_LDFLAGS, ALL_PKG_LIBS (adds the modules values -# here, substitution done by DUNE_CHECK_ALL) -# {MODULE}_VERSION -# {MODULE}_VERSION_MAJOR -# {MODULE}_VERSION_MINOR -# {MODULE}_VERSION_REVISION -# -# configure substitutions/makefile variables: -# {MODULE}_CPPFLAGS, {MODULE}_LDFLAGS, {MODULE}_LIBS -# {MODULE}_ROOT -# {MODULE}_LIBDIR (only if modules provides a library) -# -# preprocessor defines: -# HAVE_{MODULE} (1 or undefined) -# {MODULE}_VERSION -# {MODULE}_VERSION_MAJOR -# {MODULE}_VERSION_MINOR -# {MODULE}_VERSION_REVISION -# -# automake conditionals: -# HAVE_{MODULE} -AC_DEFUN([OPM_CORE_CHECK_MODULES],[ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([AC_PROG_CXXCPP]) - AC_REQUIRE([PKG_PROG_PKG_CONFIG]) - AC_REQUIRE([DUNE_DISABLE_LIBCHECK]) - AC_REQUIRE([LT_OUTPUT]) - - # ____DUNE_CHECK_MODULES_____ ($1) - - m4_pushdef([_dune_name], [$1]) - m4_pushdef([_dune_module], [m4_translit(_dune_name, [-], [_])]) - m4_pushdef([_dune_header], [$2]) - m4_pushdef([_dune_ldpath], [lib]) - m4_pushdef([_dune_lib], [m4_translit(_dune_name, [-], [])]) - m4_pushdef([_dune_symbol], [$3]) - m4_pushdef([_DUNE_MODULE], [m4_toupper(_dune_module)]) - - # switch tests to c++ - AC_LANG_PUSH([C++]) - - # the usual option... - AC_ARG_WITH(_dune_name, - AS_HELP_STRING([--with-_dune_name=PATH],[_dune_module directory])) - - # backup of flags - ac_save_CPPFLAGS="$CPPFLAGS" - ac_save_LIBS="$LIBS" - ac_save_LDFLAGS="$LDFLAGS" - CPPFLAGS="" - LIBS="" - - ## - ## Where is the module $1? - ## - - AC_MSG_CHECKING([for $1 installation or source tree]) - - # is a directory set? - AS_IF([test -z "$with_[]_dune_module"],[ - # - # search module $1 via pkg-config - # - with_[]_dune_module="global installation" - 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]) - ]) - AS_IF(AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]),[ - _dune_cm_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 - _dune_cm_LDFLAGS="" - ifelse(_dune_symbol,, - [_DUNE_MODULE[]_LIBDIR="" - _dune_cm_LIBS=""], - [_DUNE_MODULE[]_LIBDIR=`$PKG_CONFIG --variable=libdir _dune_name 2>/dev/null` - _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) - HAVE_[]_DUNE_MODULE=1 - AC_MSG_RESULT([global installation in $_DUNE_MODULE[]_ROOT]) - ],[ - HAVE_[]_DUNE_MODULE=0 - AC_MSG_RESULT([not found]) - ]) - ],[ - # - # path for module $1 is specified via command line - # - 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) - AS_IF([test -d "$_DUNE_MODULE[]_ROOT/include/dune"],[ - # Dune was installed into directory given by with-dunecommon - _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_ROOT/include" - _DUNE_MODULE[]_BUILDDIR=_DUNE_MODULE[]_ROOT - _DUNE_MODULE[]_VERSION="`PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$_DUNE_MODULE[]_ROOT/lib/pkgconfig $PKG_CONFIG --modversion _dune_name`" 2>/dev/null - ],[ - _DUNE_MODULE[]_SRCDIR=$_DUNE_MODULE[]_ROOT - # extract src and build path from Makefile, if found - AS_IF([test -f $_DUNE_MODULE[]_ROOT/Makefile],[ - _DUNE_MODULE[]_SRCDIR="`sed -ne '/^abs_top_srcdir = /{s/^abs_top_srcdir = //; p;}' $_DUNE_MODULE[]_ROOT/Makefile`" - ]) - _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_SRCDIR" - _DUNE_MODULE[]_VERSION="`grep Version $_DUNE_MODULE[]_SRCDIR/dune.module | sed -e 's/^Version: *//'`" 2>/dev/null - ]) - _dune_cm_LDFLAGS="" - ifelse(_dune_symbol,, - [_DUNE_MODULE[]_LIBDIR="" - _dune_cm_LIBS=""], - [_DUNE_MODULE[]_LIBDIR="$_DUNE_MODULE[]_ROOT" - _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) - # set expanded module path - with_[]_dune_module="$_DUNE_MODULE[]_ROOT" - HAVE_[]_DUNE_MODULE=1 - 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]) - ]) - ]) - - CPPFLAGS="$ac_save_CPPFLAGS $DUNE_CPPFLAGS $_dune_cm_CPPFLAGS" - ## - ## check for an arbitrary header - ## - AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ - AC_CHECK_HEADER([[]_dune_header], - [HAVE_[]_DUNE_MODULE=1], [HAVE_[]_DUNE_MODULE=0]) - ]) - - AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ - 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]), - - 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_CXX="$CXX" - HAVE_[]_DUNE_MODULE=0 - - # define LTCXXLINK like it will be defined in the Makefile - CXX="./libtool --tag=CXX --mode=link $ac_save_CXX" - - # use module LDFLAGS - LDFLAGS="$ac_save_LDFLAGS $DUNE_LDFLAGS $_dune_cm_LDFLAGS" - LIBS="$_dune_cm_LIBS $DUNE_LIBS $LIBS" - - AC_MSG_CHECKING([for lib[]_dune_lib]) - - AC_TRY_LINK(dnl - [#]include<_dune_header>, - _dune_symbol, - [ - AC_MSG_RESULT([yes]) - HAVE_[]_DUNE_MODULE=1 - ],[ - 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 - CXX="$ac_save_CXX" - ]) - ) - - # did we succeed? - AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[ - # add the module's own flags and libs to the modules and the global - # variables - DUNE_ADD_MODULE_DEPS(m4_defn([_dune_name]), m4_defn([_dune_name]), - [$_dune_cm_CPPFLAGS], [$_dune_cm_LDFLAGS], [$_dune_cm_LIBS]) - - # set variables for our modules - AC_SUBST(_DUNE_MODULE[]_CPPFLAGS, "$_DUNE_MODULE[]_CPPFLAGS") - AC_SUBST(_DUNE_MODULE[]_LDFLAGS, "$_DUNE_MODULE[]_LDFLAGS") - AC_SUBST(_DUNE_MODULE[]_LIBS, "$_DUNE_MODULE[]_LIBS") - AC_SUBST(_DUNE_MODULE[]_ROOT, "$_DUNE_MODULE[]_ROOT") - ifelse(m4_defn([_dune_symbol]),, - [], - [AC_SUBST(_DUNE_MODULE[]_LIBDIR) - ]) - AC_DEFINE(HAVE_[]_DUNE_MODULE, 1, [Define to 1 if] _dune_name [was found]) - - DUNE_PARSE_MODULE_VERSION(_dune_name, $_DUNE_MODULE[]_VERSION) - - # set DUNE_* variables - # This should actually be unneccesary, but I'm keeping it in here for now - # for backward compatibility - DUNE_LDFLAGS="$DUNE_LDFLAGS $_DUNE_MODULE[]_LDFLAGS" - DUNE_LIBS="$_DUNE_MODULE[]_LIBS $DUNE_LIBS" - - with_[]_dune_module="yes" - ],[ - with_[]_dune_module="no" - ]) - - AM_CONDITIONAL(HAVE_[]_DUNE_MODULE, test x$HAVE_[]_DUNE_MODULE = x1) - - # reset previous flags - CPPFLAGS="$ac_save_CPPFLAGS" - LDFLAGS="$ac_save_LDFLAGS" - LIBS="$ac_save_LIBS" - - # add this module to DUNE_SUMMARY - DUNE_MODULE_ADD_SUMMARY_ENTRY(_dune_name) - - # remove local variables - m4_popdef([_dune_name]) - m4_popdef([_dune_module]) - m4_popdef([_dune_header]) - m4_popdef([_dune_ldpath]) - m4_popdef([_dune_lib]) - m4_popdef([_dune_symbol]) - m4_popdef([_DUNE_MODULE]) - - # restore previous language settings (leave C++) - AC_LANG_POP([C++]) -]) - # Additional checks needed to find eWoms # This macro should be invoked by every module which depends on dumux, but # not by dumux itself diff --git a/m4/opm_core_check_modules.m4 b/m4/opm_core_check_modules.m4 new file mode 100644 index 00000000..b445a886 --- /dev/null +++ b/m4/opm_core_check_modules.m4 @@ -0,0 +1,281 @@ +dnl -*- autoconf -*- + +# OPM_CORE_CHECK_MODULES(NAME, HEADER, SYMBOL) +# +# THIS MACRO IS JUST A COPY OF DUNE_CHECK_MODULES WITH THE REQUIREMENT +# THAT ALL HEADERS MUST RESIDE IN $MODULE_ROOT/dune REMOVED. REMOVE +# THIS MACRO AS SOON AS DUNE DOES NOT ENFORCE THIS ANYMORE. +# +# Generic check for dune modules. This macro should not be used directly, but +# in the modules m4/{module}.m4 in the {MODULE}_CHECK_MODULE macro. The +# {MODULE}_CHECK_MODULE macro knows the parameters to call this +# DUNE_CHECK_MODULES macro with, and it does not take any parameters itself, +# so it may be used with AC_REQUIRE. +# +# NAME Name of the module, lowercase with dashes (like "dune-common"). The +# value must be known when autoconf runs, so shell variables in the +# value are not permissible. +# +# HEADER Header to check for. The check will really be for , +# so the header must reside within a directory called "dune". +# +# SYMBOL Symbol to check for in the module's library. If this argument is +# empty or missing, it is assumed that the module does not provide a +# library. The value must be known when autoconf runs, so shell +# variables in the value are not permissible. This value is actually +# handed to AC_TRY_LINK unchanged as the FUNCTION-BODY argument, so it +# may contain more complex stuff than a simple symbol. +# +# The name of the library is assumed to be the same as the module name, +# with any occurance of "-" removed. The path of the library is +# obtained from pkgconfig for installed modules, or assumed to be the +# directory "lib" within the modules root for non-installed modules. +# +# In the following, {module} is {NAME} with any "-" replaced by "_" and +# {MODULE} is the uppercase version of {module}. +# +# configure options: +# --with-{NAME} +# +# configure/shell variables: +# {MODULE}_ROOT, {MODULE}_LIBDIR +# HAVE_{MODULE} (1 or 0) +# with_{module} ("yes" or "no") +# DUNE_CPPFLAGS, DUNE_LDFLAGS, DUNE_LIBS (adds the modules values here, +# substitution done by DUNE_CHECK_ALL) +# ALL_PKG_CPPFLAGS, ALL_PKG_LDFLAGS, ALL_PKG_LIBS (adds the modules values +# here, substitution done by DUNE_CHECK_ALL) +# {MODULE}_VERSION +# {MODULE}_VERSION_MAJOR +# {MODULE}_VERSION_MINOR +# {MODULE}_VERSION_REVISION +# +# configure substitutions/makefile variables: +# {MODULE}_CPPFLAGS, {MODULE}_LDFLAGS, {MODULE}_LIBS +# {MODULE}_ROOT +# {MODULE}_LIBDIR (only if modules provides a library) +# +# preprocessor defines: +# HAVE_{MODULE} (1 or undefined) +# {MODULE}_VERSION +# {MODULE}_VERSION_MAJOR +# {MODULE}_VERSION_MINOR +# {MODULE}_VERSION_REVISION +# +# automake conditionals: +# HAVE_{MODULE} +AC_DEFUN([OPM_CORE_CHECK_MODULES],[ + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PROG_CXXCPP]) + AC_REQUIRE([PKG_PROG_PKG_CONFIG]) + AC_REQUIRE([DUNE_DISABLE_LIBCHECK]) + AC_REQUIRE([LT_OUTPUT]) + + # ____DUNE_CHECK_MODULES_____ ($1) + + m4_pushdef([_dune_name], [$1]) + m4_pushdef([_dune_module], [m4_translit(_dune_name, [-], [_])]) + m4_pushdef([_dune_header], [$2]) + m4_pushdef([_dune_ldpath], [lib]) + m4_pushdef([_dune_lib], [m4_translit(_dune_name, [-], [])]) + m4_pushdef([_dune_symbol], [$3]) + m4_pushdef([_DUNE_MODULE], [m4_toupper(_dune_module)]) + + # switch tests to c++ + AC_LANG_PUSH([C++]) + + # the usual option... + AC_ARG_WITH(_dune_name, + AS_HELP_STRING([--with-_dune_name=PATH],[_dune_module directory])) + + # backup of flags + ac_save_CPPFLAGS="$CPPFLAGS" + ac_save_LIBS="$LIBS" + ac_save_LDFLAGS="$LDFLAGS" + CPPFLAGS="" + LIBS="" + + ## + ## Where is the module $1? + ## + + AC_MSG_CHECKING([for $1 installation or source tree]) + + # is a directory set? + AS_IF([test -z "$with_[]_dune_module"],[ + # + # search module $1 via pkg-config + # + with_[]_dune_module="global installation" + 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]) + ]) + AS_IF(AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]),[ + _dune_cm_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 + _dune_cm_LDFLAGS="" + ifelse(_dune_symbol,, + [_DUNE_MODULE[]_LIBDIR="" + _dune_cm_LIBS=""], + [_DUNE_MODULE[]_LIBDIR=`$PKG_CONFIG --variable=libdir _dune_name 2>/dev/null` + _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) + HAVE_[]_DUNE_MODULE=1 + AC_MSG_RESULT([global installation in $_DUNE_MODULE[]_ROOT]) + ],[ + HAVE_[]_DUNE_MODULE=0 + AC_MSG_RESULT([not found]) + ]) + ],[ + # + # path for module $1 is specified via command line + # + 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) + AS_IF([test -d "$_DUNE_MODULE[]_ROOT/include/dune"],[ + # Dune was installed into directory given by with-dunecommon + _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_ROOT/include" + _DUNE_MODULE[]_BUILDDIR=_DUNE_MODULE[]_ROOT + _DUNE_MODULE[]_VERSION="`PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$_DUNE_MODULE[]_ROOT/lib/pkgconfig $PKG_CONFIG --modversion _dune_name`" 2>/dev/null + ],[ + _DUNE_MODULE[]_SRCDIR=$_DUNE_MODULE[]_ROOT + # extract src and build path from Makefile, if found + AS_IF([test -f $_DUNE_MODULE[]_ROOT/Makefile],[ + _DUNE_MODULE[]_SRCDIR="`sed -ne '/^abs_top_srcdir = /{s/^abs_top_srcdir = //; p;}' $_DUNE_MODULE[]_ROOT/Makefile`" + ]) + _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_SRCDIR" + _DUNE_MODULE[]_VERSION="`grep Version $_DUNE_MODULE[]_SRCDIR/dune.module | sed -e 's/^Version: *//'`" 2>/dev/null + ]) + _dune_cm_LDFLAGS="" + ifelse(_dune_symbol,, + [_DUNE_MODULE[]_LIBDIR="" + _dune_cm_LIBS=""], + [_DUNE_MODULE[]_LIBDIR="$_DUNE_MODULE[]_ROOT" + _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) + # set expanded module path + with_[]_dune_module="$_DUNE_MODULE[]_ROOT" + HAVE_[]_DUNE_MODULE=1 + 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]) + ]) + ]) + + CPPFLAGS="$ac_save_CPPFLAGS $DUNE_CPPFLAGS $_dune_cm_CPPFLAGS" + ## + ## check for an arbitrary header + ## + AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ + AC_CHECK_HEADER([[]_dune_header], + [HAVE_[]_DUNE_MODULE=1], [HAVE_[]_DUNE_MODULE=0]) + ]) + + AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ + 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]), + + 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_CXX="$CXX" + HAVE_[]_DUNE_MODULE=0 + + # define LTCXXLINK like it will be defined in the Makefile + CXX="./libtool --tag=CXX --mode=link $ac_save_CXX" + + # use module LDFLAGS + LDFLAGS="$ac_save_LDFLAGS $DUNE_LDFLAGS $_dune_cm_LDFLAGS" + LIBS="$_dune_cm_LIBS $DUNE_LIBS $LIBS" + + AC_MSG_CHECKING([for lib[]_dune_lib]) + + AC_TRY_LINK(dnl + [#]include<_dune_header>, + _dune_symbol, + [ + AC_MSG_RESULT([yes]) + HAVE_[]_DUNE_MODULE=1 + ],[ + 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 + CXX="$ac_save_CXX" + ]) + ) + + # did we succeed? + AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[ + # add the module's own flags and libs to the modules and the global + # variables + DUNE_ADD_MODULE_DEPS(m4_defn([_dune_name]), m4_defn([_dune_name]), + [$_dune_cm_CPPFLAGS], [$_dune_cm_LDFLAGS], [$_dune_cm_LIBS]) + + # set variables for our modules + AC_SUBST(_DUNE_MODULE[]_CPPFLAGS, "$_DUNE_MODULE[]_CPPFLAGS") + AC_SUBST(_DUNE_MODULE[]_LDFLAGS, "$_DUNE_MODULE[]_LDFLAGS") + AC_SUBST(_DUNE_MODULE[]_LIBS, "$_DUNE_MODULE[]_LIBS") + AC_SUBST(_DUNE_MODULE[]_ROOT, "$_DUNE_MODULE[]_ROOT") + ifelse(m4_defn([_dune_symbol]),, + [], + [AC_SUBST(_DUNE_MODULE[]_LIBDIR) + ]) + AC_DEFINE(HAVE_[]_DUNE_MODULE, 1, [Define to 1 if] _dune_name [was found]) + + DUNE_PARSE_MODULE_VERSION(_dune_name, $_DUNE_MODULE[]_VERSION) + + # set DUNE_* variables + # This should actually be unneccesary, but I'm keeping it in here for now + # for backward compatibility + DUNE_LDFLAGS="$DUNE_LDFLAGS $_DUNE_MODULE[]_LDFLAGS" + DUNE_LIBS="$_DUNE_MODULE[]_LIBS $DUNE_LIBS" + + with_[]_dune_module="yes" + ],[ + with_[]_dune_module="no" + ]) + + AM_CONDITIONAL(HAVE_[]_DUNE_MODULE, test x$HAVE_[]_DUNE_MODULE = x1) + + # reset previous flags + CPPFLAGS="$ac_save_CPPFLAGS" + LDFLAGS="$ac_save_LDFLAGS" + LIBS="$ac_save_LIBS" + + # add this module to DUNE_SUMMARY + DUNE_MODULE_ADD_SUMMARY_ENTRY(_dune_name) + + # remove local variables + m4_popdef([_dune_name]) + m4_popdef([_dune_module]) + m4_popdef([_dune_header]) + m4_popdef([_dune_ldpath]) + m4_popdef([_dune_lib]) + m4_popdef([_dune_symbol]) + m4_popdef([_DUNE_MODULE]) + + # restore previous language settings (leave C++) + AC_LANG_POP([C++]) +])