1# -*- shell-script -*-
2#
3# Copyright (c) 2014-2016 Intel, Inc.  All rights reserved.
4# $COPYRIGHT$
5#
6# Additional copyrights may follow
7#
8# $HEADER$
9#
10
11# MCA_pmix_flux_CONFIG([action-if-found], [action-if-not-found])
12# -----------------------------------------------------------
13AC_DEFUN([MCA_opal_pmix_flux_CONFIG], [
14
15    AC_CONFIG_FILES([opal/mca/pmix/flux/Makefile])
16
17    AC_ARG_WITH([flux-pmi],
18                [AC_HELP_STRING([--with-flux-pmi],
19                                [Build Flux PMI support (default: yes)])])
20
21    AC_ARG_WITH([flux-pmi-library],
22                [AC_HELP_STRING([--with-flux-pmi-library],
23                                [Link Flux PMI support with PMI library at build time.  Otherwise the library is opened at runtime at location specified by FLUX_PMI_LIBRARY_PATH environment variable.  Use this option to enable Flux support when building statically or without dlopen support (default: no)])])
24
25
26    # pkg-config check aborts configure on failure
27    AC_MSG_CHECKING([if user wants Flux support to link against PMI library])
28    AS_IF([test "x$with_flux_pmi_library" != "xyes"],
29          [AC_MSG_RESULT([no])
30           $3],
31          [AC_MSG_RESULT([yes])
32          PKG_CHECK_MODULES([FLUX_PMI], [flux-pmi], [], [])
33          have_flux_pmi_library=yes
34          AC_DEFINE([HAVE_FLUX_PMI_LIBRARY], [1],
35                    [Flux support builds against external PMI library])
36          ])
37
38    AC_MSG_CHECKING([if Flux support allowed to use dlopen])
39    AS_IF([test $OPAL_ENABLE_DLOPEN_SUPPORT -eq 1 && test "x$compile_mode" = "xdso"],
40          [AC_MSG_RESULT([yes])
41          flux_can_dlopen=yes
42          ],
43          [AC_MSG_RESULT([no])
44          ])
45
46    AC_MSG_CHECKING([Checking if Flux PMI support can be built])
47    AS_IF([test "x$with_flux_pmi" != "xno" && ( test "x$have_flux_pmi_library" = "xyes" || test "x$flux_can_dlopen" = "xyes" ) ],
48          [AC_MSG_RESULT([yes])
49          opal_enable_flux=yes
50	  ],
51          [AC_MSG_RESULT([no])
52          AS_IF([test "x$with_flux_pmi" = "xyes"],
53                [AC_MSG_ERROR([Aborting since Flux PMI support was requested])
54                ])
55          ])
56
57    # Evaluate succeed / fail
58    AS_IF([test "x$opal_enable_flux" = "xyes"],
59          [$1
60           # need to set the wrapper flags for static builds
61           pmix_flux_WRAPPER_EXTRA_LIBS="$FLUX_PMI_LIBS"],
62          [$2])
63])
64