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.
4 dnl Macro that check if several ASM instruction sets are available or not.
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
10 AC_DEFUN([EFL_CHECK_CPU_MMX],
14 AC_ARG_ENABLE([cpu-mmx],
15 [AC_HELP_STRING([--disable-cpu-mmx], [disable mmx code @<:@default=enabled@:>@])],
17 if test "x${enableval}" = "xyes" ; then
18 _efl_enable_cpu_mmx="yes"
20 _efl_enable_cpu_mmx="no"
23 [_efl_enable_cpu_mmx="yes"])
25 AC_MSG_CHECKING([whether to build mmx code])
26 AC_MSG_RESULT([${_efl_enable_cpu_mmx}])
28 dnl check if the CPU is supporting MMX instruction sets
30 _efl_build_cpu_mmx="no"
31 if test "x${_efl_enable_cpu_mmx}" = "xyes" ; then
33 i*86 | x86_64 | amd64)
34 _efl_build_cpu_mmx="yes"
39 AC_MSG_CHECKING([whether mmx instructions set is available])
40 AC_MSG_RESULT([${_efl_build_cpu_mmx}])
42 dnl check if the compiler supports -mmmx
44 if test "x${_efl_build_cpu_mmx}" = "xyes" ; then
50 [AC_LANG_PROGRAM([[]],
53 have_linker_option="yes"
54 EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} -mmmx"],
55 [have_linker_option="no"])
60 AC_MSG_CHECKING([whether mmx linker option is supported])
61 AC_MSG_RESULT([${have_linker_option}])
64 AC_SUBST(EFL_SIMD_FLAGS)
66 if test "x${_efl_build_cpu_mmx}" = "xyes" ; then
67 AC_DEFINE([EFL_HAVE_MMX], [1], [Define to mention that MMX is supported])
70 AS_IF([test "x$_efl_build_cpu_mmx" = "xyes"], [$1], [$2])
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
77 AC_DEFUN([EFL_CHECK_CPU_SSE],
81 AC_ARG_ENABLE([cpu-sse],
82 [AC_HELP_STRING([--disable-cpu-sse], [disable sse code @<:@default=enabled@:>@])],
84 if test "x${enableval}" = "xyes" ; then
85 _efl_enable_cpu_sse="yes"
87 _efl_enable_cpu_sse="no"
90 [_efl_enable_cpu_sse="yes"])
92 AC_MSG_CHECKING([whether to build sse code])
93 AC_MSG_RESULT([${_efl_enable_cpu_sse}])
95 dnl check if the CPU is supporting SSE instruction sets
97 _efl_build_cpu_sse="no"
98 if test "x${_efl_enable_cpu_sse}" = "xyes" ; then
100 i*86 | x86_64 | amd64)
101 _efl_build_cpu_sse="yes"
106 AC_MSG_CHECKING([whether sse instructions set is available])
107 AC_MSG_RESULT([${_efl_build_cpu_sse}])
109 dnl check if the compiler supports -msse
111 if test "x${_efl_build_cpu_sse}" = "xyes" ; then
112 SAVE_CFLAGS=${CFLAGS}
117 [AC_LANG_PROGRAM([[]],
121 have_linker_option="yes"
122 EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} -msse"
124 [have_linker_option="no"])
127 CFLAGS=${SAVE_CFLAGS}
129 AC_MSG_CHECKING([whether sse linker option is supported])
130 AC_MSG_RESULT([${have_linker_option}])
133 AC_SUBST(EFL_SIMD_FLAGS)
135 if test "x${_efl_build_cpu_sse}" = "xyes" ; then
136 AC_DEFINE([EFL_HAVE_SSE], [1], [Define to mention that SSE is supported])
139 AS_IF([test "x$_efl_build_cpu_sse" = "xyes"], [$1], [$2])
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
146 AC_DEFUN([EFL_CHECK_CPU_SSE2],
151 AC_ARG_ENABLE([cpu-sse2],
152 [AC_HELP_STRING([--disable-cpu-sse2], [disable sse2 code @<:@default=enabled@:>@])],
154 if test "x${enableval}" = "xyes" ; then
155 _efl_enable_cpu_sse2="yes"
157 _efl_enable_cpu_sse2="no"
160 [_efl_enable_cpu_sse2="yes"])
162 AC_MSG_CHECKING([whether to build sse2 code])
163 AC_MSG_RESULT([${_efl_enable_cpu_sse2}])
165 dnl check if the CPU is supporting SSE2 instruction sets
167 _efl_build_cpu_sse2="no"
168 if test "x${_efl_enable_cpu_sse2}" = "xyes" ; then
170 i*86 | x86_64 | amd64)
171 _efl_build_cpu_sse2="yes"
176 AC_MSG_CHECKING([whether sse2 instructions set is available])
177 AC_MSG_RESULT([${_efl_build_cpu_sse2}])
179 dnl check if the compiler supports -msse2
181 if test "x${_efl_build_cpu_sse2}" = "xyes" ; then
182 SAVE_CFLAGS=${CFLAGS}
187 [AC_LANG_PROGRAM([[]],
191 have_linker_option="yes"
192 EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} -msse2"
194 [have_linker_option="no"])
197 CFLAGS=${SAVE_CFLAGS}
199 AC_MSG_CHECKING([whether sse2 linker option is supported])
200 AC_MSG_RESULT([${have_linker_option}])
203 AC_SUBST(EFL_SIMD_FLAGS)
205 if test "x${_efl_build_cpu_sse2}" = "xyes" ; then
206 AC_DEFINE([EFL_HAVE_SSE2], [1], [Define to mention that SSE2 is supported])
209 AS_IF([test "x$_efl_build_cpu_sse2" = "xyes"], [$1], [$2])
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
217 AC_DEFUN([EFL_CHECK_CPU_ALTIVEC],
222 AC_ARG_ENABLE([cpu-altivec],
223 [AC_HELP_STRING([--disable-cpu-altivec], [disable altivec code @<:@default=enabled@:>@])],
225 if test "x${enableval}" = "xyes" ; then
226 _efl_enable_cpu_altivec="yes"
228 _efl_enable_cpu_altivec="no"
231 [_efl_enable_cpu_altivec="yes"]
233 AC_MSG_CHECKING([whether to build altivec code])
234 AC_MSG_RESULT([${_efl_enable_cpu_altivec}])
236 dnl check if the CPU is supporting ALTIVEC instruction sets
238 _efl_build_cpu_altivec="no"
239 if test "x${_efl_enable_cpu_altivec}" = "xyes" ; then
242 _efl_build_cpu_altivec="yes"
247 AC_MSG_CHECKING([whether altivec instructions set is available])
248 AC_MSG_RESULT([${_efl_build_cpu_altivec}])
250 dnl check if the compiler supports -faltivec or -maltivec and
251 dnl if altivec.h is available.
253 _efl_have_faltivec="no"
254 if test "x${_efl_build_cpu_altivec}" = "xyes" ; then
255 SAVE_CFLAGS=${CFLAGS}
264 [_efl_have_faltivec="yes"
265 _efl_altivec_flag="-faltivec"],
266 [_efl_have_faltivec="no"])
268 if test "x${_efl_have_faltivec}" = "xno" ; then
276 [_efl_have_faltivec="yes"
277 _efl_altivec_flag="-maltivec"],
278 [_efl_have_faltivec="no"])
282 CFLAGS=${SAVE_CFLAGS}
284 AC_MSG_CHECKING([whether altivec linker option is supported])
285 AC_MSG_RESULT([${_efl_have_faltivec}])
288 EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} ${_efl_altivec_flag}"
289 AC_SUBST(EFL_SIMD_FLAGS)
291 if test "x${_efl_have_faltivec}" = "xyes" ; then
292 AC_DEFINE([EFL_HAVE_ALTIVEC], [1], [Define to mention that ALTIVEC is supported])
295 AS_IF([test "x$_efl_have_faltivec" = "xyes"], [$1], [$2])
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
302 AC_DEFUN([EFL_CHECK_CPU_NEON],
306 AC_ARG_ENABLE([cpu-neon],
307 [AC_HELP_STRING([--disable-cpu-neon], [disable neon code @<:@default=enabled@:>@])],
309 if test "x${enableval}" = "xyes" ; then
310 _efl_enable_cpu_neon="yes"
312 _efl_enable_cpu_neon="no"
315 [_efl_enable_cpu_neon="yes"])
317 AC_MSG_CHECKING([whether to build neon code])
318 AC_MSG_RESULT([${_efl_enable_cpu_neon}])
320 dnl check if the CPU is supporting NEON instruction sets
322 _efl_build_cpu_neon="no"
323 if test "x${_efl_enable_cpu_neon}" = "xyes" ; then
326 _efl_build_cpu_neon="yes"
331 AC_MSG_CHECKING([whether neon instructions set is available])
332 AC_MSG_RESULT([${_efl_build_cpu_neon}])
334 if test "x${_efl_build_cpu_neon}" = "xyes" ; then
335 AC_DEFINE([EFL_HAVE_NEON], [1], [Define to mention that NEON is supported])
338 AS_IF([test "x$_efl_build_cpu_neon" = "xyes"], [$1], [$2])
341 dnl End of efl_cpu.m4