File: cs_melissa.m4

package info (click to toggle)
code-saturne 6.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 63,340 kB
  • sloc: ansic: 354,724; f90: 119,812; python: 87,716; makefile: 4,653; cpp: 4,272; xml: 2,839; sh: 1,228; lex: 170; yacc: 100
file content (245 lines) | stat: -rw-r--r-- 8,114 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
dnl--------------------------------------------------------------------------------
dnl
dnl This file is part of Code_Saturne, a general-purpose CFD tool.
dnl
dnl Copyright (C) 1998-2019 EDF S.A.
dnl
dnl This program is free software; you can redistribute it and/or modify it under
dnl the terms of the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any later
dnl version.
dnl
dnl This program is distributed in the hope that it will be useful, but WITHOUT
dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dnl FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
dnl details.
dnl
dnl You should have received a copy of the GNU General Public License along with
dnl this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
dnl Street, Fifth Floor, Boston, MA 02110-1301, USA.
dnl
dnl--------------------------------------------------------------------------------

# CS_AC_TEST_MELISSA
#--------------------
# modifies or sets cs_have_melissa, MELISSA_CPPFLAGS, MELISSA_LDFLAGS,
# and MELISSA_LIBS depending on libraries found

AC_DEFUN([CS_AC_TEST_MELISSA], [

cs_have_melissa=no
cs_have_melissa_mpi=no
cs_have_plugin_melissa=yes

# ZeroMQ paths
#-------------

AC_ARG_WITH(zeromq,
            [AS_HELP_STRING([--with-zeromq=PATH],
                            [specify prefix directory for ZeroMQ])],
            [if test "x$withval" = "x"; then
               with_zeromq=yes
             fi],
            [with_zeromq=check])

AC_ARG_WITH(zeromq-include,
            [AS_HELP_STRING([--with-zeromq-include=DIR],
                            [specify directory for ZeroMQ include files])],
            [if test "x$with_zeromq" = "xcheck"; then
               with_zeromq=yes
             fi
             ZEROMQ_CPPFLAGS="-I$with_zeromq_include"],
            [if test "x$with_zeromq" != "xno" -a "x$with_zeromq" != "xyes" \
	          -a "x$with_zeromq" != "xcheck"; then
               ZEROMQ_CPPFLAGS="-I$with_zeromq/include"
             fi])

AC_ARG_WITH(zeromq-lib,
            [AS_HELP_STRING([--with-zeromq-lib=DIR],
                            [specify directory for ZeroMQ library])],
            [if test "x$with_zeromq" = "xcheck"; then
               with_zeromq=yes
             fi
             ZEROMQ_LDFLAGS="-L$with_zeromq_lib"
             # Add the libdir to the runpath as ZeroMQ is not libtoolized
             ZEROMQRUNPATH="-R$with_zeromq_lib"],
            [if test "x$with_zeromq" != "xno" -a "x$with_zeromq" != "xyes" \
	          -a "x$with_zeromq" != "xcheck"; then
               ZEROMQ_LDFLAGS="-L$with_zeromq/lib"
               # Add the libdir to the runpath as zeromq is not libtoolized
               ZEROMQRUNPATH="-R$with_zeromq/lib"
             fi])

# Configure options for Melissa paths
#------------------------------------

AC_ARG_WITH(melissa,
            [AS_HELP_STRING([--with-melissa=PATH],
                            [specify prefix directory for MELISSA])],
            [if test "x$withval" = "x"; then
               with_melissa=no
             fi],
            [with_melissa=no])

AC_ARG_WITH(melissa-include,
            [AS_HELP_STRING([--with-melissa-include=DIR],
                            [specify directory for melissa include files])],
            [if test "x$with_melissa" = "xcheck"; then
               with_melissa=yes
             fi
             MELISSA_CPPFLAGS="-I$with_melissa_include"],
            [if test "x$with_melissa" != "xno" -a "x$with_melissa" != "xyes" \
	          -a "x$with_melissa" != "xcheck"; then
               MELISSA_CPPFLAGS="-I$with_melissa/include"
             fi])

AC_ARG_WITH(melissa-lib,
            [AS_HELP_STRING([--with-melissa-lib=DIR],
                            [specify directory for melissa library])],
            [if test "x$with_melissa" = "xcheck"; then
               with_melissa=yes
             fi
             MELISSA_LDFLAGS="-L$with_melissa_lib"
             # Add the libdir to the runpath as melissa is not libtoolized
             MELISSARUNPATH="-R$with_melissa_lib"],
            [if test "x$with_melissa" != "xno" -a "x$with_melissa" != "xyes" \
	          -a "x$with_melissa" != "xcheck"; then
               MELISSA_LDFLAGS="-L$with_melissa/lib"
               # Add the libdir to the runpath as melissa is not libtoolized
               MELISSARUNPATH="-R$with_melissa/lib"
             fi])

AC_ARG_ENABLE(melissa-as-plugin,
  [AS_HELP_STRING([--disable-melissa-as-plugin], [do not use Melissa as plugin])],
  [
    case "${enableval}" in
      yes) cs_have_plugin_melissa=yes ;;
      no)  cs_have_plugin_melissa=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-melissa-as-plugin]) ;;
    esac
  ],
  [ cs_have_plugin_melissa=yes ]
)

