Salome HOME
Merge from V6_main 28/02/2013
[plugins/netgenplugin.git] / adm_local / unix / config_files / check_NETGEN.m4
1 dnl Copyright (C) 2007-2012  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_NETGEN],[
24
25 AC_REQUIRE([AC_PROG_CXX])dnl
26 AC_REQUIRE([AC_PROG_CXXCPP])dnl
27 AC_REQUIRE([CHECK_CAS])dnl
28
29 AC_CHECKING([for Netgen])
30
31 AC_LANG_SAVE
32 AC_LANG_CPLUSPLUS
33
34 AC_ARG_WITH([netgen],
35             [AC_HELP_STRING([--with-netgen=DIR], [root directory path to NETGEN library installation])],
36             [NETGEN_HOME=$withval],[NETGEN_HOME=yes])
37
38 NETGEN_INCLUDES=""
39 NETGEN_LIBS=""
40 NETGEN_V5=no
41
42 AC_SUBST(NETGEN_INCLUDES)
43 AC_SUBST(NETGEN_LIBS)
44
45 Netgen_ok=no
46
47 if test "x$NETGEN_HOME" = "x" -o "x$NETGEN_HOME" = "xyes" -o "x$NETGEN_HOME" = "xauto" ; then
48   # auto-detection
49
50   if test "x$NETGENHOME" != "x" ; then
51     # - by environment variable NETGENHOME
52     NETGEN_HOME=$NETGENHOME
53   else
54     # - by searching NETGEN executables
55     AC_PATH_PROG([TEMP], [ng_stl])
56     if test "x$TEMP" != "x" ; then
57       NETGEN_BIN_DIR=`dirname $TEMP`
58       NETGEN_HOME=`dirname $NETGEN_BIN_DIR`
59     else
60       NETGEN_HOME=""
61     fi
62   fi 
63 fi
64
65 echo NETGEN_HOME=$NETGEN_HOME
66
67 if test "x$NETGEN_HOME" != "x"; then
68
69   echo ----------------------------------------------------------
70   echo You are about to choose to use somehow the
71   echo Netgen Library to generate Tetrahedric mesh.
72   echo
73   echo You are strongly advised to consult the file
74   echo NETGENPLUGIN_SRC/src/NETGEN/ReadMeForNgUsers, particularly
75   echo about assumptions made on the installation of the Netgen
76   echo application and libraries.
77   echo ----------------------------------------------------------
78
79   NETGEN_INCLUDES="-I${NETGEN_HOME}/include -I${NETGEN_HOME}/share/netgen/include"
80   NETGEN_LIBS="-L${NETGEN_HOME}/lib -lnglib"
81   
82   dnl check Netgen headers availability 
83
84   CPPFLAGS_old="$CPPFLAGS"
85   CXXFLAGS_old="$CXXFLAGS"
86   CPPFLAGS="$CAS_CPPFLAGS $NETGEN_INCLUDES $CPPFLAGS"
87   CXXFLAGS="$CAS_CXXFLAGS $NETGEN_INCLUDES $CXXFLAGS"
88
89   AC_MSG_CHECKING([for Netgen header file])
90
91   AC_CHECK_HEADER([nglib.h], [Netgen_ok=yes], [Netgen_ok=no])
92
93   dnl check Netgen libraries
94
95   LIBS_old="$LIBS"
96   LIBS="$NETGEN_LIBS $CAS_LDPATH -lTKernel -lTKMath -lTKG3d -lTKBRep -lTKShHealing -lTKSTEP -lTKXSBase -lTKIGES -lTKSTL -lTKTopAlgo -lTKGeomBase $LIBS"
97
98   if test "x$Netgen_ok" = "xyes"; then
99
100     AC_MSG_CHECKING([for Netgen libraries])
101
102     AC_CACHE_VAL([salome_cv_netgen_lib],
103                  [AC_TRY_LINK(
104                    [
105                      #include <iostream>
106                      #include <fstream>
107                      namespace nglib {
108                      #include "nglib.h"
109                      }
110                    ],
111                    [
112                      nglib::Ng_Init();
113                      nglib::Ng_Exit();
114                    ],
115                    [eval "salome_cv_netgen_lib=yes"],
116                    [eval "salome_cv_netgen_lib=no"])
117                  ])
118
119     Netgen_ok="$salome_cv_netgen_lib"
120
121   fi
122
123   dnl check if Netgen of v5 or v4
124
125   if test "$Netgen_ok" = "yes" ; then
126
127     AC_MSG_RESULT([yes])
128
129     AC_MSG_CHECKING([Netgen version])
130
131     AC_CACHE_VAL([salome_cv_netgen_v5_lib],
132                  [AC_TRY_LINK(
133                    [
134                      #include <iostream>
135                      #include <fstream>
136                      #define OCCGEOMETRY
137                      namespace nglib {
138                      #include "nglib.h"
139                      }
140                      #include <occgeom.hpp>
141                    ],
142                    [
143                      nglib::Ng_Init();
144                      netgen::Mesh* ngMesh;
145                      ngMesh->CalcLocalH(1.0);
146                      nglib::Ng_Exit();
147                    ],
148                    [eval "salome_cv_netgen_v5_lib=yes"],
149                    [eval "salome_cv_netgen_v5_lib=no"])
150                  ])
151
152     if test "x$salome_cv_netgen_v5_lib" = "xyes" ; then
153       NETGEN_V5=yes
154     fi
155   fi
156
157   dnl check OCCT support in Netgen
158
159   if test "$Netgen_ok" = "yes" ; then
160
161     AC_MSG_RESULT([yes])
162
163     AC_MSG_CHECKING([for OCCT support in Netgen library])
164
165     AC_CACHE_VAL([salome_cv_netgen_occ_lib],
166                  [AC_TRY_LINK(
167                    [
168                      #include <iostream>
169                      #include <fstream>
170                      #define OCCGEOMETRY
171                      namespace nglib {
172                      #include "nglib.h"
173                      }
174                    ],
175                    [
176                      nglib::Ng_Init();
177                      nglib::Ng_OCC_Geometry* ng_occ_geom = nglib::Ng_OCC_NewGeometry();
178                      nglib::Ng_Exit();
179                    ],
180                    [eval "salome_cv_netgen_occ_lib=yes"],
181                    [eval "salome_cv_netgen_occ_lib=no"])
182                  ])
183
184     Netgen_ok="$salome_cv_netgen_occ_lib"
185
186   fi
187
188   dnl check SALOME patch in Netgen
189
190   if test "$Netgen_ok" = "yes" ; then
191
192     AC_MSG_RESULT([yes])
193
194     AC_MSG_CHECKING([for SALOME patch in Netgen library])
195
196     AC_CACHE_VAL([salome_cv_netgen_salome_patch_lib],
197                  [AC_TRY_LINK(
198                    [
199                      #include <iostream>
200                      #include <fstream>
201                      #define OCCGEOMETRY
202                      namespace nglib {
203                      #include "nglib.h"
204                      }
205                      #include <occgeom.hpp>
206                    ],
207                    [
208                      nglib::Ng_Init();
209                      netgen::OCCGeometry occgeo;
210                      nglib::Ng_Exit();
211                    ],
212                    [eval "salome_cv_netgen_salome_patch_lib=yes"],
213                    [eval "salome_cv_netgen_salome_patch_lib=no"])
214                  ])
215
216     Netgen_ok="$salome_cv_netgen_salome_patch_lib"
217     
218   fi
219
220   LIBS="$LIBS_old"
221   CPPFLAGS="$CPPFLAGS_old"
222   CXXFLAGS="$CXXFLAGS_old"
223
224 fi
225
226 if test "x$Netgen_ok" = xyes ; then
227
228   AC_MSG_RESULT([yes])
229
230   if test "x$NETGEN_V5" = "xyes" ; then
231     AC_MSG_RESULT([Netgen is of version 5.0 or newer])
232     NETGEN_INCLUDES="$NETGEN_INCLUDES -DNETGEN_V5"
233   else
234     AC_MSG_RESULT([Netgen is of version 4.9.13 or older])
235   fi
236
237 else
238
239   AC_MSG_RESULT([no])
240   AC_MSG_ERROR([Netgen is not properly installed. Read NETGENPLUGIN_SRC/src/NETGEN/ReadMeForNgUsers for more details.])
241
242 fi
243
244 AC_LANG_RESTORE
245
246 ])dnl