Linux build : fix undefined pragma
[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 Copyright (C) 2012 - 2016 - Scilab Enterprises
6 dnl
7 dnl This file is hereby licensed under the terms of the GNU GPL v2.0,
8 dnl pursuant to article 5.3.4 of the CeCILL v.2.1.
9 dnl This file was originally licensed under the terms of the CeCILL v2.1,
10 dnl and continues to be available under such terms.
11 dnl For more information, see the COPYING file which you should have received
12 dnl along with this program.
13 dnl
14 dnl libhdf5 is mandatory in Scilab
15 dnl When we check :
16 dnl * if the path is provided or that we have to find it ourself
17 dnl * if it is available
18 dnl * what are the compilation flags
19 dnl * what are linking flags
20 AC_DEFUN([AC_HDF5], [
21
22
23 AC_ARG_WITH(hdf5_include,
24         AC_HELP_STRING([--with-hdf5-include=DIR],[Set the path to the HDF5 headers]),
25         [with_hdf5_include=$withval],
26         [with_hdf5_include='yes']
27         )
28
29 AC_ARG_WITH(hdf5_library,
30         AC_HELP_STRING([--with-hdf5-library=DIR],[Set the path to the HDF5 libraries]),
31         [with_hdf5_library=$withval],
32         [with_hdf5_library='yes']
33         )
34
35 if test "x$with_hdf5_include" != "xyes"; then
36     save_CFLAGS="$CFLAGS"
37     CFLAGS="-I$with_hdf5_include"
38     AC_CHECK_HEADER([hdf5.h],
39         [HDF5_CFLAGS="$CFLAGS"],
40         [AC_MSG_ERROR([Cannot find headers (hdf5.h) of the library HDF5 in $with_hdf5_include. Please install the dev package])]
41     )
42     CFLAGS="$save_CFLAGS"
43 else
44     HDF5_CFLAGS=""
45     if $WITH_DEVTOOLS; then # Scilab thirdparties
46         HDF5_CFLAGS="-I$DEVTOOLS_INCDIR"
47     else
48         if test -d /usr/include/hdf5/serial; then # New Debian packaging layout since hdf5-1.8.13
49             AC_CHECK_HEADER([hdf5/serial/hdf5.h],
50                 [HDF5_CFLAGS="-I/usr/include/hdf5/serial"],
51                 [AC_MSG_ERROR([Cannot find headers (hdf5.h) of the library HDF5. Please install the dev package])])
52         else
53             AC_CHECK_HEADER([hdf5.h],
54                 [HDF5_CFLAGS=""],
55                 [AC_MSG_ERROR([Cannot find headers (hdf5.h) of the library HDF5. Please install the dev package])])
56         fi
57     fi
58 fi
59
60 save_LIBS="$LIBS"
61
62 # --with-hdf5-library set then check in this dir
63 if test "x$with_hdf5_library" != "xyes"; then
64     HDF5_LIBS="-L$with_hdf5_library -lhdf5 -lhdf5_hl"
65     LIBS="$LIBS $HDF5_LIBS"
66     AC_CHECK_LIB([hdf5], [H5Fopen],
67             [],
68             [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])],
69             [-lz]
70             )
71 else
72     if $WITH_DEVTOOLS; then # Scilab thirparties
73         HDF5_LIBS="-L$DEVTOOLS_LIBDIR -lhdf5 -lhdf5_hl"
74     else
75         if test -d /usr/include/hdf5/serial; then # New Debian packaging layout since hdf5-1.8.13
76             HDF5_LIBS="-lhdf5_serial -lhdf5_serial_hl"
77             LIBS="$LIBS $HDF5_LIBS"
78             AC_CHECK_LIB([hdf5_serial], [H5Fopen],
79                 [],
80                 [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])],
81                 [-lz]
82                 )
83         else
84             HDF5_LIBS="-lhdf5 -lhdf5_hl"
85             LIBS="$LIBS $HDF5_LIBS"
86             AC_CHECK_LIB([hdf5], [H5Fopen],
87                 [],
88                 [AC_MSG_ERROR([libhdf5 or libhdf5_hl: library missing. (Cannot find symbol H5Fopen). Check if libhdf5 is installed and if the version is correct])],
89                 [-lz]
90                 )
91         fi
92     fi
93 fi
94
95 LIBS="$save_LIBS"
96
97 AC_SUBST(HDF5_LIBS)
98 AC_SUBST(HDF5_CFLAGS)
99
100 AC_DEFINE([WITH_HDF5], [], [With the HDF5 library])
101
102 # Gets compilation and library flags
103 ])