Updated db_bitshark_rx.c to the proper version that includes the
[debian/gnuradio] / config / gr_set_md_cpu.m4
1 dnl
2 dnl Copyright 2003,2008,2009 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 AC_DEFUN([_TRY_ADD_ALTIVEC],
23 [
24   LF_CHECK_CC_FLAG([-mabi=altivec -maltivec])
25   LF_CHECK_CXX_FLAG([-mabi=altivec -maltivec])
26 ])
27
28 AC_DEFUN([_FIND_ARM_ISA],
29 [
30   AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
31   [[#ifndef __ARM_ARCH_5__
32     #error "Not armv5"
33     #endif
34   ]])],
35     [is_armv5=yes],
36     [is_armv5=no])
37
38   AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
39   [[#ifndef __ARM_ARCH_7A__
40     #error "Not armv7-a"
41     #endif
42   ]])],
43     [is_armv7_a=yes],
44     [is_armv7_a=no])
45
46 ])
47
48 AC_DEFUN([GR_SET_MD_CPU],[
49   AC_REQUIRE([AC_CANONICAL_HOST])
50   AC_ARG_WITH(md-cpu,
51         AC_HELP_STRING([--with-md-cpu=ARCH],[set machine dependent speedups (auto)]),
52                 [cf_with_md_cpu="$withval"],
53                 [
54   dnl see if the user has specified --host or --build, via 'cross_compiling'
55   if test "$cross_compiling" != no; then
56     dnl when cross-compiling, because the user specified it either via
57     dnl --target or --build, just keep the user's specs & hope for the best.
58     cf_with_md_cpu="$host_cpu"
59   else
60     dnl when the user didn't specify --target or --build, on Darwin 10
61     dnl (OSX 10.6.0 and .1) and GNU libtoool 2.2.6, 'configure' doesn't
62     dnl figure out the CPU type correctly, so do it by hand here using
63     dnl the sizeof (void*): if 4 then use i386, and otherwise use x86_64.
64     case "$host_os" in
65      *darwin*10*)
66       AC_CHECK_SIZEOF(void*)
67       if test "$ac_cv_sizeof_voidp" = 4; then
68        cf_with_md_cpu="i386"
69       else
70        cf_with_md_cpu="x86_64"
71       fi
72       ;;
73      *)
74       cf_with_md_cpu="$host_cpu"
75       ;;
76     esac
77   fi
78   ])
79   case "$cf_with_md_cpu" in
80    x86 | i[[3-7]]86)    MD_CPU=x86      MD_SUBCPU=x86 ;;
81    x86_64)              MD_CPU=x86      MD_SUBCPU=x86_64 ;;
82    powerpc*)            MD_CPU=powerpc ;;
83    arm*)
84        _FIND_ARM_ISA
85        if test $is_armv5 = yes; then MD_CPU=armv5;
86        elif test $is_armv7_a = yes; then MD_CPU=armv7_a;
87        else MD_CPU=generic; fi
88        ;;
89    *)                   MD_CPU=generic ;;
90   esac
91
92   AC_ARG_ENABLE(altivec,
93     AC_HELP_STRING([--enable-altivec],[enable altivec on PowerPC (yes)]),
94     [ if test $MD_CPU = powerpc; then
95         case "$enableval" in
96           (no)  MD_CPU=generic ;;
97           (yes) _TRY_ADD_ALTIVEC ;;
98           (*) AC_MSG_ERROR([Invalid argument ($enableval) to --enable-altivec]) ;;
99         esac
100       fi],
101     [ if test $MD_CPU = powerpc; then _TRY_ADD_ALTIVEC fi])
102
103
104   AC_MSG_CHECKING([for machine dependent speedups])
105   AC_MSG_RESULT($MD_CPU)
106   AC_SUBST(MD_CPU)
107   AC_SUBST(MD_SUBCPU) 
108
109   AM_CONDITIONAL(MD_CPU_x86,     test "$MD_CPU" = "x86")
110   AM_CONDITIONAL(MD_SUBCPU_x86_64,  test "$MD_SUBCPU" = "x86_64")
111   AM_CONDITIONAL(MD_CPU_powerpc, test "$MD_CPU" = "powerpc")
112   AM_CONDITIONAL(MD_CPU_armv5, test "$MD_CPU" = "armv5")
113   AM_CONDITIONAL(MD_CPU_armv7_a, test "$MD_CPU" = "armv7_a")
114   AM_CONDITIONAL(MD_CPU_generic, test "$MD_CPU" = "generic")
115 ])