diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/m4/efl_cpu.m4 | 341 |
1 files changed, 341 insertions, 0 deletions
diff --git a/libraries/eina/m4/efl_cpu.m4 b/libraries/eina/m4/efl_cpu.m4 new file mode 100644 index 0000000..8fa6cd7 --- /dev/null +++ b/libraries/eina/m4/efl_cpu.m4 | |||
@@ -0,0 +1,341 @@ | |||
1 | dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr> | ||
2 | dnl That code is public domain and can be freely used or copied. | ||
3 | |||
4 | dnl Macro that check if several ASM instruction sets are available or not. | ||
5 | |||
6 | dnl Usage: EFL_CHECK_CPU_MMX([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) | ||
7 | dnl Add -mmmx to EFL_SIMD_FLAGS if the compiler supports it and call AC_SUBST(EFL_SIMD_FLAGS) | ||
8 | dnl Define EFL_HAVE_MMX | ||
9 | |||
10 | AC_DEFUN([EFL_CHECK_CPU_MMX], | ||
11 | [ | ||
12 | dnl configure option | ||
13 | |||
14 | AC_ARG_ENABLE([cpu-mmx], | ||
15 | [AC_HELP_STRING([--disable-cpu-mmx], [disable mmx code @<:@default=enabled@:>@])], | ||
16 | [ | ||
17 | if test "x${enableval}" = "xyes" ; then | ||
18 | _efl_enable_cpu_mmx="yes" | ||
19 | else | ||
20 | _efl_enable_cpu_mmx="no" | ||
21 | fi | ||
22 | ], | ||
23 | [_efl_enable_cpu_mmx="yes"]) | ||
24 | |||
25 | AC_MSG_CHECKING([whether to build mmx code]) | ||
26 | AC_MSG_RESULT([${_efl_enable_cpu_mmx}]) | ||
27 | |||
28 | dnl check if the CPU is supporting MMX instruction sets | ||
29 | |||
30 | _efl_build_cpu_mmx="no" | ||
31 | if test "x${_efl_enable_cpu_mmx}" = "xyes" ; then | ||
32 | case $host_cpu in | ||
33 | i*86 | x86_64 | amd64) | ||
34 | _efl_build_cpu_mmx="yes" | ||
35 | ;; | ||
36 | esac | ||
37 | fi | ||
38 | |||
39 | AC_MSG_CHECKING([whether mmx instructions set is available]) | ||
40 | AC_MSG_RESULT([${_efl_build_cpu_mmx}]) | ||
41 | |||
42 | dnl check if the compiler supports -mmmx | ||
43 | |||
44 | if test "x${_efl_build_cpu_mmx}" = "xyes" ; then | ||
45 | SAVE_CFLAGS=${CFLAGS} | ||
46 | CFLAGS="-mmmx" | ||
47 | AC_LANG_PUSH([C]) | ||
48 | |||
49 | AC_COMPILE_IFELSE( | ||
50 | [AC_LANG_PROGRAM([[]], | ||
51 | [[]])], | ||
52 | [ | ||
53 | have_linker_option="yes" | ||
54 | EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} -mmmx"], | ||
55 | [have_linker_option="no"]) | ||
56 | |||
57 | AC_LANG_POP([C]) | ||
58 | CFLAGS=${SAVE_CFLAGS} | ||
59 | |||
60 | AC_MSG_CHECKING([whether mmx linker option is supported]) | ||
61 | AC_MSG_RESULT([${have_linker_option}]) | ||
62 | fi | ||
63 | |||
64 | AC_SUBST(EFL_SIMD_FLAGS) | ||
65 | |||
66 | if test "x${_efl_build_cpu_mmx}" = "xyes" ; then | ||
67 | AC_DEFINE([EFL_HAVE_MMX], [1], [Define to mention that MMX is supported]) | ||
68 | fi | ||
69 | |||
70 | AS_IF([test "x$_efl_build_cpu_mmx" = "xyes"], [$1], [$2]) | ||
71 | ]) | ||
72 | |||
73 | dnl Usage: EFL_CHECK_CPU_SSE([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) | ||
74 | dnl Add -msse to EFL_SIMD_FLAGS if the compiler supports it and call AC_SUBST(EFL_SIMD_FLAGS) | ||
75 | dnl Define EFL_HAVE_SSE | ||
76 | |||
77 | AC_DEFUN([EFL_CHECK_CPU_SSE], | ||
78 | [ | ||
79 | dnl configure option | ||
80 | |||
81 | AC_ARG_ENABLE([cpu-sse], | ||
82 | [AC_HELP_STRING([--disable-cpu-sse], [disable sse code @<:@default=enabled@:>@])], | ||
83 | [ | ||
84 | if test "x${enableval}" = "xyes" ; then | ||
85 | _efl_enable_cpu_sse="yes" | ||
86 | else | ||
87 | _efl_enable_cpu_sse="no" | ||
88 | fi | ||
89 | ], | ||
90 | [_efl_enable_cpu_sse="yes"]) | ||
91 | |||
92 | AC_MSG_CHECKING([whether to build sse code]) | ||
93 | AC_MSG_RESULT([${_efl_enable_cpu_sse}]) | ||
94 | |||
95 | dnl check if the CPU is supporting SSE instruction sets | ||
96 | |||
97 | _efl_build_cpu_sse="no" | ||
98 | if test "x${_efl_enable_cpu_sse}" = "xyes" ; then | ||
99 | case $host_cpu in | ||
100 | i*86 | x86_64 | amd64) | ||
101 | _efl_build_cpu_sse="yes" | ||
102 | ;; | ||
103 | esac | ||
104 | fi | ||
105 | |||
106 | AC_MSG_CHECKING([whether sse instructions set is available]) | ||
107 | AC_MSG_RESULT([${_efl_build_cpu_sse}]) | ||
108 | |||
109 | dnl check if the compiler supports -msse | ||
110 | |||
111 | if test "x${_efl_build_cpu_sse}" = "xyes" ; then | ||
112 | SAVE_CFLAGS=${CFLAGS} | ||
113 | CFLAGS="-msse" | ||
114 | AC_LANG_PUSH([C]) | ||
115 | |||
116 | AC_COMPILE_IFELSE( | ||
117 | [AC_LANG_PROGRAM([[]], | ||
118 | [[]]) | ||
119 | ], | ||
120 | [ | ||
121 | have_linker_option="yes" | ||
122 | EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} -msse" | ||
123 | ], | ||
124 | [have_linker_option="no"]) | ||
125 | |||
126 | AC_LANG_POP([C]) | ||
127 | CFLAGS=${SAVE_CFLAGS} | ||
128 | |||
129 | AC_MSG_CHECKING([whether sse linker option is supported]) | ||
130 | AC_MSG_RESULT([${have_linker_option}]) | ||
131 | fi | ||
132 | |||
133 | AC_SUBST(EFL_SIMD_FLAGS) | ||
134 | |||
135 | if test "x${_efl_build_cpu_sse}" = "xyes" ; then | ||
136 | AC_DEFINE([EFL_HAVE_SSE], [1], [Define to mention that SSE is supported]) | ||
137 | fi | ||
138 | |||
139 | AS_IF([test "x$_efl_build_cpu_sse" = "xyes"], [$1], [$2]) | ||
140 | ]) | ||
141 | |||
142 | dnl Usage: EFL_CHECK_CPU_SSE2([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) | ||
143 | dnl Add -msse2 to EFL_SIMD_FLAGS if the compiler supports it and call AC_SUBST(EFL_SIMD_FLAGS) | ||
144 | dnl Define EFL_HAVE_SSE2 | ||
145 | |||
146 | AC_DEFUN([EFL_CHECK_CPU_SSE2], | ||
147 | [ | ||
148 | |||
149 | dnl configure option | ||
150 | |||
151 | AC_ARG_ENABLE([cpu-sse2], | ||
152 | [AC_HELP_STRING([--disable-cpu-sse2], [disable sse2 code @<:@default=enabled@:>@])], | ||
153 | [ | ||
154 | if test "x${enableval}" = "xyes" ; then | ||
155 | _efl_enable_cpu_sse2="yes" | ||
156 | else | ||
157 | _efl_enable_cpu_sse2="no" | ||
158 | fi | ||
159 | ], | ||
160 | [_efl_enable_cpu_sse2="yes"]) | ||
161 | |||
162 | AC_MSG_CHECKING([whether to build sse2 code]) | ||
163 | AC_MSG_RESULT([${_efl_enable_cpu_sse2}]) | ||
164 | |||
165 | dnl check if the CPU is supporting SSE2 instruction sets | ||
166 | |||
167 | _efl_build_cpu_sse2="no" | ||
168 | if test "x${_efl_enable_cpu_sse2}" = "xyes" ; then | ||
169 | case $host_cpu in | ||
170 | i*86 | x86_64 | amd64) | ||
171 | _efl_build_cpu_sse2="yes" | ||
172 | ;; | ||
173 | esac | ||
174 | fi | ||
175 | |||
176 | AC_MSG_CHECKING([whether sse2 instructions set is available]) | ||
177 | AC_MSG_RESULT([${_efl_build_cpu_sse2}]) | ||
178 | |||
179 | dnl check if the compiler supports -msse2 | ||
180 | |||
181 | if test "x${_efl_build_cpu_sse2}" = "xyes" ; then | ||
182 | SAVE_CFLAGS=${CFLAGS} | ||
183 | CFLAGS="-msse2" | ||
184 | AC_LANG_PUSH([C]) | ||
185 | |||
186 | AC_COMPILE_IFELSE( | ||
187 | [AC_LANG_PROGRAM([[]], | ||
188 | [[]]) | ||
189 | ], | ||
190 | [ | ||
191 | have_linker_option="yes" | ||
192 | EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} -msse2" | ||
193 | ], | ||
194 | [have_linker_option="no"]) | ||
195 | |||
196 | AC_LANG_POP([C]) | ||
197 | CFLAGS=${SAVE_CFLAGS} | ||
198 | |||
199 | AC_MSG_CHECKING([whether sse2 linker option is supported]) | ||
200 | AC_MSG_RESULT([${have_linker_option}]) | ||
201 | fi | ||
202 | |||
203 | AC_SUBST(EFL_SIMD_FLAGS) | ||
204 | |||
205 | if test "x${_efl_build_cpu_sse2}" = "xyes" ; then | ||
206 | AC_DEFINE([EFL_HAVE_SSE2], [1], [Define to mention that SSE2 is supported]) | ||
207 | fi | ||
208 | |||
209 | AS_IF([test "x$_efl_build_cpu_sse2" = "xyes"], [$1], [$2]) | ||
210 | ]) | ||
211 | |||
212 | dnl Usage: EFL_CHECK_CPU_ALTIVEC([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) | ||
213 | dnl Add -faltivec or -maltivec to EFL_SIMD_FLAGS if the compiler supports it and | ||
214 | dnl call AC_SUBST(EFL_SIMD_FLAGS) | ||
215 | dnl Define EFL_HAVE_ALTIVEC | ||
216 | |||
217 | AC_DEFUN([EFL_CHECK_CPU_ALTIVEC], | ||
218 | [ | ||
219 | |||
220 | dnl configure option | ||
221 | |||
222 | AC_ARG_ENABLE([cpu-altivec], | ||
223 | [AC_HELP_STRING([--disable-cpu-altivec], [disable altivec code @<:@default=enabled@:>@])], | ||
224 | [ | ||
225 | if test "x${enableval}" = "xyes" ; then | ||
226 | _efl_enable_cpu_altivec="yes" | ||
227 | else | ||
228 | _efl_enable_cpu_altivec="no" | ||
229 | fi | ||
230 | ], | ||
231 | [_efl_enable_cpu_altivec="yes"] | ||
232 | ) | ||
233 | AC_MSG_CHECKING([whether to build altivec code]) | ||
234 | AC_MSG_RESULT([${_efl_enable_cpu_altivec}]) | ||
235 | |||
236 | dnl check if the CPU is supporting ALTIVEC instruction sets | ||
237 | |||
238 | _efl_build_cpu_altivec="no" | ||
239 | if test "x${_efl_enable_cpu_altivec}" = "xyes" ; then | ||
240 | case $host_cpu in | ||
241 | *power* | *ppc*) | ||
242 | _efl_build_cpu_altivec="yes" | ||
243 | ;; | ||
244 | esac | ||
245 | fi | ||
246 | |||
247 | AC_MSG_CHECKING([whether altivec instructions set is available]) | ||
248 | AC_MSG_RESULT([${_efl_build_cpu_altivec}]) | ||
249 | |||
250 | dnl check if the compiler supports -faltivec or -maltivec and | ||
251 | dnl if altivec.h is available. | ||
252 | |||
253 | _efl_have_faltivec="no" | ||
254 | if test "x${_efl_build_cpu_altivec}" = "xyes" ; then | ||
255 | SAVE_CFLAGS=${CFLAGS} | ||
256 | CFLAGS="-faltivec" | ||
257 | AC_LANG_PUSH([C]) | ||
258 | |||
259 | AC_COMPILE_IFELSE( | ||
260 | [AC_LANG_PROGRAM([[ | ||
261 | #include <altivec.h> | ||
262 | ]], | ||
263 | [[]])], | ||
264 | [_efl_have_faltivec="yes" | ||
265 | _efl_altivec_flag="-faltivec"], | ||
266 | [_efl_have_faltivec="no"]) | ||
267 | |||
268 | if test "x${_efl_have_faltivec}" = "xno" ; then | ||
269 | CFLAGS="-maltivec" | ||
270 | |||
271 | AC_COMPILE_IFELSE( | ||
272 | [AC_LANG_PROGRAM([[ | ||
273 | #include <altivec.h> | ||
274 | ]], | ||
275 | [[]])], | ||
276 | [_efl_have_faltivec="yes" | ||
277 | _efl_altivec_flag="-maltivec"], | ||
278 | [_efl_have_faltivec="no"]) | ||
279 | fi | ||
280 | |||
281 | AC_LANG_POP([C]) | ||
282 | CFLAGS=${SAVE_CFLAGS} | ||
283 | |||
284 | AC_MSG_CHECKING([whether altivec linker option is supported]) | ||
285 | AC_MSG_RESULT([${_efl_have_faltivec}]) | ||
286 | fi | ||
287 | |||
288 | EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} ${_efl_altivec_flag}" | ||
289 | AC_SUBST(EFL_SIMD_FLAGS) | ||
290 | |||
291 | if test "x${_efl_have_faltivec}" = "xyes" ; then | ||
292 | AC_DEFINE([EFL_HAVE_ALTIVEC], [1], [Define to mention that ALTIVEC is supported]) | ||
293 | fi | ||
294 | |||
295 | AS_IF([test "x$_efl_have_faltivec" = "xyes"], [$1], [$2]) | ||
296 | ]) | ||
297 | |||
298 | dnl Usage: EFL_CHECK_CPU_NEON([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) | ||
299 | dnl Add -mneon to EFL_SIMD_FLAGS if the compiler supports it and call AC_SUBST(EFL_SIMD_FLAGS) | ||
300 | dnl Define EFL_HAVE_NEON | ||
301 | |||
302 | AC_DEFUN([EFL_CHECK_CPU_NEON], | ||
303 | [ | ||
304 | dnl configure option | ||
305 | |||
306 | AC_ARG_ENABLE([cpu-neon], | ||
307 | [AC_HELP_STRING([--disable-cpu-neon], [disable neon code @<:@default=enabled@:>@])], | ||
308 | [ | ||
309 | if test "x${enableval}" = "xyes" ; then | ||
310 | _efl_enable_cpu_neon="yes" | ||
311 | else | ||
312 | _efl_enable_cpu_neon="no" | ||
313 | fi | ||
314 | ], | ||
315 | [_efl_enable_cpu_neon="yes"]) | ||
316 | |||
317 | AC_MSG_CHECKING([whether to build neon code]) | ||
318 | AC_MSG_RESULT([${_efl_enable_cpu_neon}]) | ||
319 | |||
320 | dnl check if the CPU is supporting NEON instruction sets | ||
321 | |||
322 | _efl_build_cpu_neon="no" | ||
323 | if test "x${_efl_enable_cpu_neon}" = "xyes" ; then | ||
324 | case $host_cpu in | ||
325 | armv7*) | ||
326 | _efl_build_cpu_neon="yes" | ||
327 | ;; | ||
328 | esac | ||
329 | fi | ||
330 | |||
331 | AC_MSG_CHECKING([whether neon instructions set is available]) | ||
332 | AC_MSG_RESULT([${_efl_build_cpu_neon}]) | ||
333 | |||
334 | if test "x${_efl_build_cpu_neon}" = "xyes" ; then | ||
335 | AC_DEFINE([EFL_HAVE_NEON], [1], [Define to mention that NEON is supported]) | ||
336 | fi | ||
337 | |||
338 | AS_IF([test "x$_efl_build_cpu_neon" = "xyes"], [$1], [$2]) | ||
339 | ]) | ||
340 | |||
341 | dnl End of efl_cpu.m4 | ||