File: cs_hdf5.m4

package info (click to toggle)
code-saturne 5.3.2+repack-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 76,868 kB
  • sloc: ansic: 338,582; f90: 118,487; python: 65,227; makefile: 4,429; cpp: 3,826; xml: 3,078; sh: 1,205; lex: 170; yacc: 100
file content (221 lines) | stat: -rw-r--r-- 6,487 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
dnl--------------------------------------------------------------------------------
dnl
dnl This file is part of Code_Saturne, a general-purpose CFD tool.
dnl
dnl Copyright (C) 1998-2018 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_HDF5
#----------------
# modifies or sets cs_have_hdf5, HDF_CPPFLAGS, HDF_LDFLAGS, and HDF_LIBS
# depending on libraries found

AC_DEFUN([CS_AC_TEST_HDF5], [

cs_have_hdf5=no
cs_have_hdf5_header=no
cs_hdf5_libpath=""
hdf5_prefix=""

AC_ARG_WITH(hdf5,
            [AS_HELP_STRING([--with-hdf5=PATH],
                            [specify prefix directory for HDF5])],
            [if test "x$withval" = "x"; then
               with_hdf5=yes
             elif test "x$withval" = "xsalome"; then
               if test -z "$HDF5HOME"; then
                 AC_MSG_FAILURE([no SALOME path information for HDF5 (needed by --with-hdf5=salome)!])
               else
                 with_hdf5=$HDF5HOME
               fi
             fi],
            [with_hdf5=check])

AC_ARG_WITH(hdf5-include,
            [AS_HELP_STRING([--with-hdf5-include=PATH],
                            [specify directory for HDF5 include files])],
            [if test "x$with_hdf5" = "xcheck"; then
               with_hdf5=yes
             fi
             HDF5_CPPFLAGS="-I$with_hdf5_include"],
            [if test "x$with_hdf5" != "xno" -a "x$with_hdf5" != "xyes" \
	          -a "x$with_hdf5" != "xcheck"; then
               HDF5_CPPFLAGS="-I$with_hdf5/include"
             fi])

AC_ARG_WITH(hdf5-lib,
            [AS_HELP_STRING([--with-hdf5-lib=PATH],
                            [specify directory for HDF5 library])],
            [if test "x$with_hdf5" = "xcheck"; then
               with_hdf5=yes
             fi
             HDF5_LDFLAGS="-L$with_hdf5_lib"
             cs_hdf5_libpath="$with_hdf5_lib"
             # Add the libdir to the runpath as HDF5 might not be libtoolized
             HDF5RUNPATH=""],
            [if test "x$with_hdf5" != "xno" -a "x$with_hdf5" != "xyes" \
	          -a "x$with_hdf5" != "xcheck"; then
               HDF5_LDFLAGS="-L$with_hdf5/lib"
               # Add the libdir to the runpath as HDF5 might not be libtoolized
               HDF5RUNPATH=""
               cs_hdf5_libpath="$with_hdf5/lib"
             fi])


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

  # Now run tests

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

  CPPFLAGS="${CPPFLAGS} ${HDF5_CPPFLAGS}"

  # First, check for hdf5.h header
  AC_CHECK_HEADERS([hdf5.h],
                   [cs_have_hdf5_header=yes],
                   [],
                   [])

  if test $cs_have_hdf5_header = no ; then
    unset ac_cv_header_hdf5_h
    HDF5_CPPFLAGS="${HDF5_CPPFLAGS} ${MPI_CPPFLAGS}"
    CPPFLAGS="${saved_CPPFLAGS} ${HDF5_CPPFLAGS}"
    AC_CHECK_HEADERS([hdf5.h],
                     [cs_have_hdf5_header=yes],
                     [],
                     [])
  fi

  # If HDF5 was built with MPI support, it might also be needed here

  AC_EGREP_CPP([cs_hdf5_parallel],
               [
                #include <hdf5.h>
                #ifdef H5_HAVE_PARALLEL
                #if (H5_HAVE_PARALLEL > 0)
                cs_hdf5_parallel
                #endif
                #endif
                ],
                [cs_hdf5_need_mpi=yes],
                [cs_hdf5_need_mpi=no])

  LDFLAGS="${LDFLAGS} ${HDF5_LDFLAGS}"

  cs_hdf5_libnames="hdf5-shared hdf5-static hdf5"
  cs_hdf5_libname=""

  if test "x$cs_hdf5_libpath" != x ; then
    if test ! -d "$cs_hdf5_libpath" ; then
      AC_MSG_FAILURE([directory specified by --with-hdf5-lib=$cs_hdf5_libpath does not exist!])
    fi
    for n in $cs_hdf5_libnames ; do
      if test "x$cs_hdf5_libname" = "x" ; then
        ls "$cs_hdf5_libpath"/"$n".* > /dev/null 2>&1
        if test $? == "0"; then
          cs_hdf5_libname=$n
          cs_hdf5_libnames="$cs_hdf5_libname"
        fi
      fi
    done
  fi

  unset cs_hdf5_libname

  for hdf5_libname in $cs_hdf5_libnames ; do

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

      if test "x$cs_hdf5_need_mpi" = "xyes" ; then
        HDF5_CPPFLAGS_MPI=$MPI_CPPFLAGS
        HDF5_LDFLAGS_MPI=$MPI_LDFLAGS
        CPPFLAGS="${CPPFLAGS} ${HDF5_CPPFLAGS_MPI}"
        LDFLAGS="${LDFLAGS} ${HDF5_LDFLAGS_MPI}"
      fi

      HDF5_LIBS="-l${hdf5_libname} $PTHREAD_LIBS"
      LIBS="${HDF5_LIBS} ${saved_LIBS}"

      if test "x$cs_hdf5_need_mpi" = "xyes" ; then
        HDF5_LIBS_MPI=$MPI_LIBS
        LIBS="${HDF5_LIBS} ${HDF5_LIBS_MPI}"
      fi

      # Now check library

      AC_CHECK_LIB($hdf5_libname, H5Fopen,
                   [ AC_DEFINE([HAVE_HDF5], 1, [HDF5 file support])
                     cs_have_hdf5=yes
                   ],
                   [],
                   )

    fi

    if test "x$cs_have_hdf5" = "xno"; then
      HDF5_LIBS=""
      HDF5_CPPFLAGS_MPI=""
      HDF5_LDFLAGS_MPI=""
      HDF5_LIBS_MPI=""
    fi

  done

  if test "x$cs_have_hdf5" = "xno"; then
    if test "x$with_hdf5" != "xcheck" ; then
      AC_MSG_FAILURE([HDF5 support is requested, but test for HDF5 failed!])
    else
      AC_MSG_WARN([no HDF5 file support])
    fi
  fi

  unset cs_hdf5_libnames
  unset cs_hdf5_libpath

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

  unset saved_CPPFLAGS
  unset saved_LDFLAGS
  unset saved_LIBS

  case $host_os in
    mingw32)
      hdf5_prefix=`cygpath --path --windows "$with_hdf5"`;;
    *)
      ;;
  esac

fi

AC_SUBST(cs_have_hdf5)
AC_SUBST(hdf5_prefix, [${hdf5_prefix}])
AC_SUBST(HDF5_CPPFLAGS)
AC_SUBST(HDF5_LDFLAGS)
AC_SUBST(HDF5_LIBS)
AC_SUBST(HDF5RUNPATH)

AC_SUBST(HDF5_CPPFLAGS_MPI)
AC_SUBST(HDF5_LDFLAGS_MPI)
AC_SUBST(HDF5_LIBS_MPI)

])dnl