Salome HOME
0020511: EDF 1101 SMESH : Add CGNS to Mesh Format Supported
[modules/smesh.git] / adm_local / unix / config_files / check_cgns.m4
1 dnl Copyright (C) 2007-2011  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_CGNS],[
24 AC_REQUIRE([AC_PROG_CC])dnl
25 AC_REQUIRE([AC_PROG_CPP])dnl
26 AC_REQUIRE([CHECK_HDF5])dnl
27
28 AC_CHECKING(for CGNS)
29
30 AC_ARG_WITH(cgns,
31     [  --with-cgns=DIR                 root directory path to CGNS installation ],
32     [CGNSHOME="$withval"
33       AC_MSG_RESULT("select $withval as path to CGNS")
34     ])
35
36 AC_SUBST(CGNS_INCLUDES)
37 AC_SUBST(CGNS_LIBS)
38
39 CGNS_INCLUDES=""
40 CGNS_LIBS=""
41
42 cgns_ok=no
43
44 LOCAL_INCLUDES=""
45 LOCAL_LIBS="-lcgns $HDF5_LIBS"
46
47 if test -z $CGNSHOME
48 then
49    AC_MSG_WARN(undefined CGNSHOME variable which specify CGNS library installation directory)
50    AC_PATH_PROG(BINDIR, cgnsversion)
51    if test "x$BINDIR" != "x" ; then
52       CGNSHOME=$BINDIR
53       CGNSHOME=`echo ${CGNSHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
54       CGNSHOME=`echo ${CGNSHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
55    fi
56 fi
57 if test ! -z $CGNSHOME
58 then
59    LOCAL_INCLUDES="-I$CGNSHOME/include"
60    if test "x$CGNSHOME" != "x/usr"; then
61      LOCAL_LIBS="-L$CGNSHOME/lib $LOCAL_LIBS"
62    fi
63 fi
64
65 dnl check cgnslib header
66
67 CPPFLAGS_old=$CPPFLAGS
68 CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
69
70 AC_CHECK_HEADER(cgnslib.h,cgns_ok=yes ,cgns_ok=no)
71
72 CPPFLAGS=$CPPFLAGS_old
73
74 if  test "x$cgns_ok" = "xyes"
75 then
76
77 dnl check cgns library
78
79   LIBS_old="$LIBS"
80   LIBS="$LIBS $LOCAL_LIBS"
81   AC_CHECK_LIB(cgns,cg_open,cgns_ok=yes,cgns_ok=no)
82
83   LIBS="$LIBS_old"
84  
85 fi
86
87 if  test "x$cgns_ok" = "xyes"
88 then
89   CGNS_LIBS="$LOCAL_LIBS"
90   CGNS_INCLUDES="$LOCAL_INCLUDES"
91   #CPPFLAGS="-DWITH_CGNS $CPPFLAGS"
92 fi
93
94 AC_MSG_RESULT(for CGNS: $cgns_ok)
95
96 #AM_CONDITIONAL(WITH_CGNS, [test x"$cgns_ok" = xyes])
97
98 ])dnl