Initial release including wifi display based on gst-rtsp-server-1.4.1
[platform/upstream/gstreamer.git] / 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   dnl Determine CPU
9   case "x${target_cpu}" in
10     xi?86 | xk? | xi?86_64)
11       case $target_os in
12          solaris*)
13             AC_CHECK_DECL([__i386],     [I386_ABI="yes"], [I386_ABI="no"])
14             AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"])
15
16             if test "x$I386_ABI" = "xyes" ; then
17                HAVE_CPU_I386=yes
18                AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86])
19             fi
20             if test "x$AMD64_ABI" = "xyes" ; then
21                 HAVE_CPU_X86_64=yes
22                 AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64])
23             fi
24             ;;
25          *)
26             HAVE_CPU_I386=yes
27             AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86])
28
29             dnl FIXME could use some better detection
30             dnl (ie CPUID)
31             case "x${target_cpu}" in
32               xi386 | xi486) ;;
33             *)
34               AC_DEFINE(HAVE_RDTSC, 1, [Define if RDTSC is available]) ;;
35             esac
36             ;;
37       esac
38       ;;
39     xpowerpc)
40       HAVE_CPU_PPC=yes
41       AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the target CPU is a PowerPC]) ;;
42     xpowerpc64)
43       HAVE_CPU_PPC64=yes
44       AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the target CPU is a 64 bit PowerPC]) ;;
45     xalpha*)
46       HAVE_CPU_ALPHA=yes
47       AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the target CPU is an Alpha]) ;;
48     xarm*)
49       HAVE_CPU_ARM=yes
50       AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the target CPU is an ARM]) ;;
51     xsparc*)
52       HAVE_CPU_SPARC=yes
53       AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the target CPU is a SPARC]) ;;
54     xmips*)
55       HAVE_CPU_MIPS=yes
56       AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the target CPU is a MIPS]) ;;
57     xhppa*)
58       HAVE_CPU_HPPA=yes
59       AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the target CPU is a HPPA]) ;;
60     xs390*)
61       HAVE_CPU_S390=yes
62       AC_DEFINE(HAVE_CPU_S390, 1, [Define if the target CPU is a S390]) ;;
63     xia64*)
64       HAVE_CPU_IA64=yes
65       AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the target CPU is a IA64]) ;;
66     xm68k*)
67       HAVE_CPU_M68K=yes
68       AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the target CPU is a M68K]) ;;
69     xx86_64)
70       HAVE_CPU_X86_64=yes
71       AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64]) ;;
72     xcris)
73       HAVE_CPU_CRIS=yes
74       AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the target CPU is a CRIS]) ;;
75     xcrisv32)
76       HAVE_CPU_CRISV32=yes
77       AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the target CPU is a CRISv32]) ;;
78   esac
79
80   dnl Determine endianness
81   AC_C_BIGENDIAN
82
83   AM_CONDITIONAL(HAVE_CPU_I386,       test "x$HAVE_CPU_I386" = "xyes")
84   AM_CONDITIONAL(HAVE_CPU_PPC,        test "x$HAVE_CPU_PPC" = "xyes")
85   AM_CONDITIONAL(HAVE_CPU_PPC64,      test "x$HAVE_CPU_PPC64" = "xyes")
86   AM_CONDITIONAL(HAVE_CPU_ALPHA,      test "x$HAVE_CPU_ALPHA" = "xyes")
87   AM_CONDITIONAL(HAVE_CPU_ARM,        test "x$HAVE_CPU_ARM" = "xyes")
88   AM_CONDITIONAL(HAVE_CPU_SPARC,      test "x$HAVE_CPU_SPARC" = "xyes")
89   AM_CONDITIONAL(HAVE_CPU_HPPA,       test "x$HAVE_CPU_HPPA" = "xyes")
90   AM_CONDITIONAL(HAVE_CPU_MIPS,       test "x$HAVE_CPU_MIPS" = "xyes")
91   AM_CONDITIONAL(HAVE_CPU_S390,       test "x$HAVE_CPU_S390" = "xyes")
92   AM_CONDITIONAL(HAVE_CPU_IA64,       test "x$HAVE_CPU_IA64" = "xyes")
93   AM_CONDITIONAL(HAVE_CPU_M68K,       test "x$HAVE_CPU_M68K" = "xyes")
94   AM_CONDITIONAL(HAVE_CPU_X86_64,     test "x$HAVE_CPU_X86_64" = "xyes")
95   AM_CONDITIONAL(HAVE_CPU_CRIS,       test "x$HAVE_CPU_CRIS" = "xyes")
96   AM_CONDITIONAL(HAVE_CPU_CRISV32,    test "x$HAVE_CPU_CRISV32" = "xyes")
97
98   AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU])
99   AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu", [the target CPU])
100 ])
101
102 dnl check if unaligned memory access works correctly
103 AC_DEFUN([AG_GST_UNALIGNED_ACCESS], [
104   AC_MSG_CHECKING([if unaligned memory access works correctly])
105   if test x"$as_cv_unaligned_access" = x ; then
106     case $host in
107       alpha*|arm*|hp*|mips*|sh*|sparc*|ia64*)
108         _AS_ECHO_N([(blacklisted) ])
109         as_cv_unaligned_access=no
110         ;;
111       i?86*|x86_64*|amd64*|powerpc*|m68k*|cris*)
112         _AS_ECHO_N([(whitelisted) ])
113         as_cv_unaligned_access=yes
114         ;;
115     esac
116   else
117     _AS_ECHO_N([(cached) ])
118   fi
119   if test x"$as_cv_unaligned_access" = x ; then
120     AC_TRY_RUN([
121 int main(int argc, char **argv)
122 {
123   char array[] = "ABCDEFGH";
124   unsigned int iarray[2];
125   memcpy(iarray,array,8);
126 #define GET(x) (*(unsigned int *)((char *)iarray + (x)))
127   if(GET(0) != 0x41424344 && GET(0) != 0x44434241) return 1;
128   if(GET(1) != 0x42434445 && GET(1) != 0x45444342) return 1;
129   if(GET(2) != 0x43444546 && GET(2) != 0x46454443) return 1;
130   if(GET(3) != 0x44454647 && GET(3) != 0x47464544) return 1;
131   return 0;
132 }
133     ], as_cv_unaligned_access="yes", as_cv_unaligned_access="no")
134   fi
135   AC_MSG_RESULT($as_cv_unaligned_access)
136   if test "$as_cv_unaligned_access" = "yes"; then
137     AC_DEFINE_UNQUOTED(HAVE_UNALIGNED_ACCESS, 1,
138       [defined if unaligned memory access works correctly])
139   fi
140 ])