Salome HOME
Update version to 3.2.0a1
[modules/kernel.git] / salome_adm / unix / config_files / check_vtk.m4
1 dnl  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 dnl 
4 dnl  This library is free software; you can redistribute it and/or 
5 dnl  modify it under the terms of the GNU Lesser General Public 
6 dnl  License as published by the Free Software Foundation; either 
7 dnl  version 2.1 of the License. 
8 dnl 
9 dnl  This library is distributed in the hope that it will be useful, 
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 dnl  Lesser General Public License for more details. 
13 dnl 
14 dnl  You should have received a copy of the GNU Lesser General Public 
15 dnl  License along with this library; if not, write to the Free Software 
16 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 dnl 
18 dnl  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 dnl
20 dnl
21 dnl
22
23 AC_DEFUN([CHECK_VTK],[
24 AC_REQUIRE([AC_PROG_CC])dnl
25 AC_REQUIRE([AC_PROG_CXX])dnl
26 AC_REQUIRE([AC_PROG_CPP])dnl
27 AC_REQUIRE([AC_PROG_CXXCPP])dnl
28
29 AC_CHECKING(for VTK)
30
31 AC_LANG_SAVE
32 AC_LANG_CPLUSPLUS
33
34 AC_SUBST(VTK_INCLUDES)
35 AC_SUBST(VTK_LIBS)
36 AC_SUBST(VTKPY_MODULES)
37
38 VTK_INCLUDES=""
39 VTK_LIBS=""
40 VTKPY_MODULES=""
41
42 vtk_ok=no
43
44 AC_PATH_X
45
46 if test "x$OpenGL_ok" != "xyes"
47 then
48    AC_MSG_WARN(vtk needs OpenGL correct configuration, check configure output)
49 fi
50
51 if test "x$x_libraries" != "x"
52 then
53    LXLIB="-L$x_libraries"
54 else
55    LXLIB=""
56 fi
57
58 if test "x$x_libraries" = "x/usr/lib"
59 then
60    LXLIB=""
61 fi
62
63 if test "x$x_libraries" = "x/usr/lib"
64 then
65    LXLIB=""
66 fi
67
68 if test "x$x_libraries" = "x/usr/lib"
69 then
70    LXLIB=""
71 fi
72
73 LOCAL_INCLUDES="$OGL_INCLUDES"
74 LOCAL_LIBS="-lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid $OGL_LIBS $LXLIB -lX11 -lXt"
75 TRY_LINK_LIBS="-lvtkCommon $OGL_LIBS $LXLIB -lX11 -lXt"
76
77 if test -z $VTKHOME
78 then 
79    AC_MSG_WARN(undefined VTKHOME variable which specify where vtk was compiled)
80    if test -f /usr/include/vtk/vtkPlane.h ; then
81       AC_MSG_RESULT(trying /usr)
82       VTKHOME="/usr"
83    fi
84 fi
85
86 if test ! -z $VTKHOME
87 then
88    LOCAL_INCLUDES="-I$VTKHOME/include/vtk $LOCAL_INCLUDES"
89    LOCAL_LIBS="-L$VTKHOME/lib/vtk $LOCAL_LIBS"
90    TRY_LINK_LIBS="-L$VTKHOME/lib/vtk $TRY_LINK_LIBS"
91 fi
92
93 dnl vtk headers
94 CPPFLAGS_old="$CPPFLAGS"
95 CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
96
97 AC_CHECK_HEADER(vtkPlane.h,vtk_ok="yes",vtk_ok="no")
98
99  CPPFLAGS="$CPPFLAGS_old"
100
101  if  test "x$vtk_ok" = "xyes"
102  then
103    VTK_INCLUDES="$LOCAL_INCLUDES"
104
105  dnl vtk libraries
106
107    AC_MSG_CHECKING(linking VTK library)
108
109   LIBS_old="$LIBS"
110 #  LIBS="$LIBS $TRY_LINK_LIBS"
111   LIBS="$LIBS $LOCAL_LIBS"
112   CPPFLAGS_old="$CPPFLAGS"
113   CPPFLAGS="$CPPFLAGS $VTK_INCLUDES"
114
115  dnl  VTKPY_MODULES="$VTKHOME/python"
116
117    AC_CACHE_VAL(salome_cv_lib_vtk,[
118      AC_TRY_LINK(
119 #include "vtkPlane.h"
120 ,   vtkPlane *p = vtkPlane::New();,
121     eval "salome_cv_lib_vtk=yes",eval "salome_cv_lib_vtk=no")
122   ])
123   vtk_ok="$salome_cv_lib_vtk"
124   LIBS="$LIBS_old"
125   CPPFLAGS="$CPPFLAGS_old"
126
127 fi
128
129 if  test "x$vtk_ok" = "xno"
130 then
131   AC_MSG_RESULT("no")
132   AC_MSG_WARN(unable to link with vtk library)
133 else
134   AC_MSG_RESULT("yes")
135   VTK_LIBS="$LOCAL_LIBS"
136   VTK_MT_LIBS="$LOCAL_LIBS"
137 fi
138
139 AC_MSG_RESULT("for vtk: $vtk_ok")
140
141 AC_LANG_RESTORE
142
143 # Save cache
144 AC_CACHE_SAVE
145
146 ])dnl
147
148