Statistics
| Branch: | Tag: | Revision:

root / config / gr_qwt.m4 @ bc98dc91

History | View | Annotate | Download (4.8 kB)

1
dnl
2
dnl Copyright 2007,2008 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 QWT Library Version
33
    QWT_LIBRARY1=-lqwt-qt4
34
    QWT_LIBRARY2=-lqwt
35
36
    dnl Save the environment
37
    AC_LANG_PUSH(C++)
38
    qwt_save_CPPFLAGS="$CPPFLAGS"
39
    qwt_save_LIBS="$LIBS"
40
    libqwt_ok=yes
41
42
    dnl QWT Info
43
    dnl Allow user to specify where QWT files are
44
    AC_ARG_WITH([qwt-libdir],
45
		[  --with-qwt-libdir=path  Prefix where QWT library is installed (optional)],
46
		[qwt_libdir="$withval"], [qwt_libdir=""])
47
48
    AC_ARG_WITH([qwt-incdir],
49
		[  --with-qwt-incdir=path  Prefix where QWT include files are (optional)],
50
		[qwt_incdir="$withval"], [qwt_incdir=""])
51
    AC_ARG_WITH([qwt-lib],
52
		[  --with-qwt-lib=library  QWT library name (optional)],
53
		[qwt_lib="$withval"], [qwt_lib=""])
54
55
    dnl Check for presence of header files
56
    dnl if not user-specified, try the first include dir (Ubuntu), then
57
    dnl try the second include dir (Fedora)
58
    CPPFLAGS="$CPPFLAGS $QTCORE_CFLAGS"
59
60
    dnl if not set by user
61
    if test "$qwt_incdir" = "" ; then
62
        dnl check qwt-qt4/qwt.h (as in Ubuntu)
63
        AC_CHECK_HEADER(
64
            [qwt-qt4/qwt_math.h],
65
            [qwt_qt4_qwt_h=yes],
66
            [qwt_qt4_qwt_h=no]
67
        )
68
        dnl If it was found, set the flags and move on
69
        if test "$qwt_qt4_qwt_h" = "yes" ; then
70
            QWT_CFLAGS="$QWT_CFLAGS -I/usr/include/qwt-qt4"
71
        else
72
            dnl check qwt/qwt.h (as in Fedora)
73
            AC_CHECK_HEADER(
74
                [qwt/qwt_math.h],
75
	        [qwt_qwt_h=yes],
76
                [qwt_qwt_h=no]
77
            )
78
            dnl if it was found, set the flags and move on
79
            if test "$qwt_qwt_h" = "yes" ; then
80
                QWT_CFLAGS="$QWT_CFLAGS -I/usr/include/qwt"
81
            else
82
                dnl otherwise, qwt.h wasn't found, so set the flag to no
83
                libqwt_ok=no
84
            fi
85
        fi
86
    else
87
	dnl Using the user-specified include directory
88
	QWT_CFLAGS="$QWT_CFLAGS -I$qwt_incdir"
89
        AC_CHECK_HEADER(
90
            [$qwt_incdir/qwt.h],
91
	    [],
92
	    [libqwt_ok=no])
93
    fi
94
95
    dnl Don't bother going on if we can't find the headers
96
    if test "$libqwt_ok" = "yes" ; then
97
98
        dnl Check for QWT library (qwt or qwt-qt4)
99
100
        dnl User-defined QWT library path
101
        if test "$qwt_libdir" != "" ; then
102
            QWT_LIBS="-L$qwt_libdir $QWT_LIBS"
103
        fi
104
105
        dnl temporarily set these so the AC_CHECK_LIB works
106
        CPPFLAGS="$CPPFLAGS $QWT_CFLAGS"
107
        LIBS="$qwt_save_LIBS $QT_LIBS $QWT_LIBS -lqwt"
108
109
        dnl If the user specified a qwt library name, use it here
110
        if test "$qwt_lib" != "" ; then
111
            AC_CHECK_LIB([$qwt_lib], [main], [libqwt_ok=yes], [libqwt_ok=no])
112
113
        else            
114
            dnl Check for 'main' in libqwt (Fedora)
115
            AC_CHECK_LIB([qwt], [main], [libqwt_ok=yes], [libqwt_ok=no])
116
117
            dnl If library found properly, set the flag and move on
118
            if test "$libqwt_ok" = "yes" ; then
119
                QWT_LIBS="$QWT_LIBS -lqwt"
120
            else
121
                dnl Otherwise, check for 'main' in libqwt-qt4 (Ubuntu)
122
                LIBS="$qwt_save_LIBS $QT_LIBS $QWT_LIBS -lqwt-qt4"
123
                AC_CHECK_LIB([qwt-qt4], [main], [libqwt_ok=yes], [libqwt_ok=no])
124
                if test "$libqwt_ok" = "yes" ; then
125
                    QWT_LIBS="$QWT_LIBS -lqwt-qt4"
126
                else
127
                    AC_MSG_RESULT([Could not link to libqwt.so])
128
                fi
129
            fi
130
        fi
131
    else
132
        AC_MSG_RESULT([Could not find qwt headers])
133
    fi
134
135
    dnl Restore saved variables
136
    LIBS="$qwt_save_LIBS"
137
    CPPFLAGS="$qwt_save_CPPFLAGS"
138
    AC_LANG_POP
139
140
    dnl Execute user actions
141
    if test "x$libqwt_ok" = "xyes" ; then
142
	ifelse([$1], , :, [$1])
143
    else
144
	QWT_CFLAGS=""
145
	QWT_LIBDIRS=""
146
	ifelse([$2], , :, [$2])
147
    fi
148
149
    dnl Export our variables
150
    AC_SUBST(QWT_CFLAGS)
151
    AC_SUBST(QWT_LIBS)
152
])