Salome HOME
Copyright update: 2016
[modules/smesh.git] / adm_local / unix / config_files / check_cgns.m4
1 dnl Copyright (C) 2007-2016  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, or (at your option) any later version.
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 "x$CGNSHOME" != "xno"; then
48     if test "x$CGNSHOME" == "xyes"; then
49         CGNSHOME=""
50     fi
51     if test -z $CGNSHOME
52     then
53         AC_MSG_WARN(undefined CGNSHOME variable which specify CGNS library installation directory)
54         AC_PATH_PROG(BINDIR, cgnsversion)
55         if test "x$BINDIR" != "x" ; then
56             CGNSHOME=$BINDIR
57             CGNSHOME=`echo ${CGNSHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
58             CGNSHOME=`echo ${CGNSHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
59         fi
60     fi
61     if test ! -z $CGNSHOME
62     then
63         LOCAL_INCLUDES="-I$CGNSHOME/include"
64         if test "x$CGNSHOME" != "x/usr"; then
65             LOCAL_LIBS="-L$CGNSHOME/lib $LOCAL_LIBS"
66         fi
67     fi
68
69 dnl check cgnslib header
70
71     CPPFLAGS_old=$CPPFLAGS
72     CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
73
74     AC_CHECK_HEADER(cgnslib.h,cgns_ok=yes ,cgns_ok=no)
75
76     CPPFLAGS=$CPPFLAGS_old
77 fi
78
79 if  test "x$cgns_ok" = "xyes"
80 then
81
82 dnl check cgns library
83
84   LIBS_old="$LIBS"
85   LIBS="$LIBS $LOCAL_LIBS"
86   AC_CHECK_LIB(cgns,cg_open,cgns_ok=yes,cgns_ok=no)
87
88   LIBS="$LIBS_old"
89  
90 fi
91
92 if  test "x$cgns_ok" = "xyes"
93 then
94   CGNS_LIBS="$LOCAL_LIBS"
95   CGNS_INCLUDES="$LOCAL_INCLUDES"
96   CPPFLAGS="-DWITH_CGNS $CPPFLAGS"
97 fi
98
99 AC_MSG_RESULT(for CGNS: $cgns_ok)
100
101 AM_CONDITIONAL(WITH_CGNS, [test x"$cgns_ok" = xyes])
102
103 ])dnl