root / firmware / fx2 / config / grc_build.m4 @ 70eae1d2
History | View | Annotate | Download (10.4 kB)
| 1 |
dnl Copyright 2006,2008,2009 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 |
dnl Create --enable-foo argument for named component, create variables as needed |
| 21 |
dnl $1 is component name |
| 22 |
AC_DEFUN([GRC_ENABLE], [ |
| 23 |
_GRC_ENABLE($1,m4_bpatsubst($1,-,_)) |
| 24 |
]) |
| 25 |
dnl $2 is the '_'d component name |
| 26 |
dnl on exit variable enable_$2 will be set to [yes|no]; |
| 27 |
dnl passed will be [yes|no] (same as enable_$2) |
| 28 |
|
| 29 |
AC_DEFUN([_GRC_ENABLE],[ |
| 30 |
passed=yes |
| 31 |
AC_ARG_ENABLE([$1], |
| 32 |
AC_HELP_STRING([--enable-$1], |
| 33 |
[Stop if $1 fails configuration]), |
| 34 |
[],[ |
| 35 |
[enable_]$2=$enable_all_components |
| 36 |
if test x$enable_all_components = xno; then |
| 37 |
passed=no |
| 38 |
fi |
| 39 |
]) |
| 40 |
]) |
| 41 |
dnl Component specific configuration |
| 42 |
dnl The order of the GR_ macros determines the order of compilation |
| 43 |
dnl For -any- checks on $enable_all_components |
| 44 |
dnl use the following guildlines: |
| 45 |
dnl yes : --enable-all-components was specified, so error out if any |
| 46 |
dnl components do not pass configuration checks. |
| 47 |
dnl no : --disable-all-components was specified, so try to build the |
| 48 |
dnl --enable'd components, and error out if any do not pass |
| 49 |
dnl configuration checks. |
| 50 |
dnl "" : this option was not specified on the command line; try to |
| 51 |
dnl build all components that are not --with'd, but don't |
| 52 |
dnl error out if any component does not pass configuration checks. |
| 53 |
dnl |
| 54 |
dnl For each --enable-foo component, if that flag is not specified on |
| 55 |
dnl the command line, the related variable $enable_foo will be set to |
| 56 |
dnl $enable_all_components . |
| 57 |
|
| 58 |
dnl Create --with-foo argument for named compoment, create variables as needed |
| 59 |
dnl $1 is component name |
| 60 |
dnl $2 is what to do on success |
| 61 |
dnl $3 is the PKG_CONFIG name; if not given, then $1 |
| 62 |
AC_DEFUN([GRC_WITH], [ |
| 63 |
if test [x]$3 = x; then |
| 64 |
pc_comp_name="$1" |
| 65 |
else |
| 66 |
pc_comp_name="$3" |
| 67 |
fi |
| 68 |
_GRC_WITH($1,[$2],${pc_comp_name},m4_bpatsubst($1,-,_))
|
| 69 |
]) |
| 70 |
dnl $3 is the pkg-config component name |
| 71 |
dnl $4 is the '_'d component name |
| 72 |
dnl on exit variable passed will be [yes|no|with]: |
| 73 |
dnl yes: if --enable-$1 and/or --enable-all-components was specified, |
| 74 |
dnl but --with was not; |
| 75 |
dnl with: if --with-$1 was specified, and passed checks; |
| 76 |
dnl no: all other conditions |
| 77 |
AC_DEFUN([_GRC_WITH],[ |
| 78 |
AC_ARG_WITH([$1], |
| 79 |
AC_HELP_STRING([--with-$1@<:@=PATH@:>@], |
| 80 |
[Use package $1 if installed in PATH (if specified) or PKG_CONFIG_PATH (if PATH not specified); stop if $1 not found]), |
| 81 |
[if test "x$withval" != "xyes"; then |
| 82 |
[with_]$4[_val]=$withval |
| 83 |
[with_]$4=yes |
| 84 |
fi], |
| 85 |
[]) |
| 86 |
if test x$[with_]$4 = xyes; then |
| 87 |
if test x$[enable_]$4 = xyes; then |
| 88 |
AC_MSG_ERROR([Component $1: Cannot use both --enable and --with]) |
| 89 |
else |
| 90 |
_GRC_WITH_PKG_CONFIG_CHECK($1,$3,$4) |
| 91 |
ifelse([$2], , :, [$2]) |
| 92 |
fi |
| 93 |
fi |
| 94 |
]) |
| 95 |
|
| 96 |
dnl Use 'pkgconfig' to check for a package |
| 97 |
dnl $1 is the --with component name |
| 98 |
dnl $2 is the pkg-config component name, if provided; otherwise use $1 for this |
| 99 |
dnl on success, resulting INCLUDES, INCLUDEDIR, LA, and LIBDIRPATH variables |
| 100 |
dnl will be set; on failure, will exit with an error. |
| 101 |
AC_DEFUN([GRC_WITH_PKG_CONFIG_CHECK], [ |
| 102 |
if test [x]$2 = x; then |
| 103 |
pc_comp_name="$1" |
| 104 |
else |
| 105 |
pc_comp_name="$2" |
| 106 |
fi |
| 107 |
_GRC_WITH_PKG_CONFIG_CHECK($1,${pc_comp_name},m4_bpatsubst($1,-,_))
|
| 108 |
]) |
| 109 |
dnl $2 is the pkg-config component name |
| 110 |
dnl $3 is the '_'d component name |
| 111 |
AC_DEFUN([_GRC_WITH_PKG_CONFIG_CHECK],[ |
| 112 |
dnl save PKG_CONFIG_PATH, restore at the end |
| 113 |
s_PKG_CONFIG_PATH=$PKG_CONFIG_PATH |
| 114 |
|
| 115 |
dnl create the PKG_CONFIG_PATH, via this component arg, if provided; |
| 116 |
dnl else use the environment PKG_CONFIG_PATH |
| 117 |
l_PKG_CONFIG_PATH=$[with_]$3[_val] |
| 118 |
if test "x$l_PKG_CONFIG_PATH" != "x"; then |
| 119 |
export PKG_CONFIG_PATH=$l_PKG_CONFIG_PATH |
| 120 |
|
| 121 |
dnl verify that the file exists; if not, no point in continuing |
| 122 |
if ! test -r ${l_PKG_CONFIG_PATH}/$2[.pc]; then
|
| 123 |
AC_MSG_ERROR([Component $1: PKGCONFIG cannot find info for $2, with provided PKG_CONFIG_PATH = @<:@ $l_PKG_CONFIG_PATH @:>@ .]) |
| 124 |
fi |
| 125 |
fi |
| 126 |
|
| 127 |
dnl do the check; error out if not found |
| 128 |
PKG_CHECK_EXISTS($2, [passed=with; check1=yes], [ |
| 129 |
check1=no |
| 130 |
dnl pkg-config returned an error; this might be that the .pc |
| 131 |
dnl file was not valid, or the Requires: were not met. |
| 132 |
dnl If the arg was provided and the input PKG_CONFIG_PATH , then try |
| 133 |
dnl again appending the whole PKG_CONFIG_PATH. |
| 134 |
if test "x$l_PKG_CONFIG_PATH" != "x"; then |
| 135 |
if test "x$s_PKG_CONFIG_PATH" != "x"; then |
| 136 |
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:${s_PKG_CONFIG_PATH}
|
| 137 |
PKG_CHECK_EXISTS($2, passed=with, passed=no) |
| 138 |
fi |
| 139 |
fi |
| 140 |
if test $passed != with; then |
| 141 |
AC_MSG_ERROR([Component $1: PKGCONFIG cannot find info for $2, with PKG_CONFIG_PATH = @<:@ $PKG_CONFIG_PATH @:>@ .]) |
| 142 |
fi |
| 143 |
dnl pkg-config Requires are now met; save the new PKG_CONFIG_PATH |
| 144 |
s_PKG_CONFIG_PATH=$PKG_CONFIG_PATH |
| 145 |
]) |
| 146 |
|
| 147 |
dnl if PKG_CHECK_EXISTS returned, then this component's .pc file was |
| 148 |
dnl found in the provided 'arg' PKG_CONFIG_PATH; |
| 149 |
dnl retrieve various parameters |
| 150 |
$3[_INCLUDES]=`$PKG_CONFIG --cflags-only-I $2` |
| 151 |
$3[_LA]=`$PKG_CONFIG --libs $2` |
| 152 |
$3[_INCLUDEDIR]=`$PKG_CONFIG --variable=includedir $2` |
| 153 |
|
| 154 |
if test x$check1 = xyes; then |
| 155 |
dnl prepend the args PKG_CONFIG_PATH to the saved one, if the |
| 156 |
dnl saved version was not empty |
| 157 |
if test "x$s_PKG_CONFIG_PATH" != "x"; then |
| 158 |
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:${s_PKG_CONFIG_PATH}
|
| 159 |
fi |
| 160 |
fi |
| 161 |
]) |
| 162 |
|
| 163 |
dnl Check the $prefix versus the --with libdirpath for this component |
| 164 |
dnl $1 is the prefix |
| 165 |
dnl $2 is the --with component name |
| 166 |
dnl $3 is the --with component library path |
| 167 |
AC_DEFUN([GRC_PREFIX_LDFLAGS],[ |
| 168 |
$2[_LIBDIRPATH]=$3 |
| 169 |
dnl create LDFLAGS for this --with, if different from the provided $prefix |
| 170 |
if test [x]$1[/lib] != [x]$3; then |
| 171 |
$2[_LDFLAG]=[-L]$3 |
| 172 |
else |
| 173 |
$2[_LDFLAG]= |
| 174 |
fi |
| 175 |
]) |
| 176 |
|
| 177 |
dnl Check to make sure this dependency is fulfilled for this component |
| 178 |
dnl $1 is the component's name |
| 179 |
dnl $2 is the component dependency name |
| 180 |
dnl On input and exit, $passed will be: |
| 181 |
dnl with : if --with passed muster |
| 182 |
dnl yes : if --enable passed muster |
| 183 |
dnl no : otherwise |
| 184 |
dnl If trying --with, will error-out if any dependency was not --with'd |
| 185 |
AC_DEFUN([GRC_CHECK_DEPENDENCY],[ |
| 186 |
dnl f0=[enable_]m4_bpatsubst($1,-,_) |
| 187 |
dnl f1=[$enable_]m4_bpatsubst($1,-,_) |
| 188 |
dnl echo |
| 189 |
dnl echo "$1 : Checking Dependency $2" |
| 190 |
dnl echo "$1 : enable_all_components is '$enable_all_components'" |
| 191 |
dnl echo "$1 : $f0 is '$f1'" |
| 192 |
dnl echo "$1 : passed is '$passed'" |
| 193 |
dnl echo |
| 194 |
if test $passed != no; then |
| 195 |
if test $passed = yes; then |
| 196 |
dnl make sure this dependency was not skipped |
| 197 |
if test [x$]m4_bpatsubst($2,-,_)[_skipped] = xyes; then |
| 198 |
AC_MSG_RESULT([Component $1 requires $2, which is not being built or specified via pre-installed files.]) |
| 199 |
passed=no |
| 200 |
fi |
| 201 |
else |
| 202 |
dnl make sure this dependency was --with'd only; not --enable'd |
| 203 |
if test [x$]m4_bpatsubst($2,-,_)[_with] = xno; then |
| 204 |
AC_MSG_ERROR([Component $1 requires $2 to be included as --with-$2@<:@=arg@:>@]) |
| 205 |
fi |
| 206 |
fi |
| 207 |
fi |
| 208 |
]) |
| 209 |
|
| 210 |
dnl Check to make sure GUILE is available |
| 211 |
dnl $1 is the component name |
| 212 |
AC_DEFUN([GRC_CHECK_GUILE],[ |
| 213 |
if test x"$GUILE" = x; then |
| 214 |
AC_MSG_RESULT([Component $1 requires guile, which was not found.]) |
| 215 |
passed=no |
| 216 |
fi |
| 217 |
]) |
| 218 |
|
| 219 |
dnl Add the specified "with" list; clear the provided variable |
| 220 |
dnl $1 is the component name |
| 221 |
dnl $2 is the path list name suffix |
| 222 |
dnl $3 is the separator (for paths, ":"; for includes " ") |
| 223 |
AC_DEFUN([GRC_ADD_TO_LIST],[ |
| 224 |
if test "x${$1[_]$2}" != "x"; then
|
| 225 |
if test "x$[with_]$2" = "x"; then |
| 226 |
[with_]$2="${$1[_]$2}"
|
| 227 |
else |
| 228 |
[with_]$2="${$1[_]$2}"$3"$[with_]$2"
|
| 229 |
fi |
| 230 |
$1[_]$2= |
| 231 |
fi |
| 232 |
]) |
| 233 |
|
| 234 |
dnl Conditionally build named component. |
| 235 |
dnl $1 is component name |
| 236 |
dnl $2 is executed if configuration passes and build is desired |
| 237 |
AC_DEFUN([GRC_BUILD_CONDITIONAL],[ |
| 238 |
_GRC_BUILD_CONDITIONAL($1, $2, m4_bpatsubst($1,-,_)) |
| 239 |
]) |
| 240 |
dnl $3=m4_bpatsubst($1,-,_) |
| 241 |
dnl Use $passed=no to indicate configuration failure; |
| 242 |
dnl Use $passed=with to indicate the use of pre-installed libraries and headers; |
| 243 |
dnl Any other value of $passed, including blank, assumes success; |
| 244 |
dnl Defines $3_with=[yes|no] depending on if $passed=with or not (respectively) |
| 245 |
dnl Defines $3_skipped=[yes|no] depending on if $passed=no or not (respectively) |
| 246 |
AC_DEFUN([_GRC_BUILD_CONDITIONAL],[ |
| 247 |
$3[_with]=no |
| 248 |
if test $passed = no; then |
| 249 |
if test x$[enable_]$3 = xyes; then |
| 250 |
AC_MSG_ERROR([Component $1 has errors; stopping.]) |
| 251 |
else |
| 252 |
AC_MSG_RESULT([Not building component $1.]) |
| 253 |
fi |
| 254 |
else |
| 255 |
if test $passed = with; then |
| 256 |
with_dirs="$with_dirs $1" |
| 257 |
GRC_ADD_TO_LIST($3, INCLUDES, " ") |
| 258 |
GRC_ADD_TO_LIST($3, SWIG_INCLUDES, " ") |
| 259 |
GRC_ADD_TO_LIST($3, PYDIRPATH, ":") |
| 260 |
GRC_ADD_TO_LIST($3, SWIGDIRPATH, ":") |
| 261 |
GRC_ADD_TO_LIST($3, LIBDIRPATH, ":") |
| 262 |
AC_MSG_RESULT([Component $1 will be included from a pre-installed library and includes.]) |
| 263 |
$3[_with]=yes |
| 264 |
else |
| 265 |
$3[_LDFLAG]= |
| 266 |
if test x$[enable_]$3 != xno; then |
| 267 |
ifelse([$2], , :, [$2]) |
| 268 |
build_dirs="$build_dirs $1" |
| 269 |
AC_MSG_RESULT([Component $1 passed configuration checks; building.]) |
| 270 |
else |
| 271 |
passed=no |
| 272 |
AC_MSG_RESULT([Component $1 passed configuration checks; but not building.]) |
| 273 |
fi |
| 274 |
fi |
| 275 |
fi |
| 276 |
if test $passed = no; then |
| 277 |
skipped_dirs="$skipped_dirs $1" |
| 278 |
$3[_skipped]=yes |
| 279 |
else |
| 280 |
$3[_skipped]=no |
| 281 |
fi |
| 282 |
AC_SUBST($3[_INCLUDES]) |
| 283 |
AC_SUBST($3[_LA]) |
| 284 |
AC_SUBST($3[_INCLUDEDIR]) |
| 285 |
AC_SUBST($3[_LIBDIRPATH]) |
| 286 |
AC_SUBST($3[_LDFLAG]) |
| 287 |
]) |