Updated license from GPL version 2 or later to GPL version 3 or later.
[debian/gnuradio] / config / gr_qwt.m4
1 dnl
2 dnl Copyright 2007 Free Software Foundation, Inc.
3 dnl 
4 dnl This file is part of GNU Radio
5 dnl 
6 dnl GNU Radio is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 3, or (at your option)
9 dnl any later version.
10 dnl 
11 dnl GNU Radio 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
14 dnl GNU General Public License for more details.
15 dnl 
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with GNU Radio; see the file COPYING.  If not, write to
18 dnl the Free Software Foundation, Inc., 51 Franklin Street,
19 dnl Boston, MA 02110-1301, USA.
20 dnl
21
22 dnl Configure paths for library qwt.
23 dnl
24 dnl GR_QWT([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
25 dnl
26 dnl Test for library qwt, set QWT_CFLAGS and QWT_LIBS if found. Assumes 
27 dnl QT_CFLAGS and QT_LIBS have already been correctly set.
28 dnl
29
30 AC_DEFUN([GR_QWT],
31 [
32     dnl Save the environment
33     AC_LANG_PUSH(C++)
34     qwt_save_CPPFLAGS="$CPPFLAGS"
35     qwt_save_LIBS="$LIBS"
36     libqwt_ok=yes
37
38     dnl Allow user to specify where QWT files are
39     AC_ARG_WITH([qwt-libdir],
40                 [  --with-qwt-libdir=path  Prefix where QWT library is installed (optional)],
41                 [qwt_libdir="$withval"], [qwt_libdir=""])
42
43     AC_ARG_WITH([qwt-incdir],
44                 [  --with-qwt-incdir=path  Prefix where QWT include files are (optional)],
45                 [qwt_incdir="$withval"], [qwt_incdir=""])
46
47     dnl Create QWT_CFLAGS based on user input
48     AC_MSG_CHECKING(QWT_CFLAGS)
49     if test "$qwt_incdir" != "" ; then
50         QWT_CFLAGS="$QWT_CFLAGS -I$qwt_incdir"
51     fi
52     AC_MSG_RESULT($QWT_CFLAGS)
53     
54     dnl Set CPPFLAGS so C++ tests can operate
55     CPPFLAGS="$CPPFLAGS $QT_CFLAGS $QWT_CFLAGS"
56
57     dnl Check for presence of header files
58     AC_CHECK_HEADERS([qwt.h], 
59                      [],
60                      [libqwt_ok=no;AC_MSG_RESULT([cannot find usable qwt headers])]
61     )
62
63     dnl Set QWT_LIBS based on user input
64     AC_MSG_CHECKING(QWT_LIBS)
65     QWT_LIBS="$QWT_LIBS -lqwt"
66     if test "$qwt_libdir" != "" ; then
67         QWT_LIBS="-L$qwt_libdir $QWT_LIBS"
68     fi
69     AC_MSG_RESULT($QWT_LIBS)
70
71     dnl Set LIBS so C++ link test can operate
72     LIBS="$QWT_LIBS $QT_LIBS $LIBS"
73
74     dnl Check that library files can be linked in
75     dnl This references an arbitrary static class method 
76     AC_TRY_LINK([#include <qwt_text.h>],
77                 [QwtTextEngine const *te = QwtText::textEngine(QwtText::AutoText)],
78                 [],
79                 [libqwt_ok=no;AC_MSG_RESULT([unable to link QWT library])]
80     )
81
82     dnl Restore saved variables
83     LIBS="$qwt_save_LIBS"
84     CPPFLAGS="$qwt_save_CPPFLAGS"
85     AC_LANG_POP
86
87     dnl Execute user actions
88     if test "x$libqwt_ok" = "xyes" ; then
89         ifelse([$1], , :, [$1])
90     else
91         QWT_CFLAGS=""
92         QWT_LIBDIRS=""
93         ifelse([$2], , :, [$2])
94     fi
95
96     dnl Export our variables
97     AC_SUBST(QWT_CFLAGS)
98     AC_SUBST(QWT_LIBS)
99 ])