Salome HOME
37558e22719c72402c8fc1ff636daeacc4f983ee
[plugins/blsurfplugin.git] / adm_local / unix / config_files / check_BLSURF.m4
1 dnl Copyright (C) 2007-2011  CEA/DEN, EDF R&D
2 dnl
3 dnl This library is free software; you can redistribute it and/or
4 dnl modify it under the terms of the GNU Lesser General Public
5 dnl License as published by the Free Software Foundation; either
6 dnl version 2.1 of the License.
7 dnl
8 dnl This library is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 dnl Lesser General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU Lesser General Public
14 dnl License along with this library; if not, write to the Free Software
15 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 dnl
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19
20 dnl  File   : check_BLSURF.m4
21 dnl  Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
22 dnl
23 AC_DEFUN([CHECK_BLSURF],[
24
25 AC_REQUIRE([AC_PROG_CXX])dnl
26 AC_REQUIRE([AC_PROG_CXXCPP])dnl
27
28 AC_CHECKING([for BLSURF commercial product])
29
30 AC_LANG_SAVE
31 AC_LANG_C
32
33 BLSURF_INCLUDES=""
34 BLSURF_LIBS=""
35
36 AC_ARG_WITH([blsurf],
37             [  --with-blsurf=DIR       root directory path of BLSURF installation])
38
39 BLSURF_ok=no
40
41 if test "$with_blsurf" != "no" ; then
42   if test "$with_blsurf" == "yes" || test "$with_blsurf" == "auto"; then
43     BLSURF_HOME=""
44   else
45     BLSURF_HOME="$with_blsurf"
46   fi
47
48   if test "$BLSURF_HOME" == "" ; then
49     if test "x$BLSURFHOME" != "x" ; then
50       BLSURF_HOME=$BLSURFHOME
51     fi
52   fi
53
54   if test "x$BLSURF_HOME" != "x"; then
55
56     echo
57     echo -------------------------------------------------
58     echo You are about to choose to use somehow the
59     echo BLSURF commercial product to generate 2D mesh.
60     echo
61
62     LOCAL_INCLUDES="-I$BLSURF_HOME/include"
63     LOCAL_LIBS="-L$BLSURF_HOME/lib -lBLSurf"
64     if test $(`which arch`) = x86_64 ; then
65       if test -f $BLSURF_HOME/lib/Linux_64/libBLSurf.so ; then
66         LOCAL_LIBS="-L$BLSURF_HOME/lib/Linux_64 -lBLSurf -ldistene"
67       fi
68     fi
69
70     CPPFLAGS_old="$CPPFLAGS"
71     CXXFLAGS_old="$CXXFLAGS"
72     CPPFLAGS="$LOCAL_INCLUDES $CPPFLAGS"
73     CXXFLAGS="$LOCAL_INCLUDES $CXXFLAGS"
74
75     AC_MSG_CHECKING([for BLSURF header file])
76
77     AC_CHECK_HEADER([distene/api.h],[BLSURF_ok=yes],[BLSURF_ok=no])
78
79     if test "x$BLSURF_ok" == "xyes"; then
80
81       AC_MSG_CHECKING([for BLSURF library])
82
83       LDFLAGS_old="$LDFLAGS"
84       LDFLAGS="-L. $LOCAL_LIBS $LDFLAGS"
85
86       AC_TRY_LINK(
87         [#include "distene/api.h"],
88         [distene_context_new()],
89         [BLSURF_ok=yes],[BLSURF_ok=no]
90         )
91
92       LDFLAGS="$LDFLAGS_old"
93
94       AC_MSG_RESULT([$BLSURF_ok])
95     fi
96
97     CPPFLAGS="$CPPFLAGS_old"
98     CXXFLAGS="$CXXFLAGS_old"
99
100   fi
101 fi
102
103 if test "x$BLSURF_ok" == xno ; then
104   AC_MSG_RESULT([for BLSURF: no])
105   AC_MSG_WARN([BLSURF includes or libraries are not found or are not properly installed])
106   AC_MSG_WARN([Cannot build without BLSURF. Use --with-blsurf option to define BLSURF installation.])
107 else
108   BLSURF_INCLUDES=$LOCAL_INCLUDES
109   BLSURF_LIBS=$LOCAL_LIBS
110   AC_MSG_RESULT([for BLSURF: yes])
111 fi
112
113 AC_SUBST(BLSURF_INCLUDES)
114 AC_SUBST(BLSURF_LIBS)
115
116 AC_LANG_RESTORE
117
118 ])dnl