Merged r7478:7608 from michaelld/t186 into trunk. Adds ability to compile GNU Radio...
[debian/gnuradio] / config / grc_build.m4
1 dnl Copyright 2006,2008 Free Software Foundation, Inc.
2 dnl 
3 dnl This file is part of GNU Radio
4 dnl 
5 dnl GNU Radio is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3, or (at your option)
8 dnl any later version.
9 dnl 
10 dnl GNU Radio is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl 
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with GNU Radio; see the file COPYING.  If not, write to
17 dnl the Free Software Foundation, Inc., 51 Franklin Street,
18 dnl Boston, MA 02110-1301, USA.
19
20 # Create --enable-foo argument for named component, create variables as needed
21 # $1 is component name
22 AC_DEFUN([GRC_ENABLE],[
23     AC_ARG_ENABLE([$1],
24                   AC_HELP_STRING([--enable-$1],
25                                  [Fail build if $1 fails configuration]),
26                   [],
27                   [[enable_]m4_bpatsubst($1,-,_)=$enable_all_components])
28 ])
29
30 # Create --with-foo argument for named compoment, create variables as needed
31 # $1 is component name
32 AC_DEFUN([GRC_WITH],[
33     AC_ARG_WITH([$1],
34                 AC_HELP_STRING([--with-$1],
35                                [Use package $1 if installed in $prefix/lib/pkgconfig; otherwise revert back to --enable-$1]),
36                 [],
37                 [])
38 ])
39
40 # Add the specified "with" list; clear the provided variable
41 # $1 is the component name
42 # $2 is the path list name suffix
43 # $3 is the separator (for paths, ":"; for includes " ")
44 AC_DEFUN([GRC_ADD_TO_LIST],[
45     if test "x${$1_$2}" != "x"; then
46         if test "x$with_$2" = "x"; then
47             with_$2="${$1_$2}"
48         else
49             with_$2="${$1_$2}"$3"$with_$2"
50         fi
51         $1_$2=
52     fi
53 ])
54
55 # Conditionally build named component.
56 # $1 is component name
57 # $2 is executed if configuration passes and build is desired
58 AC_DEFUN([GRC_BUILD_CONDITIONAL],[
59     _GRC_BUILD_CONDITIONAL($1, m4_bpatsubst($1,-,_), $2)
60 ])
61
62 # $1 is the component name
63 # $2=m4_bpatsubst($1,-,_)
64 # $3 is executed if configuration passes and build is desired
65 # Use $passed=no to indicate configuration failure
66 # Use $passed=with to indicate the use of pre-installed libraries and headers
67 # Any other value of $passed, including blank, assumes success 
68 AC_DEFUN([_GRC_BUILD_CONDITIONAL],[
69     if test x$passed = xno; then
70         if test x$enable_$2 = xyes; then
71             AC_MSG_ERROR([Component $1 has errors, stopping.])
72         else
73             AC_MSG_RESULT([Not building component $1.])
74         fi
75     else
76         if test x$passed = xwith; then
77             with_dirs="$with_dirs $1"
78             GRC_ADD_TO_LIST($2, INCLUDES, " ")
79             GRC_ADD_TO_LIST($2, SWIG_INCLUDES, " ")
80             GRC_ADD_TO_LIST($2, PYDIRPATH, ":")
81             GRC_ADD_TO_LIST($2, SWIGDIRPATH, ":")
82             GRC_ADD_TO_LIST($2, LIBDIRPATH, ":")
83             AC_MSG_RESULT([Component $1 will be included from a pre-installed library and includes, and will not be built.])
84         else
85             if test x$enable_$2 != xno; then
86                 $3
87                 build_dirs="$build_dirs $1"
88                 AC_MSG_RESULT([Component $1 passed configuration checks, building.])
89             else
90                 passed=no
91                 AC_MSG_RESULT([Component $1 passed configuration checks, but not building.])
92             fi
93         fi
94     fi
95     if test x$passed = xno; then
96         skipped_dirs="$skipped_dirs $1"
97         $2_skipped=yes
98     else
99         $2_skipped=no
100     fi
101 ])