Salome HOME
Fix n.3 of hack_libtool utility to workaround problems on some Linux configurations
[modules/kernel.git] / salome_adm / unix / config_files / check_hdf5.m4
1 dnl  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 dnl
3 dnl  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 dnl
6 dnl  This library is free software; you can redistribute it and/or
7 dnl  modify it under the terms of the GNU Lesser General Public
8 dnl  License as published by the Free Software Foundation; either
9 dnl  version 2.1 of the License.
10 dnl
11 dnl  This library is distributed in the hope that it will be useful,
12 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 dnl  Lesser General Public License for more details.
15 dnl
16 dnl  You should have received a copy of the GNU Lesser General Public
17 dnl  License along with this library; if not, write to the Free Software
18 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 dnl
20 dnl  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 dnl
22
23 AC_DEFUN([CHECK_HDF5],[
24 AC_REQUIRE([AC_PROG_CC])dnl
25 AC_REQUIRE([AC_PROG_CPP])dnl
26
27 AC_CHECKING(for HDF5)
28
29 AC_ARG_WITH(hdf5,
30     [AC_HELP_STRING([--with-hdf5=DIR],[root directory path to hdf5 installation])],
31     [HDF5HOME="$withval"
32       AC_MSG_RESULT("select $withval as path to hdf5")
33     ])
34
35 AC_SUBST(HDF5_INCLUDES)
36 AC_SUBST(HDF5_LIBS)
37 AC_SUBST(HDF5_MT_LIBS)
38
39 HDF5_INCLUDES=""
40 HDF5_LIBS=""
41 HDF5_MT_LIBS=""
42
43 hdf5_ok=no
44
45 LOCAL_INCLUDES=""
46 LOCAL_LIBS=""
47 LOCAL_RLIBS=""
48
49 if test -z $HDF5HOME
50 then
51    AC_MSG_WARN(undefined HDF5HOME variable which specify hdf5 installation directory)
52    AC_MSG_NOTICE(Trying native Hdf5...)
53    dnl For Parallel HDF5 test
54    HDF5HOME="/usr" 
55 else
56    LOCAL_INCLUDES="-I$HDF5HOME/include"
57    if test "x$HDF5HOME" = "x/usr"
58    then
59       AC_MSG_NOTICE(Trying native Hdf5...)
60       LOCAL_LIBS=""
61    else
62       AC_MSG_NOTICE(Trying Hdf5 from $HDF5HOME ...)
63       LOCAL_LIBS="-L$HDF5HOME/lib"
64       LOCAL_RLIBS="-R$HDF5HOME/lib"
65    fi
66 fi
67
68 hdf5_parallel=0
69
70 if  test "x$hdf5_ok" = "xno"
71 then
72   if  test -e "$HDF5HOME/include/hdf5.h" 
73   then
74     AC_MSG_NOTICE(Checking if hdf5 is parallel and thus needs mpi...)
75     hdf5_parallel=`grep "#define H5_HAVE_PARALLEL" $HDF5HOME/include/H5pubconf.h | awk '{i=3 ; print $i}'`
76     if test "x$hdf5_parallel" = "x1"
77     then
78       AC_MSG_RESULT(***** Yes: checking MPI...******)
79       CHECK_MPI
80       AC_MSG_RESULT(***** Checking MPI done...******)
81       LOCAL_INCLUDES="-DOMPI_SKIP_MPICXX $MPI_INCLUDES $LOCAL_INCLUDES"
82     else
83       AC_MSG_RESULT(No,hdf5 seems serial)
84     fi
85   else
86     AC_MSG_WARN(File $HDF5HOME/include/hdf5.h not present)
87   fi
88 fi
89
90 dnl hdf5 headers
91
92 CPPFLAGS_old="$CPPFLAGS"
93 CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
94 AC_CHECK_HEADER(hdf5.h,hdf5_ok=yes ,hdf5_ok=no)
95 CPPFLAGS="$CPPFLAGS_old"
96
97
98 if  test "x$hdf5_ok" = "xyes"
99 then
100
101 dnl hdf5 library
102
103   LIBS_old="$LIBS"
104   LIBS="$LIBS $LOCAL_LIBS"
105   AC_CHECK_LIB(hdf5,H5open,hdf5_ok=yes,hdf5_ok=no)
106   LIBS="$LIBS_old"
107
108 fi
109
110 if  test "x$hdf5_ok" = "xyes"
111 then
112   HDF5_INCLUDES="$LOCAL_INCLUDES"
113   HDF5_LIBS="$LOCAL_LIBS -lhdf5 $LOCAL_RLIBS"
114   HDF5_MT_LIBS="$LOCAL_LIBS -lhdf5 $LOCAL_RLIBS"
115 fi
116
117 if  test "x$hdf5_ok" = "xyes"
118 then
119   HDF5_INCLUDES="$HDF5_INCLUDES -DH5_USE_16_API"
120 fi
121
122 AC_MSG_RESULT(for hdf5: $hdf5_ok)
123
124 ])dnl