Fix header path for hdf5
[scilab.git] / scilab / m4 / hdf5.m4
1 dnl
2 dnl Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 dnl Copyright (C) DIGITEO - 2009 - Bruno JOFRET
4 dnl
5 dnl This file must be used under the terms of the CeCILL.
6 dnl This source file is licensed as described in the file COPYING, which
7 dnl you should have received as part of this distribution.  The terms
8 dnl are also available at
9 dnl http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
10 dnl
11 dnl libhdf5 is mandatory in Scilab
12 dnl When we check :
13 dnl * if the path is provided or that we have to find it ourself
14 dnl * if it is available
15 dnl * what are the compilation flags
16 dnl * what are linking flags
17 AC_DEFUN([AC_HDF5], [
18
19
20 AC_ARG_WITH(hdf5_include,
21         AC_HELP_STRING([--with-hdf5-include=DIR],[Set the path to the HDF5 headers]),
22         [with_hdf5_include=$withval],
23         [with_hdf5_include='yes']
24         )
25
26 AC_ARG_WITH(hdf5_library,
27         AC_HELP_STRING([--with-hdf5-library=DIR],[Set the path to the HDF5 libraries]),
28         [with_hdf5_library=$withval],
29         [with_hdf5_library='yes']
30         )
31
32 if test "x$with_hdf5_include" != "xyes"; then
33     save_CFLAGS="$CFLAGS"
34     CFLAGS="-I$with_hdf5_include"
35     AC_CHECK_HEADER([hdf5.h],
36         [HDF5_CFLAGS="$CFLAGS"],
37         [AC_MSG_ERROR([Cannot find headers (hdf5.h) of the library HDF5 in $with_hdf5_include. Please install the dev package])]
38     )
39     CFLAGS="$save_CFLAGS"
40 else
41     HDF5_CFLAGS=""
42     if $WITH_DEVTOOLS; then # Scilab thirdparties
43         HDF5_CFLAGS="-I$DEVTOOLS_INCDIR"
44     else
45         if test -d /usr/include/hdf5/serial; then # New Debian packaging layout since hdf5-1.8.13
46             AC_CHECK_HEADER([hdf5/serial/hdf5.h],
47                 [HDF5_CFLAGS="-I/usr/include/hdf5/serial"],
48                 [AC_MSG_ERROR([Cannot find headers (hdf5.h) of the library HDF5. Please install the dev package])])
49         else
50             AC_CHECK_HEADER([hdf5.h],
51                 [HDF5_CFLAGS=""],
52                 [AC_MSG_ERROR([Cannot find headers (hdf5.h) of the library HDF5. Please install the dev package])])
53         fi
54     fi
55 fi
56
57 save_LIBS="$LIBS"
58
59 # --with-hdf5-library set then check in this dir
60 if test "x$with_hdf5_library" != "xyes"; then
61     HDF5_LIBS="-L$with_hdf5_library -lhdf5 -lhdf5_hl"
62     LIBS="$LIBS $HDF5_LIBS"
63     AC_CHECK_LIB([hdf5], [H5Fopen],
64             [],
65             [AC_MSG_ERROR([libhdf5 or libhdf5_hl: library missing. (Cannot find symbol H5Fopen) in $with_hdf5_library. Check if libhdf5 is installed and if the version is correct])],
66             [-lsz -lz]
67             )
68 else
69     if $WITH_DEVTOOLS; then # Scilab thirparties
70         HDF5_LIBS="-L$DEVTOOLS_LIBDIR -lhdf5 -lhdf5_hl"
71     else
72         if test -d /usr/include/hdf5/serial; then # New Debian packaging layout since hdf5-1.8.13
73             HDF5_LIBS="-lhdf5_serial -lhdf5_serial_hl"
74             LIBS="$LIBS $HDF5_LIBS"
75             AC_CHECK_LIB([hdf5_serial], [H5Fopen],
76                 [],
77                 [AC_MSG_ERROR([libhdf5_serial or libhdf5_serial_hl: library missing. (Cannot find symbol H5Fopen). Check if libhdf5 is installed and if the version is correct])],
78                 [-lz]
79                 )
80         else
81             HDF5_LIBS="-lhdf5 -lhdf5_hl"
82             LIBS="$LIBS $HDF5_LIBS"
83             AC_CHECK_LIB([hdf5], [H5Fopen],
84                 [],
85                 [AC_MSG_ERROR([libhdf5 or libhdf5_hl: library missing. (Cannot find symbol H5Fopen). Check if libhdf5 is installed and if the version is correct])],
86                 [-lsz -lz]
87                 )
88         fi
89     fi
90 fi
91
92 LIBS="$save_LIBS"
93
94 AC_SUBST(HDF5_LIBS)
95 AC_SUBST(HDF5_CFLAGS)
96
97 AC_DEFINE([WITH_HDF5], [], [With the HDF5 library])
98
99 # Gets compilation and library flags
100 ])