1# -------------------------------------------------------------
2# MetaPhysicL - a C++ header-only numerics utility library
3# -------------------------------------------------------------
4AC_DEFUN([CONFIGURE_METAPHYSICL],
5[
6  AC_ARG_ENABLE(metaphysicl,
7                AS_HELP_STRING([--disable-metaphysicl],
8                               [build without MetaPhysicL suppport]),
9                [AS_CASE("${enableval}",
10                         [yes], [enablemetaphysicl=yes],
11                         [no],  [enablemetaphysicl=no],
12                         [AC_MSG_ERROR(bad value ${enableval} for --enable-metaphysicl)])],
13                [enablemetaphysicl=$enablenested])
14
15  dnl Setting --enable-metaphysicl-required causes an error to be
16  dnl emitted during configure if the MetaPhysicL library is not
17  dnl detected successfully.  This is useful for app codes which require
18  dnl MetaPhysicL (like MOOSE-based apps), since it prevents situations
19  dnl where libmesh is accidentally built without MetaPhysicL support
20  dnl (which may take a very long time), and then the app fails to
21  dnl compile, requiring you to redo everything.
22  AC_ARG_ENABLE(metaphysicl-required,
23                AC_HELP_STRING([--enable-metaphysicl-required],
24                               [Error if MetaPhysicL is not detected by configure]),
25                [AS_CASE("${enableval}",
26                         [yes], [metaphysiclrequired=yes],
27                         [no],  [metaphysiclrequired=no],
28                         [AC_MSG_ERROR(bad value ${enableval} for --enable-metaphysicl-required)])],
29                     [metaphysiclrequired=no])
30
31  dnl Let --enable-metaphysicl-required override the value of $enablenested. Also, if the user
32  dnl provides the nonsensical combination "--disable-metaphysicl --enable-metaphysicl-required"
33  dnl we'll set $enablemetaphysicl to yes instead.
34  AS_IF([test "x$enablemetaphysicl" = "xno" && test "x$metaphysiclrequired" = "xyes"],
35        [enablemetaphysicl=yes])
36
37  dnl Check for existence of a file that should always be in metaphysicl
38  AS_IF([test "x$enablemetaphysicl" = "xyes" && test -r $top_srcdir/contrib/metaphysicl/README],
39        [enablemetaphysicl=yes],
40        [
41          AC_MSG_RESULT([>>> Configuring metaphysicl failed, you may need to run 'git submodule update --init' first <<<])
42          enablemetaphysicl=no
43        ])
44
45  dnl If metaphysicl was required but isn't available, throw an error.
46  dnl We return a non-unity error code here, since 0 means success and 1 is
47  dnl indistinguishable from other errors.  Ideally, all of the
48  dnl AC_MSG_ERROR calls in our m4 files would return a different
49  dnl error code, but currently this is not implemented.
50  AS_IF([test "x$enablemetaphysicl" = "xno" && test "x$metaphysiclrequired" = "xyes"],
51        [AC_MSG_ERROR([*** MetaPhysicL was not found, but --enable-metaphysicl-required was specified.], 5)])
52
53  dnl The MetaPhysicL API is distributed with libmesh, so we don't have
54  dnl to guess where it might be installed.  This needs to be replaced
55  dnl someday with an option to include an external version instead.
56  AS_IF([test "x$enablemetaphysicl" = "xyes"],
57        [
58          METAPHYSICL_INCLUDE="-I\$(top_srcdir)/contrib/metaphysicl/src/numerics/include -I\$(top_srcdir)/contrib/metaphysicl/src/core/include -I\$(top_srcdir)/contrib/metaphysicl/src/utilities/include"
59          AC_DEFINE(HAVE_METAPHYSICL, 1, [Flag indicating whether the library will be compiled with MetaPhysicL support])
60          AC_MSG_RESULT(<<< Configuring library with MetaPhysicL support >>>)
61          AC_CONFIG_SUBDIRS([contrib/metaphysicl])
62        ],
63        [
64          METAPHYSICL_INCLUDE=""
65          enablemetaphysicl=no
66        ])
67
68  AC_SUBST(METAPHYSICL_INCLUDE)
69])
70