m4/gst-arch.m4: add PPC64 so we can have separate structure sizes for it
[platform/upstream/gst-common.git] / m4 / gst-arch.m4
1 dnl 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([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 ])
83
84 dnl check if unaligned memory access works correctly
85 AC_DEFUN([GST_UNALIGNED_ACCESS], [
86   AC_MSG_CHECKING([if unaligned memory access works correctly])
87   if test x"$as_cv_unaligned_access" = x ; then
88     case $host in
89       alpha*|arm*|hp*|mips*|sh*|sparc*|ia64*)
90         _AS_ECHO_N([(blacklisted) ])
91         as_cv_unaligned_access=no
92         ;;
93       i?86*|powerpc*|m68k*|cris*)
94         _AS_ECHO_N([(whitelisted) ])
95         as_cv_unaligned_access=yes
96         ;;
97     esac
98   else
99     _AS_ECHO_N([(cached) ])
100   fi
101   if test x"$as_cv_unaligned_access" = x ; then
102     AC_TRY_RUN([
103 int main(int argc, char **argv)
104 {
105   char array[] = "ABCDEFGH";
106   unsigned int iarray[2];
107   memcpy(iarray,array,8);
108 #define GET(x) (*(unsigned int *)((char *)iarray + (x)))
109   if(GET(0) != 0x41424344 && GET(0) != 0x44434241) return 1;
110   if(GET(1) != 0x42434445 && GET(1) != 0x45444342) return 1;
111   if(GET(2) != 0x43444546 && GET(2) != 0x46454443) return 1;
112   if(GET(3) != 0x44454647 && GET(3) != 0x47464544) return 1;
113   return 0;
114 }
115     ], as_cv_unaligned_access="yes", as_cv_unaligned_access="no")
116   fi
117   AC_MSG_RESULT($as_cv_unaligned_access)
118   if test "$as_cv_unaligned_access" = "yes"; then
119     AC_DEFINE_UNQUOTED(HAVE_UNALIGNED_ACCESS, 1,
120       [defined if unaligned memory access works correctly])
121   fi
122   AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU])
123 ])