Salome HOME
Fix for bug 0019977: Installation of Salome modules wihtout gui.
[modules/smesh.git] / adm_local / unix / config_files / check_qwt.m4
1 dnl  Copyright (C) 2007-2008  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 AC_DEFUN([CHECK_QWT],[
23 AC_REQUIRE([CHECK_QT])dnl
24 AC_REQUIRE([AC_LINKER_OPTIONS])dnl
25
26 AC_CHECKING(for qwt)
27
28 AC_LANG_SAVE
29 AC_LANG_CPLUSPLUS
30
31 qwt_ok=yes
32
33 dnl where is qwt ?
34
35 AC_ARG_WITH(qwt,
36     [  --with-qwt=DIR     directory path to QWT installation ],
37     [QWTHOME="$withval"
38       AC_MSG_RESULT("select $withval as path to QWT")
39     ])
40
41 AC_ARG_WITH(qwt_inc,
42     [  --with-qwt_inc=DIR   directory path to QWT includes ],
43     [QWT_INCDIR="$withval"
44       AC_MSG_RESULT("select $withval as path to QWT includes")
45     ])
46
47 if test -z $QWTHOME; then
48   AC_MSG_RESULT(QWTHOME not defined)
49   exist_ok=no   
50   if test "x$exist_ok" = "xno"; then
51      for d in /usr/local /usr ; do
52         AC_CHECK_FILE(${d}/lib${LIB_LOCATION_SUFFIX}/libqwt.so,exist_ok=yes,exist_ok=no)
53         if test "x$exist_ok" = "xyes"; then
54            QWTHOME=$d
55            AC_MSG_RESULT(libqwt.so detected in $d/lib)
56         fi
57      done
58   fi
59   if test "x$exist_ok" = "xno"; then
60      for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do
61         if test -f $d/libqwt.so ; then
62            AC_MSG_RESULT(libqwt.so detected in $d)
63            QWTHOME=$d
64            QWTHOME=`echo ${QWTHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
65            exist_ok=yes
66            break
67         fi
68      done
69   fi
70   if test "x$exist_ok" = "xyes"; then
71      if test -z $QWT_INCDIR; then
72         QWT_INCDIR=$QWTHOME"/include/qwt"
73         if test ! -f $QWT_INCDIR/qwt.h ; then
74           QWT_INCDIR=$QWTHOME"/include"
75         fi
76         if test ! -f $QWT_INCDIR/qwt.h ; then
77           QWT_INCDIR=/usr/lib/qt4/include/qwt
78         fi
79      fi
80   else
81      qwt_ok=no
82   fi
83 else
84   if test -z $QWT_INCDIR; then
85      QWT_INCDIR="$QWTHOME/include"
86   fi    
87 fi
88
89 if test "x$qwt_ok" = xno -o ! -d "$QWTHOME" ; then
90   AC_MSG_RESULT(no)
91   AC_MSG_WARN(qwt not found)
92   qwt_ok=no
93 else
94   CPPFLAGS_old=$CPPFLAGS
95   CPPFLAGS="$CPPFLAGS $QT_INCLUDES -I$QWT_INCDIR"
96
97   AC_CHECK_HEADER(qwt.h,qwt_ok=yes,qwt_ok=no) 
98   CPPFLAGS=$CPPFLAGS_old
99
100   AC_MSG_CHECKING(include of qwt headers)
101
102   if test "x$qwt_ok" = xno ; then
103     AC_MSG_RESULT(no)
104     AC_MSG_WARN(qwt not found)
105   else
106     AC_MSG_RESULT(yes)
107     QWT_INCLUDES=-I$QWT_INCDIR
108   fi
109
110   #
111   # test Qwt libraries
112   #
113   if test "x$qwt_ok" = "xyes" ; then
114     AC_MSG_CHECKING(linking qwt library)
115
116     LIBS_old=$LIBS
117     LIBS="$LIBS $QT_LIBS"
118     if test "x$QWTHOME" = "x/usr" ; then
119       LIBS="$LIBS -lqwt"
120     else
121       LIBS="$LIBS -L$QWTHOME/lib -lqwt"
122     fi
123
124     CXXFLAGS_old=$CXXFLAGS
125     CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QWT_INCLUDES"
126
127     AC_CACHE_VAL(salome_cv_lib_qwt,[
128       AC_TRY_LINK(
129 #include <QApplication>
130 #include <qwt_plot.h>
131 ,     int n;
132       char **s;
133       QApplication a(n, s);
134       QwtPlot p;
135       p.resize( 600, 400 );
136       p.show();
137       a.exec();,
138       eval "salome_cv_lib_qwt=yes",eval "salome_cv_lib_qwt=no")
139     ])
140     qwt_ok="$salome_cv_lib_qwt"
141
142     if  test "x$qwt_ok" = "xno" ; then
143       AC_MSG_RESULT(unable to link with qwt library)
144       AC_MSG_RESULT(QWTHOME environment variable may be wrong)
145     else
146       AC_MSG_RESULT(yes)
147       if test "x$QWTHOME" = "x/usr" ; then
148         QWT_LIBS=" -lqwt"
149       else
150         QWT_LIBS="-L$QWTHOME/lib -lqwt"
151       fi
152     fi
153
154     LIBS=$LIBS_old
155     CXXFLAGS=$CXXFLAGS_old
156   fi
157 fi
158
159 AC_SUBST(QWT_INCLUDES)
160 AC_SUBST(QWT_LIBS)
161
162 AC_LANG_RESTORE
163
164 AC_MSG_RESULT(for qwt: $qwt_ok)
165
166 # Save cache
167 AC_CACHE_SAVE
168
169 ])dnl
170 dnl