]> SALOME platform Git repositories - modules/smesh.git/blob - adm_local/unix/config_files/check_qwt.m4
Salome HOME
Merge branch 'V9_2_2_BR'
[modules/smesh.git] / adm_local / unix / config_files / check_qwt.m4
1 dnl Copyright (C) 2007-2019  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, 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 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 libqwt_name=qwt
48 if test -z $QWTHOME; then
49   AC_MSG_RESULT(QWTHOME not defined)
50   AC_MSG_NOTICE(Trying native Qwt...)
51   exist_ok=no   
52   if test "x$exist_ok" = "xno"; then
53      for d in /usr /usr/local ; do
54         for extension in qwt-qt4 qwt; do
55            AC_CHECK_FILE(${d}/lib${LIB_LOCATION_SUFFIX}/lib${extension}.so,exist_ok=yes,exist_ok=no)
56            if test "x$exist_ok" = "xyes"; then
57               QWTHOME=$d
58               AC_MSG_RESULT(lib${extension}.so detected in $d/lib)
59               libqwt_name=${extension}
60               dnl  break, libqwt-qt4.so is chosen before libqwt.so since it is surely the Qt4 version.
61               break
62            fi
63         done
64         if test "x$exist_ok" = "xyes"; then
65            break
66         fi
67      done
68   fi
69   if test "x$exist_ok" = "xno"; then
70      for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do
71         if test -f $d/libqwt.so ; then
72            AC_MSG_RESULT(libqwt.so detected in $d)
73            QWTHOME=$d
74            QWTHOME=`echo ${QWTHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
75            exist_ok=yes
76            break
77         fi
78      done
79   fi
80   if test "x$exist_ok" = "xyes"; then
81      if test -z $QWT_INCDIR; then
82         QWT_INCDIR=$QWTHOME"/include/qwt-qt4"
83         if test ! -f $QWT_INCDIR/qwt.h ; then
84           QWT_INCDIR=/usr/include/qwt
85         fi
86         if test ! -f $QWT_INCDIR/qwt.h ; then
87           QWT_INCDIR=$QWTHOME"/include"
88         fi
89         if test ! -f $QWT_INCDIR/qwt.h ; then
90           QWT_INCDIR=/usr/lib/qt4/include/qwt
91         fi
92         if test ! -f $QWT_INCDIR/qwt.h ; then
93           QWT_INCDIR=/usr/include/qwt-qt4
94         fi
95      fi
96   else
97      qwt_ok=no
98   fi
99 else
100   AC_MSG_NOTICE(Trying Qwt from $QWTHOME ...)
101   if test -z $QWT_INCDIR; then
102      QWT_INCDIR="$QWTHOME/include"
103   fi    
104 fi
105
106 if test "x$qwt_ok" = xno -o ! -d "$QWTHOME" ; then
107   AC_MSG_RESULT(no)
108   AC_MSG_WARN(qwt not found)
109   qwt_ok=no
110 else
111   CPPFLAGS_old=$CPPFLAGS
112   CPPFLAGS="$CPPFLAGS $QT_INCLUDES -I$QWT_INCDIR"
113
114   AC_CHECK_HEADER(qwt.h,qwt_ok=yes,qwt_ok=no) 
115   CPPFLAGS=$CPPFLAGS_old
116
117   AC_MSG_CHECKING(include of qwt headers)
118
119   if test "x$qwt_ok" = xno ; then
120     AC_MSG_RESULT(no)
121     AC_MSG_WARN(qwt not found)
122   else
123     AC_MSG_RESULT(yes)
124     QWT_INCLUDES=-I$QWT_INCDIR
125   fi
126
127   #
128   # test Qwt libraries
129   #
130   if test "x$qwt_ok" = "xyes" ; then
131     AC_MSG_CHECKING(linking qwt library)
132
133     LIBS_old=$LIBS
134     LIBS="$LIBS $QT_LIBS"
135     if test "x$QWTHOME" = "x/usr" ; then
136       LIBS="$LIBS -l${libqwt_name}"
137     else
138       LIBS="$LIBS -L$QWTHOME/lib -l${libqwt_name}"
139     fi
140
141     CXXFLAGS_old=$CXXFLAGS
142     CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QWT_INCLUDES"
143
144     AC_CACHE_VAL(salome_cv_lib_qwt,[
145       AC_TRY_LINK(
146 #include <QApplication>
147 #include <qwt_plot.h>
148 ,     int n;
149       char **s;
150       QApplication a(n, s);
151       QwtPlot p;
152       p.resize( 600, 400 );
153       p.show();
154       a.exec();,
155       eval "salome_cv_lib_qwt=yes",eval "salome_cv_lib_qwt=no")
156     ])
157     qwt_ok="$salome_cv_lib_qwt"
158
159     if  test "x$qwt_ok" = "xno" ; then
160       AC_MSG_RESULT(unable to link with qwt library)
161       AC_MSG_RESULT(QWTHOME environment variable may be wrong)
162     else
163       AC_MSG_RESULT(yes)
164       if test "x$QWTHOME" = "x/usr" ; then
165         QWT_LIBS=" -l${libqwt_name}"
166       else
167         QWT_LIBS="-L$QWTHOME/lib -l${libqwt_name}"
168       fi
169     fi
170
171     LIBS=$LIBS_old
172     CXXFLAGS=$CXXFLAGS_old
173   fi
174 fi
175
176 AC_SUBST(QWT_INCLUDES)
177 AC_SUBST(QWT_LIBS)
178
179 AC_LANG_RESTORE
180
181 AC_MSG_RESULT(for qwt: $qwt_ok)
182
183 # Save cache
184 AC_CACHE_SAVE
185
186 ])dnl
187 dnl