Imported Upstream version 3.2.2
[debian/gnuradio] / config / usrp_sdcc.m4
1 # Check for sdcc support.                       -*- Autoconf -*-
2
3 # Copyright 2004 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3, or (at your option)
8 # any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Boston, MA
18 # 02110-1301, USA.
19
20 AC_DEFUN([USRP_SDCC],
21 [
22         sdccok=yes
23         AC_CHECK_PROG(XCC, sdcc, sdcc -mmcs51 --no-xinit-opt,no)
24         AC_CHECK_PROG(XAS, asx8051, asx8051 -plosgff,no)
25
26         if test "$XCC" = "no" -o "$XAS" = "no" ; then
27                 AC_MSG_RESULT([USRP requires sdcc. sdcc not found. See http://sdcc.sf.net])
28                 sdccok=no
29         else
30                 sdcc_version_min=$1
31
32                 sdcc_version=`sdcc --version 2>&1 | \
33                         sed  's/\(SDCC.* \)\([[0-9]]*\.[[0-9]]*\.[[0-9]]*\)\( .*$\)/\2/'`
34
35                 AC_MSG_CHECKING([sdcc_version "$sdcc_version"])
36
37                 sdcc_major_version=`echo $sdcc_version | \
38                         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
39                 sdcc_minor_version=`echo $sdcc_version | \
40                         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
41                 sdcc_micro_version=`echo $sdcc_version | \
42                         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
43
44                 sdcc_major_min=`echo $sdcc_version_min | \
45                         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
46                 sdcc_minor_min=`echo $sdcc_version_min | \
47                         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
48                 sdcc_micro_min=`echo $sdcc_version_min | \
49                         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
50
51                 sdcc_version_proper=`expr \
52                         "$sdcc_major_version" \> "$sdcc_major_min" \| \
53                         "$sdcc_major_version" \= "$sdcc_major_min" \& \
54                         "$sdcc_minor_version" \> "$sdcc_minor_min" \| \
55                         "$sdcc_major_version" \= "$sdcc_major_min" \& \
56                         "$sdcc_minor_version" \= "$sdcc_minor_min" \& \
57                         "$sdcc_micro_version" \>= "$sdcc_micro_min" `
58
59                 if test "$sdcc_version_proper" = "1" ; then
60                         AC_MSG_RESULT([$sdcc_major_version.$sdcc_minor_version.$sdcc_micro_version])
61                 else
62                         sdccok=no
63                         AC_MSG_RESULT([USRP requires sdcc >= $sdcc_version_min. sdcc not found. See http://sdcc.sf.net])
64                 fi
65
66                 AC_SUBST(XCC)
67                 AC_SUBST(XAS)
68         fi
69
70         if test $sdccok = yes; then
71                 ifelse([$2], , :, [$2])
72         else
73                 ifelse([$3], , :, [$3])
74         fi
75 ])