Imported Upstream version 3.2.2
[debian/gnuradio] / config / gr_qwtplot3d.m4
1 dnl
2 dnl Copyright 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 qwtplot3d.
23 dnl
24 dnl GR_QWTPLOT3D([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
25 dnl
26 dnl Test for library qwtplot3d, set QWTPLOT3D_CFLAGS and QWTPLOT3D_LIBS if found. Assumes 
27 dnl QT_CFLAGS and QT_LIBS have already been correctly set.
28 dnl
29
30 AC_DEFUN([GR_QWTPLOT3D],
31 [
32     dnl QWTPLOT3D Library Version
33
34     dnl Save the environment
35     AC_LANG_PUSH(C++)
36     qwtplot3d_save_CPPFLAGS="$CPPFLAGS"
37     qwtplot3d_save_LIBS="$LIBS"
38     libqwtplot3d_ok=yes
39
40     dnl Allow user to specify where QWTPLOT3D files are
41     AC_ARG_WITH([qwtplot3d-libdir],
42                 [  --with-qwtplot3d-libdir=path  Prefix where QWTPLOT3D library is installed (optional)],
43                 [qwtplot3d_libdir="$withval"], [qwtplot3d_libdir=""])
44
45     AC_ARG_WITH([qwtplot3d-incdir],
46                 [  --with-qwtplot3d-incdir=path  Prefix where QWTPLOT3D include files are (optional)],
47                 [qwtplot3d_incdir="$withval"], [qwtplot3d_incdir=""])
48
49     AC_ARG_WITH([qwtplot3d-lib],
50                 [  --with-qwtplot3d-lib=library  QWT Plot3D library name (optional)],
51                 [qwtplot3d_lib="$withval"], [qwtplot3d_lib=""])
52
53
54     dnl Check for presence of header files
55     dnl if not user-specified, try the first include dir (Ubuntu), then
56     dnl try the second include dir (Fedora)
57     CPPFLAGS="$CPPFLAGS $QTCORE_CFLAGS $QTGUI_CFLAGS $QWT_CFLAGS"
58
59     dnl if not set by user
60     if test "$qwtplot3d_incdir" = "" ; then
61         dnl check qwtplot3d/qwtplot3d.h (as in Fedora)
62         AC_CHECK_HEADER(
63             [qwtplot3d/qwt3d_plot.h],
64             [qwtplot3d_qwtplot3d_h=yes],
65             [qwtplot3d_qwtplot3d_h=no]
66         )
67         dnl If it was found, set the flags and move on
68         if test "$qwtplot3d_qwtplot3d_h" = "yes" ; then
69             QWTPLOT3D_CFLAGS="$QWTPLOT3D_CFLAGS -I/usr/include/qwtplot3d"
70         else
71             dnl otherwise, check qwtplot3d-qt4/qwtplot3d.h (as in Ubuntu)
72             AC_CHECK_HEADER(
73                 [qwtplot3d-qt4/qwt3d_plot.h],
74                 [qwtplot3d_qt4_qwtplot3d_h=yes],
75                 [qwtplot3d_qt4_qwtplot3d_h=no]
76             )
77             dnl if it was found, set the flags and move on
78             if test "$qwtplot3d_qt4_qwtplot3d_h" = "yes" ; then
79                 QWTPLOT3D_CFLAGS="$QWTPLOT3D_CFLAGS -I/usr/include/qwtplot3d-qt4"
80             else
81                 dnl otherwise, qwtplot3d.h wasn't found, so set the flag to no
82                 libqwtplot3d_ok=no
83             fi
84         fi
85     else
86         dnl Using the user-specified include directory
87         QWTPLOT3D_CFLAGS="$QWTPLOT3D_CFLAGS -I$qwtplot3d_incdir"
88         AC_CHECK_HEADER(
89             [$qwtplot3d_incdir/qwt3d_plot.h],
90             [],
91             [libqwtplot3d_ok=no])
92     fi
93
94     dnl Don't bother going on if we can't find the headers
95     if test "$libqwtplot3d_ok" = "yes" ; then
96
97         dnl Check for QWTPLOT3D library (qwtplot3d or qwtplot3d-qt4)
98
99         dnl User-defined QWTPLOT3D library path
100         if test "$qwtplot3d_libdir" != "" ; then
101             QWTPLOT3D_LIBS="-L$qwtplot3d_libdir $QWTPLOT3D_LIBS"
102         fi
103
104         dnl temporarily set these so the AC_CHECK_LIB works
105         CPPFLAGS="$CPPFLAGS $QWTPLOT3D_CFLAGS"
106         LIBS="$qwtplot3d_save_LIBS $QT_LIBS $QWTPLOT3D_LIBS -lqwtplot3d-qt4"
107
108         dnl If the user specified a qwtplot3d library name, use it here
109         if test "$qwtplot3d_lib" != "" ; then
110             AC_CHECK_LIB([$qwtplot3d_lib], [main], [libqwtplot3d_ok=yes], [libqwtplot3d_ok=no])
111
112         else            
113             dnl Check for 'main' in libqwtplot3d-qt4
114             AC_CHECK_LIB([qwtplot3d-qt4], [main], [libqwtplot3d_ok=yes], [libqwtplot3d_ok=no])
115
116             dnl If library found properly, set the flag and move on
117             if test "$libqwtplot3d_ok" = "yes" ; then
118                 QWTPLOT3D_LIBS="$QWTPLOT3D_LIBS -lqwtplot3d-qt4"
119             else
120                 dnl Otherwise, check for 'main' in libqwtplot3d
121                 LIBS="$qwtplot3d_save_LIBS $QT_LIBS $QWTPLOT3D_LIBS -lqwtplot3d"
122                 AC_CHECK_LIB([qwtplot3d], [main], [libqwtplot3d_ok=yes], [libqwtplot3d_ok=no])
123                 if test "$libqwtplot3d_ok" = "yes" ; then
124                     QWTPLOT3D_LIBS="$QWTPLOT3D_LIBS -lqwtplot3d"
125                 else
126                     AC_MSG_RESULT([Could not link to libqwtplot3d.so])
127                 fi
128             fi
129         fi
130     else
131         AC_MSG_RESULT([Could not find qwtplot3d headers])
132     fi
133
134     dnl Restore saved variables
135     LIBS="$qwtplot3d_save_LIBS"
136     CPPFLAGS="$qwtplot3d_save_CPPFLAGS"
137     AC_LANG_POP
138
139     dnl Execute user actions
140     if test "x$libqwtplot3d_ok" = "xyes" ; then
141         ifelse([$1], , :, [$1])
142     else
143         QWTPLOT3D_CFLAGS=""
144         QWTPLOT3D_LIBDIRS=""
145         ifelse([$2], , :, [$2])
146     fi
147
148     dnl Export our variables
149     AC_SUBST(QWTPLOT3D_CFLAGS)
150     AC_SUBST(QWTPLOT3D_LIBS)
151 ])