Initialize Tizen 2.3
[framework/multimedia/gst-plugins-ext0.10.git] / mobile / common / m4 / gst-arch.m4
1 dnl AG_GST_ARCH
2 dnl sets up defines and automake conditionals for host architecture
3 dnl checks endianness
4 dnl defines HOST_CPU
5
6 AC_DEFUN([AG_GST_ARCH],
7 [
8   AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use host_ variables
9
10   dnl Determine CPU
11   case "x${host_cpu}" in
12     xi?86 | xk? | xi?86_64)
13       HAVE_CPU_I386=yes
14       AC_DEFINE(HAVE_CPU_I386, 1, [Define if the host CPU is an x86])
15   
16       dnl FIXME could use some better detection
17       dnl (ie CPUID)
18       case "x${host_cpu}" in
19         xi386 | xi486) ;;
20         *)
21           AC_DEFINE(HAVE_RDTSC, 1, [Define if RDTSC is available]) ;;
22       esac ;;
23     xpowerpc)
24       HAVE_CPU_PPC=yes
25       AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the host CPU is a PowerPC]) ;;
26     xpowerpc64)
27       HAVE_CPU_PPC64=yes
28       AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the host CPU is a 64 bit PowerPC]) ;;
29     xalpha*)
30       HAVE_CPU_ALPHA=yes
31       AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the host CPU is an Alpha]) ;;
32     xarm*)
33       HAVE_CPU_ARM=yes
34       AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the host CPU is an ARM]) ;;
35     xsparc*)
36       HAVE_CPU_SPARC=yes
37       AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the host CPU is a SPARC]) ;;
38     xmips*)
39       HAVE_CPU_MIPS=yes
40       AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the host CPU is a MIPS]) ;;
41     xhppa*)
42       HAVE_CPU_HPPA=yes
43       AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the host CPU is a HPPA]) ;;
44     xs390*)
45       HAVE_CPU_S390=yes
46       AC_DEFINE(HAVE_CPU_S390, 1, [Define if the host CPU is a S390]) ;;
47     xia64*)
48       HAVE_CPU_IA64=yes
49       AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the host CPU is a IA64]) ;;
50     xm68k*)
51       HAVE_CPU_M68K=yes
52       AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the host CPU is a M68K]) ;;
53     xx86_64)
54       HAVE_CPU_X86_64=yes
55       AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the host CPU is a x86_64]) ;;
56     xcris)
57       HAVE_CPU_CRIS=yes
58       AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the host CPU is a CRIS]) ;;
59     xcrisv32)
60       HAVE_CPU_CRISV32=yes
61       AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the host CPU is a CRISv32]) ;;
62   esac
63   
64   dnl Determine endianness
65   AC_C_BIGENDIAN
66   
67   AM_CONDITIONAL(HAVE_CPU_I386,       test "x$HAVE_CPU_I386" = "xyes")
68   AM_CONDITIONAL(HAVE_CPU_PPC,        test "x$HAVE_CPU_PPC" = "xyes")
69   AM_CONDITIONAL(HAVE_CPU_PPC64,      test "x$HAVE_CPU_PPC64" = "xyes")
70   AM_CONDITIONAL(HAVE_CPU_ALPHA,      test "x$HAVE_CPU_ALPHA" = "xyes")
71   AM_CONDITIONAL(HAVE_CPU_ARM,        test "x$HAVE_CPU_ARM" = "xyes")
72   AM_CONDITIONAL(HAVE_CPU_SPARC,      test "x$HAVE_CPU_SPARC" = "xyes")
73   AM_CONDITIONAL(HAVE_CPU_HPPA,       test "x$HAVE_CPU_HPPA" = "xyes")
74   AM_CONDITIONAL(HAVE_CPU_MIPS,       test "x$HAVE_CPU_MIPS" = "xyes")
75   AM_CONDITIONAL(HAVE_CPU_S390,       test "x$HAVE_CPU_S390" = "xyes")
76   AM_CONDITIONAL(HAVE_CPU_IA64,       test "x$HAVE_CPU_IA64" = "xyes")
77   AM_CONDITIONAL(HAVE_CPU_M68K,       test "x$HAVE_CPU_M68K" = "xyes")
78   AM_CONDITIONAL(HAVE_CPU_X86_64,     test "x$HAVE_CPU_X86_64" = "xyes")
79   AM_CONDITIONAL(HAVE_CPU_CRIS,       test "x$HAVE_CPU_CRIS" = "xyes")
80   AM_CONDITIONAL(HAVE_CPU_CRISV32,    test "x$HAVE_CPU_CRISV32" = "xyes")
81
82   AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU])
83 ])
84
85 dnl check if unaligned memory access works correctly
86 AC_DEFUN([AG_GST_UNALIGNED_ACCESS], [
87   AC_MSG_CHECKING([if unaligned memory access works correctly])
88   if test x"$as_cv_unaligned_access" = x ; then
89     case $host in
90       alpha*|arm*|hp*|mips*|sh*|sparc*|ia64*)
91         _AS_ECHO_N([(blacklisted) ])
92         as_cv_unaligned_access=no
93         ;;
94       i?86*|powerpc*|m68k*|cris*)
95         _AS_ECHO_N([(whitelisted) ])
96         as_cv_unaligned_access=yes
97         ;;
98     esac
99   else
100     _AS_ECHO_N([(cached) ])
101   fi
102   if test x"$as_cv_unaligned_access" = x ; then
103     AC_TRY_RUN([
104 int main(int argc, char **argv)
105 {
106   char array[] = "ABCDEFGH";
107   unsigned int iarray[2];
108   memcpy(iarray,array,8);
109 #define GET(x) (*(unsigned int *)((char *)iarray + (x)))
110   if(GET(0) != 0x41424344 && GET(0) != 0x44434241) return 1;
111   if(GET(1) != 0x42434445 && GET(1) != 0x45444342) return 1;
112   if(GET(2) != 0x43444546 && GET(2) != 0x46454443) return 1;
113   if(GET(3) != 0x44454647 && GET(3) != 0x47464544) return 1;
114   return 0;
115 }
116     ], as_cv_unaligned_access="yes", as_cv_unaligned_access="no")
117   fi
118   AC_MSG_RESULT($as_cv_unaligned_access)
119   if test "$as_cv_unaligned_access" = "yes"; then
120     AC_DEFINE_UNQUOTED(HAVE_UNALIGNED_ACCESS, 1,
121       [defined if unaligned memory access works correctly])
122   fi
123 ])