summaryrefslogtreecommitdiff
path: root/config/gr_qwtplot3d.m4
blob: 758dfbc3e6274540cd2d25a454b4a725ddeb3709 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
dnl
dnl Copyright 2008 Free Software Foundation, Inc.
dnl 
dnl This file is part of GNU Radio
dnl 
dnl GNU Radio is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3, or (at your option)
dnl any later version.
dnl 
dnl GNU Radio is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl 
dnl You should have received a copy of the GNU General Public License
dnl along with GNU Radio; see the file COPYING.  If not, write to
dnl the Free Software Foundation, Inc., 51 Franklin Street,
dnl Boston, MA 02110-1301, USA.
dnl

dnl Configure paths for library qwtplot3d.
dnl
dnl GR_QWTPLOT3D([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl
dnl Test for library qwtplot3d, set QWTPLOT3D_CFLAGS and QWTPLOT3D_LIBS if found. Assumes 
dnl QT_CFLAGS and QT_LIBS have already been correctly set.
dnl

AC_DEFUN([GR_QWTPLOT3D],
[
    dnl QWTPLOT3D Library Version

    dnl Save the environment
    AC_LANG_PUSH(C++)
    qwtplot3d_save_CPPFLAGS="$CPPFLAGS"
    qwtplot3d_save_LIBS="$LIBS"
    libqwtplot3d_ok=yes

    dnl Allow user to specify where QWTPLOT3D files are
    AC_ARG_WITH([qwtplot3d-libdir],
		[  --with-qwtplot3d-libdir=path  Prefix where QWTPLOT3D library is installed (optional)],
		[qwtplot3d_libdir="$withval"], [qwtplot3d_libdir=""])

    AC_ARG_WITH([qwtplot3d-incdir],
		[  --with-qwtplot3d-incdir=path  Prefix where QWTPLOT3D include files are (optional)],
		[qwtplot3d_incdir="$withval"], [qwtplot3d_incdir=""])

    AC_ARG_WITH([qwtplot3d-lib],
		[  --with-qwtplot3d-lib=library  QWT Plot3D library name (optional)],
		[qwtplot3d_lib="$withval"], [qwtplot3d_lib=""])


    dnl Check for presence of header files
    dnl if not user-specified, try the first include dir (Ubuntu), then
    dnl try the second include dir (Fedora)
    CPPFLAGS="$CPPFLAGS $QTCORE_CFLAGS $QTGUI_CFLAGS $QWT_CFLAGS"

    dnl if not set by user
    if test "$qwtplot3d_incdir" = "" ; then
        dnl check qwtplot3d/qwtplot3d.h (as in Fedora)
        AC_CHECK_HEADER(
            [qwtplot3d/qwt3d_plot.h],
	    [qwtplot3d_qwtplot3d_h=yes],
            [qwtplot3d_qwtplot3d_h=no]
        )
        dnl If it was found, set the flags and move on
        if test "$qwtplot3d_qwtplot3d_h" = "yes" ; then
            QWTPLOT3D_CFLAGS="$QWTPLOT3D_CFLAGS -I/usr/include/qwtplot3d"
        else
            dnl otherwise, check qwtplot3d-qt4/qwtplot3d.h (as in Ubuntu)
            AC_CHECK_HEADER(
                [qwtplot3d-qt4/qwt3d_plot.h],
                [qwtplot3d_qt4_qwtplot3d_h=yes],
                [qwtplot3d_qt4_qwtplot3d_h=no]
            )
            dnl if it was found, set the flags and move on
            if test "$qwtplot3d_qt4_qwtplot3d_h" = "yes" ; then
                QWTPLOT3D_CFLAGS="$QWTPLOT3D_CFLAGS -I/usr/include/qwtplot3d-qt4"
            else
                dnl otherwise, qwtplot3d.h wasn't found, so set the flag to no
                libqwtplot3d_ok=no
            fi
        fi
    else
	dnl Using the user-specified include directory
	QWTPLOT3D_CFLAGS="$QWTPLOT3D_CFLAGS -I$qwtplot3d_incdir"
        AC_CHECK_HEADER(
            [$qwtplot3d_incdir/qwt3d_plot.h],
	    [],
	    [libqwtplot3d_ok=no])
    fi

    dnl Don't bother going on if we can't find the headers
    if test "$libqwtplot3d_ok" = "yes" ; then

        dnl Check for QWTPLOT3D library (qwtplot3d or qwtplot3d-qt4)

        dnl User-defined QWTPLOT3D library path
        if test "$qwtplot3d_libdir" != "" ; then
            QWTPLOT3D_LIBS="-L$qwtplot3d_libdir $QWTPLOT3D_LIBS"
        fi

        dnl temporarily set these so the AC_CHECK_LIB works
        CPPFLAGS="$CPPFLAGS $QWTPLOT3D_CFLAGS"
        LIBS="$qwtplot3d_save_LIBS $QT_LIBS $QWTPLOT3D_LIBS -lqwtplot3d-qt4"

        dnl If the user specified a qwtplot3d library name, use it here
        if test "$qwtplot3d_lib" != "" ; then
            AC_CHECK_LIB([$qwtplot3d_lib], [main], [libqwtplot3d_ok=yes], [libqwtplot3d_ok=no])

        else            
            dnl Check for 'main' in libqwtplot3d-qt4
            AC_CHECK_LIB([qwtplot3d-qt4], [main], [libqwtplot3d_ok=yes], [libqwtplot3d_ok=no])

            dnl If library found properly, set the flag and move on
            if test "$libqwtplot3d_ok" = "yes" ; then
                QWTPLOT3D_LIBS="$QWTPLOT3D_LIBS -lqwtplot3d-qt4"
            else
                dnl Otherwise, check for 'main' in libqwtplot3d
                LIBS="$qwtplot3d_save_LIBS $QT_LIBS $QWTPLOT3D_LIBS -lqwtplot3d"
                AC_CHECK_LIB([qwtplot3d], [main], [libqwtplot3d_ok=yes], [libqwtplot3d_ok=no])
                if test "$libqwtplot3d_ok" = "yes" ; then
                    QWTPLOT3D_LIBS="$QWTPLOT3D_LIBS -lqwtplot3d"
                else
                    AC_MSG_RESULT([Could not link to libqwtplot3d.so])
                fi
            fi
        fi
    else
        AC_MSG_RESULT([Could not find qwtplot3d headers])
    fi

    dnl Restore saved variables
    LIBS="$qwtplot3d_save_LIBS"
    CPPFLAGS="$qwtplot3d_save_CPPFLAGS"
    AC_LANG_POP

    dnl Execute user actions
    if test "x$libqwtplot3d_ok" = "xyes" ; then
	ifelse([$1], , :, [$1])
    else
	QWTPLOT3D_CFLAGS=""
	QWTPLOT3D_LIBDIRS=""
	ifelse([$2], , :, [$2])
    fi

    dnl Export our variables
    AC_SUBST(QWTPLOT3D_CFLAGS)
    AC_SUBST(QWTPLOT3D_LIBS)
])