Imported Upstream version 3.0
[debian/gnuradio] / config / gr_boost.m4
1 dnl
2 dnl Copyright 2004,2005 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 2, 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 This tries to do the "right thing" to locate the boost include files.
23 dnl If the user explicitly specified --with-boost-include-dir=<foo>
24 dnl we believe them and use it.  Otherwise,
25 dnl
26 dnl We look for boost/shared_ptr.hpp in the "normal places".  That is,
27 dnl wherever AC_CHECK_HEADER looks.  If the boost includes are in /usr/local/include
28 dnl this step will find them.
29 dnl
30 dnl Otherwise, we check to see if the boost stuff was installed in a version-specific
31 dnl directory under /usr/local/include.  These look like: /usr/local/include/boost-1_33_1
32 dnl If there's more than one version installed, we select the
33 dnl lexicographically greatest one.
34 dnl
35 dnl If none of these work, we bail.
36
37 AC_DEFUN([GR_REQUIRE_BOOST_INCLUDES],
38 [
39   AC_LANG_PUSH(C++)
40   gr_boost_include_dir=
41   AC_ARG_WITH([boost-include-dir],
42     AC_HELP_STRING([--with-boost-include-dir=<path>],
43                    [path to boost c++ include files]),
44     [
45       # "yes" and "no" are bogus answers
46       if test x"$with_boost_include_dir" == xyes ||
47          test x"$with_boost_include_dir" == xno; then
48         gr_boost_include_dir=
49       else
50         gr_boost_include_dir=$with_boost_include_dir
51       fi
52     ])
53   echo "gr_boost_include_dir = $gr_boost_include_dir"
54   if test x$gr_boost_include_dir != x; then
55     #
56     # If the user specified a directory, then we use it
57     #
58     OLD_CPPFLAGS=$CPPFLAGS
59     CPPFLAGS="$CPPFLAGS -I$gr_boost_include_dir"
60     AC_CHECK_HEADER([boost/shared_ptr.hpp],
61       [BOOST_CFLAGS="-I$gr_boost_include_dir"],
62       [AC_MSG_ERROR(
63         [Failed to locate boost/shared_ptr.hpp.
64 Try using --with-boost-include-dir=<path>, 
65 E.g., --with-boost-include-dir=/usr/local/include/boost-1_33_1])])
66     CPPFLAGS=$OLD_CPPFLAGS
67   else
68     #
69     # Otherwise we check in the default places
70     # 
71     AC_CHECK_HEADER([boost/shared_ptr.hpp],
72       [BOOST_CFLAGS=""],
73       [ # Nope, look for latest version if any in $prefix/include/boost-*
74
75         # Wipe out cached value.  KLUDGE: AC should have API for this
76         unset AS_TR_SH([ac_cv_header_boost/shared_ptr.hpp])
77
78         boost_last_match(){
79           #echo "boost_last_match: [$]*"
80           pattern="[$]1"
81           shift
82           if test "[$]pattern" = "[$]1"
83           then
84             LM=''
85           else
86             shift `expr [$]# - 1`
87             LM=[$]1
88           fi
89           #echo "LM(1)='[$]LM'"
90         }
91
92         pattern="/usr/local/include/boost-*"
93         boost_last_match "$pattern" $pattern
94         #echo "LM(2)='$LM'"
95
96         OLD_CPPFLAGS=$CPP_FLAGS
97         CPPFLAGS="$CPPFLAGS -I$LM"
98         AC_CHECK_HEADER([boost/shared_ptr.hpp],
99           [BOOST_CFLAGS="-I$LM"],
100           [AC_MSG_ERROR(
101             [Failed to locate boost/shared_ptr.hpp.  
102 Try using --with-boost-include-dir=<path>, 
103 E.g., --with-boost-include-dir=/usr/local/include/boost-1_33_1])])
104         CPPFLAGS=$OLD_CPPFLAGS
105       ])
106
107    fi
108    unset boost_last_match LM
109    AC_LANG_POP
110    AC_SUBST(BOOST_CFLAGS)
111 ])