Tentative refinement of ERT Autoconf support.

Add a new macro, "ERT", that uses AC_LINK_IFELSE to test if the ECL and
related libraries are available of the local computer system.  Call the
macro from "configure.ac".

Also, adapt the main "Makefile.am" to the results of the "ERT" macro.
This commit is contained in:
Bård Skaflestad 2012-06-28 13:27:03 +02:00
parent bb066aa23b
commit 41736965ff
3 changed files with 87 additions and 68 deletions

View File

@ -11,31 +11,35 @@ lib_LTLIBRARIES = libopmcore.la
# ----------------------------------------------------------------------
# Build-time flags needed to build libopmcore.la
AM_CPPFLAGS = \
$(ERT_CPPFLAGS) \
$(BOOST_CPPFLAGS)
#-----------------------------------------------------------------
# ERT related settings
#if HAVE_ERT
ERT_LIB_PATH = $(ERT_ROOT)/lib
ERT_LIBS = -lecl -lgeometry -lutil -lpthread -lz -lgomp
ERT_LDFLAGS = -L$(ERT_LIB_PATH) $(ERT_LIBS)
ERT_INCLUDE_PATH = $(ERT_ROOT)/include
ERT_CPPFLAGS = -I$(ERT_INCLUDE_PATH)
#endif
# ERT_LIB_PATH = $(ERT_ROOT)/lib
# ERT_LIBS = -lecl -lgeometry -lutil -lpthread -lz -lgomp
# ERT_LDFLAGS = -L$(ERT_LIB_PATH) $(ERT_LIBS)
# ERT_INCLUDE_PATH = $(ERT_ROOT)/include
# ERT_CPPFLAGS = -I$(ERT_INCLUDE_PATH)
AM_CPPFLAGS = \
$(BOOST_CPPFLAGS) \
-I$(ERT_INCLUDE_PATH)
#AM_CPPFLAGS += \
#$(ERT_CPPFLAGS)
#endif
# ----------------------------------------------------------------------
# Link-time flags needed both to successfully link the library and to
# (transitively) convey inter-library dependency information.
libopmcore_la_LDFLAGS = \
$(BOOST_LDFLAGS) \
$(BOOST_FILESYSTEM_LIB) \
$(BOOST_SYSTEM_LIB) \
$(BOOST_DATE_TIME_LIB) \
libopmcore_la_LDFLAGS = \
$(ERT_LDFLAGS) \
$(BOOST_LDFLAGS) \
$(BOOST_FILESYSTEM_LIB) \
$(BOOST_SYSTEM_LIB) \
$(BOOST_DATE_TIME_LIB) \
$(BOOST_UNIT_TEST_FRAMEWORK_LIB) \
$(ERT_LDFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS)
$(ERT_LIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS)
# ----------------------------------------------------------------------
# Library constituents. SOURCES followed by HEADERS.

View File