if test x$cs_have_dlloader = xno -o x$enable_shared = xno ; then
  cs_have_plugin_melissa=no
fi

# Now check for libraries
#------------------------

if test "x$with_zeromq" != "xno" -a "x$with_melissa" != "xno"; then

  saved_CPPFLAGS="$CPPFLAGS"
  saved_LDFLAGS="$LDFLAGS"
  saved_LIBS="$LIBS"

  MELISSA_CPPFLAGS="${MELISSA_CPPFLAGS} ${ZEROMQ_CPPFLAGS}"
  MELISSA_LIBS="-lmelissa_api -lzmq"
  MELISSA_LDFLAGS="${MELISSA_LDFLAGS} ${ZEROMQ_LDFLAGS}"

  if test "x$cs_have_mpi" != "xno"; then

    AC_MSG_CHECKING([for Melissa library (with MPI)])

    CPPFLAGS="${CPPFLAGS} ${MELISSA_CPPFLAGS} ${MPI_CPPFLAGS}"
    LDFLAGS="${LDFLAGS} ${MELISSA_LDFLAGS} ${MPI_LDFLAGS}"
    LIBS="${MELISSA_LIBS} ${MPI_LIBS} ${LIBS}"

    AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <mpi.h>
#include <melissa_api.h>]],
[[#if defined(MELISSA_MAJOR_NUM)
(void)melissa_init("name", 1, MPI_COMM_SELF);
#else
(void)melissa_init("name", 1, 1, 0, 0, MPI_COMM_SELF, 1);
#endif ]])],
                   [cs_have_melissa_mpi=yes],
                   [cs_have_melissa_mpi=no])

  fi

  if test "x$cs_have_melissa_mpi" = "xyes"; then
    cs_have_melissa=yes
  fi

  if test "x$cs_have_melissa" = "xno"; then

    AC_MSG_CHECKING([for Melissa library])

    CPPFLAGS="${saved_CPPFLAGS} ${MELISSA_CPPFLAGS}"
    LDFLAGS="${saved_LDFLAGS} ${MELISSA_LDFLAGS}"
    LIBS="${MELISSA_LIBS} ${_saved_LIBS}"

    LDFLAGS="${LDFLAGS} ${MELISSA_LDFLAGS}"
    LIBS="${MELISSA_LIBS} ${LIBS}"

    AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <melissa_api_no_mpi.h>]],
[[#if defined(MELISSA_MAJOR_NUM)
(void)melissa_init_no_mpi("name", 1);
#else
(void)melissa_init_no_mpi("name", 1, 0, 1);
#endif ]])],
                   [cs_have_melissa=yes],
                   [cs_have_melissa=no])

  fi

  # Report Melissa support
  #------------------------

  if test "x$cs_have_melissa" = "xyes" ; then
    AC_DEFINE([HAVE_MELISSA], 1, [Melissa co-processing support])
    if test "x$cs_have_melissa_mpi" = "xyes" ; then
      AC_DEFINE([HAVE_MELISSA_MPI], 1, [Melissa co-processing support with MPI])
    fi
    if test x$cs_have_plugin_melissa = xyes ; then
      AC_DEFINE([HAVE_PLUGIN_MELISSA], 1, [Melissa co-processing support as plugin])
    fi
  elif test "x$cs_have_melissa" = "xno" ; then
    if test "x$with_melissa" != "xcheck" ; then
      AC_MSG_FAILURE([Melissa co-processing support requested, but test for Melissa failed!])
    else
      AC_MSG_WARN([no Melissa co-processing support])
    fi
  fi

  AC_MSG_RESULT($cs_have_melissa)

  if test "x$cs_have_melissa" != "xyes"; then
    MELISSA_LIBS=""
  fi

  CPPFLAGS="$saved_CPPFLAGS"
  LDFLAGS="$saved_LDFLAGS"
  LIBS="$saved_LIBS"

  unset saved_CPPFLAGS
  unset saved_LDFLAGS
  unset saved_LIBS

fi

AM_CONDITIONAL(HAVE_MELISSA, test x$cs_have_melissa = xyes)

if test x$cs_have_melissa = xno ; then
  cs_have_plugin_melissa=no
fi

AM_CONDITIONAL(HAVE_MELISSA, test x$cs_have_melissa = xyes)
AM_CONDITIONAL(HAVE_PLUGIN_MELISSA, test x$cs_have_plugin_melissa = xyes)

cs_py_have_plugin_melissa=False
if test x$cs_have_plugin_melissa = xyes ; then
  cs_py_have_plugin_melissa=True
fi

AC_SUBST(cs_have_melissa)
AC_SUBST(cs_py_have_plugin_melissa)
AC_SUBST(MELISSA_CPPFLAGS)
AC_SUBST(MELISSA_LDFLAGS)
AC_SUBST(MELISSA_LIBS)
AC_SUBST(MELISSARUNPATH)

])dnl