Salome HOME
f064cf390e34431773b6bce933a451b4ee18db8f
[plugins/netgenplugin.git] / adm_local / unix / config_files / check_NETGEN.m4
1 dnl Copyright (C) 2007-2023  CEA, EDF, 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_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_OLD="-L${NETGEN_HOME}/lib -lnglib"
81   NETGEN_LIBS_NEW="-L${NETGEN_HOME}/lib -lnglib -linterface -lgeom2d -lcsg -lstl -locc -lmesh"
82   
83   dnl check Netgen headers availability 
84
85   CPPFLAGS_old="$CPPFLAGS"
86   CXXFLAGS_old="$CXXFLAGS"
87   CPPFLAGS="$CAS_CPPFLAGS $NETGEN_INCLUDES $CPPFLAGS"
88   CXXFLAGS="$CAS_CXXFLAGS $NETGEN_INCLUDES $CXXFLAGS"
89
90   AC_MSG_CHECKING([for Netgen header file])
91
92   AC_CHECK_HEADER([nglib.h], [Netgen_ok=yes], [Netgen_ok=no])
93
94   dnl check Netgen libraries
95
96   NETGEN_LIBS=${NETGEN_LIBS_NEW}
97
98   LIBS_old="$LIBS"
99   LIBS="$NETGEN_LIBS $CAS_LDPATH -lTKernel -lTKMath -lTKG3d -lTKBRep -lTKShHealing -lTKSTEP -lTKXSBase -lTKIGES -lTKSTL -lTKTopAlgo -lTKGeomBase $LIBS_old"
100
101   if test "x$Netgen_ok" = "xyes"; then
102
103     AC_MSG_NOTICE([checking for Netgen libraries])
104
105     AC_MSG_CHECKING([libraries ... try new style ])
106
107     AC_TRY_LINK(
108       [
109         #include <iostream>
110         #include <fstream>
111         namespace nglib {
112         #include "nglib.h"
113         }
114       ],
115       [
116         nglib::Ng_Init();
117         nglib::Ng_Exit();
118       ],
119       [Netgen_ok=yes],
120       [Netgen_ok=no])
121
122     if test "x$Netgen_ok" = "xno" ; then
123
124         AC_MSG_RESULT([no])
125
126         AC_MSG_CHECKING([libraries ... try old style])
127
128         NETGEN_LIBS=${NETGEN_LIBS_OLD}
129         LIBS="$NETGEN_LIBS $CAS_LDPATH -lTKernel -lTKMath -lTKG3d -lTKBRep -lTKShHealing -lTKSTEP -lTKXSBase -lTKIGES -lTKSTL -lTKTopAlgo -lTKGeomBase $LIBS_old"
130
131         AC_TRY_LINK(
132           [
133             #include <iostream>
134             #include <fstream>
135             namespace nglib {
136             #include "nglib.h"
137             }
138           ],
139           [
140             nglib::Ng_Init();
141             nglib::Ng_Exit();
142           ],
143           [Netgen_ok=yes],
144           [Netgen_ok=no])
145
146     fi
147
148   fi
149
150   dnl check if Netgen of v5 or v4
151
152   if test "$Netgen_ok" = "yes" ; then
153
154     AC_MSG_RESULT([yes])
155
156     AC_MSG_CHECKING([Netgen version])
157
158     AC_TRY_LINK(
159       [
160         #include <iostream>
161         #include <fstream>
162         #define OCCGEOMETRY
163         namespace nglib {
164         #include "nglib.h"
165         }
166         #include <occgeom.hpp>
167       ],
168       [
169         nglib::Ng_Init();
170         netgen::Mesh* ngMesh;
171         ngMesh->CalcLocalH(1.0);
172         nglib::Ng_Exit();
173       ],
174       [NETGEN_V5=yes],
175       [NETGEN_V5=no])
176
177   fi
178
179   dnl check OCCT support in Netgen
180
181   if test "$Netgen_ok" = "yes" ; then
182
183     AC_MSG_RESULT([yes])
184
185     AC_MSG_CHECKING([for OCCT support in Netgen library])
186
187     AC_TRY_LINK(
188       [
189         #include <iostream>
190         #include <fstream>
191         #define OCCGEOMETRY
192         namespace nglib {
193         #include "nglib.h"
194         }
195       ],
196       [
197         nglib::Ng_Init();
198         nglib::Ng_OCC_Geometry* ng_occ_geom = nglib::Ng_OCC_NewGeometry();
199         nglib::Ng_Exit();
200       ],
201       [Netgen_ok=yes],
202       [Netgen_ok=no])
203
204   fi
205
206   dnl check SALOME patch in Netgen
207
208   if test "$Netgen_ok" = "yes" ; then
209
210     AC_MSG_RESULT([yes])
211
212     AC_MSG_CHECKING([for SALOME patch in Netgen library])
213
214     AC_TRY_LINK(
215       [
216         #include <iostream>
217         #include <fstream>
218         #define OCCGEOMETRY
219         namespace nglib {
220         #include "nglib.h"
221         }
222         #include <occgeom.hpp>
223       ],
224       [
225         nglib::Ng_Init();
226         netgen::OCCGeometry occgeo;
227         nglib::Ng_Exit();
228       ],
229       [Netgen_ok=yes],
230       [Netgen_ok=no])
231
232   fi
233
234   LIBS="$LIBS_old"
235   CPPFLAGS="$CPPFLAGS_old"
236   CXXFLAGS="$CXXFLAGS_old"
237
238 fi
239
240 if test "x$Netgen_ok" = xyes ; then
241
242   AC_MSG_RESULT([yes])
243
244   if test "x$NETGEN_V5" = "xyes" ; then
245     AC_MSG_RESULT([Netgen is of version 5.0 or newer])
246     NETGEN_INCLUDES="$NETGEN_INCLUDES -DNETGEN_V5"
247   else
248     AC_MSG_RESULT([Netgen is of version 4.9.13 or older])
249   fi
250
251 else
252
253   AC_MSG_RESULT([no])
254   AC_MSG_ERROR([Netgen is not properly installed. Read NETGENPLUGIN_SRC/src/NETGEN/ReadMeForNgUsers for more details.])
255
256 fi
257
258 AC_LANG_RESTORE
259
260 ])dnl