@ -78,59 +78,7 @@ m4_ifdef([AM_COND_IF],
UMFPACK support is disabled.])])
])
#-----------------------------------------------------------------
# Support for ERT configuration in the OPM build process. The
# configuration is unfortunately not really functional :-(.
#
# Define the option --with-ert=/path/to/ert/root which can be passed
# to the configure script. If we pass --with-ert=no (the default)
# support for use of ert libraries will not be added built in;
# otherwise we will build support for ERT.
#
# The argument given to the --with-ert option will be interpreted as
# the root path of a ert installation, and the build process will
# expect to find the ert libraries in $with_ert/lib and the header
# files in $with_ert/include. There are no check for actually finding
# the required libraries and headers, and support for ert could in
# principle be configured as:
#
# configure --with-ert=yes CPPFLAGS=-I/path/to/ert/include LDFLAGS=-L/path/to/ert/lib
AC_ARG_WITH(ert, [AS_HELP_STRING([--with-ert=<root>], [Use ERT libraries])], [], [with_ert=no])
AM_CONDITIONAL([HAVE_ERT],
[test "x$ert" != "xno"])
# The purpose of this macro was to test if the WITH_ERT conditional
# was true, and in that case the statements:
#
# AC_SUBST([ERT_ROOT],["$with_ert"])
# AC_DEFINE([HAVE_ERT],1,[Are the ERT libraries available])
#
# should be invoked - but the if construction does not work, and at
# the bottom of the configuration the two statements are invoked
# unconditionally (i.e. in the end the build will be with ert
# anyway). I will award anyone who can fix this a real bear :-) -
# Joakim.
m4_ifdef([AM_COND_IF],
[AM_COND_IF([HAVE_ERT], [AC_SUBST([ERT_ROOT],["$with_ert"])], [])
])
AC_SUBST([ERT_ROOT],["$with_ert"])
AC_DEFINE(HAVE_ERT,1,[Are the ERT libraries available for reading and writing ECLIPSE files.])
# In addition to what is present in this script ERT support is further
# configured through:
#
# o The ERT_LDFLAGS and ERT_CPPFLAGS configured in the Makefile.am
# template.
#
# o The config.h file will define the symbol HAVE_ERT if ert is built into
# the current installation.
#-----------------------------------------------------------------
ERT
AC_CONFIG_FILES([
Makefile

67
m4/ert.m4 Normal file
View File

@ -0,0 +1,67 @@
AC_DEFUN([_ERT_SOURCE_TEXT],
[
AC_LANG_PROGRAM(
[[
#include <stddef.h>
#include <ecl_util.h>
]],dnl
[[
int sz;
sz = ecl_util_get_sizeof_ctype(ECL_INT_TYPE);
]])[]dnl
])[]dnl
# ----------------------------------------------------------------------
AC_DEFUN([ERT],
[
AC_ARG_WITH([ert],
[AS_HELP_STRING([--with-ert=<root>], [Use ERT libraries])],
[], [with_ert=no])
use_ert=no
AS_IF([test x"${with_ert}" != x"no"],
[
_ert_LDFLAGS_SAVE="${LDFLAGS}"
_ert_LIBS_SAVE="${LIBS}"
_ert_CPPFLAGS_SAVE="${CPPFLAGS}"
_ert_CFLAGS_SAVE="${CFLAGS}"
ERT_CPPFLAGS=
ERT_LDFLAGS=
ERT_LIBS="-lecl -lgeometry -lutil -lpthread -lz -lgomp"
AS_IF([test x"${with_ert}" != x"yes"],
[ERT_LDFLAGS="-L${with_ert}/lib"
ERT_CPPFLAGS="-I${with_ert}/include"], [:])[]dnl
CFLAGS="-std=gnu99"
CPPFLAGS="${ERT_CPPFLAGS} ${CPPFLAGS}"
LDFLAGS="${ERT_LDFLAGS} ${LDFLAGS}"
LIBS="${ERT_LIBS} ${LIBS}"
AC_LINK_IFELSE([_ERT_SOURCE_TEXT],
[use_ert=yes], [use_ert=no])
LIBS="${_ert_LIBS_SAVE}"
CPPFLAGS="${_ert_CPPFLAGS_SAVE}"
LDFLAGS="${_ert_LDFLAGS_SAVE}"
CFLAGS="${_ert_CFLAGS_SAVE}"
AS_IF([test x"${use_ert}" == x"yes"],
[AC_SUBST([ERT_CPPFLAGS])
AC_SUBST([ERT_LDFLAGS])
AC_SUBST([ERT_LIBS])
AC_DEFINE([HAVE_ERT], [1],
[Are the ERT libraries available for reading and writing ECLIPSE files.])],dnl
[:])[]dnl
], [:])[]dnl
AM_CONDITIONAL([HAVE_ERT], [test x"${use_ert}" != x"no"])
# AC_MSG_ERROR(
# [**** ERT_CPPFLAGS = ${ERT_CPPFLAGS} ****
# **** ERT_LDFLAGS = ${ERT_LDFLAGS} ****
# **** ERT_LIBS = ${ERT_LIBS} ****
# ])
])