From 89d5e6f07332af1f34efad33c13119a928d68628 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 3 Oct 2008 15:28:13 +0000 Subject: [PATCH] * add detection of SIMD and thread support * minor formatting SVN revision: 36418 --- legacy/eina/configure.ac | 24 ++- legacy/eina/m4/efl_benchmark.m4 | 14 +- legacy/eina/m4/efl_coverage.m4 | 22 +-- legacy/eina/m4/efl_cpu.m4 | 288 ++++++++++++++++++++++++++++++++ legacy/eina/m4/efl_pthread.m4 | 67 ++++++++ legacy/eina/m4/efl_tests.m4 | 18 +- 6 files changed, 403 insertions(+), 30 deletions(-) create mode 100644 legacy/eina/m4/efl_cpu.m4 create mode 100644 legacy/eina/m4/efl_pthread.m4 diff --git a/legacy/eina/configure.ac b/legacy/eina/configure.ac index 405120c19d..3d4774609e 100644 --- a/legacy/eina/configure.ac +++ b/legacy/eina/configure.ac @@ -1,8 +1,8 @@ # get rid of that stupid cache mechanism rm -f config.cache -AC_INIT(eina, 0.0.1, enlightenment-devel@lists.sourceforge.net) -AC_PREREQ(2.52) +AC_INIT([eina], [0.0.1], [enlightenment-devel@lists.sourceforge.net]) +AC_PREREQ([2.60]) AC_CONFIG_SRCDIR(configure.ac) AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -31,6 +31,13 @@ MODULE_ARCH="$host_os-$host_cpu" AC_SUBST(MODULE_ARCH) AC_DEFINE_UNQUOTED(MODULE_ARCH, "${MODULE_ARCH}", "Module architecture") +EFL_CHECK_CPU_MMX([have_mmx="yes"], [have_mmx="no"]) +EFL_CHECK_CPU_SSE([have_sse="yes"], [have_sse="no"]) +EFL_CHECK_CPU_SSE2([have_sse2="yes"], [have_sse2="no"]) +EFL_CHECK_CPU_ALTIVEC([have_altivec="yes"], [have_altivec="no"]) + +EFL_CHECK_PTHREAD([have_pthread="yes"], [have_pthread="no"]) + ### Additional options to configure @@ -195,8 +202,9 @@ AM_CONDITIONAL(EINA_BUILD_DOC, test "x${build_doc}" = "xyes") ### Checks for compiler characteristics AC_C_CONST AC_C_BIGENDIAN -AC_PROG_CC_STDC +AC_C_INLINE AC_C___ATTRIBUTE__ +AC_PROG_CC_STDC EINA_CFLAGS="${EFL_COVERAGE_CFLAGS}" case "${host_os}" in @@ -302,6 +310,16 @@ echo " Evas...............: ${have_evas}" echo " Ecore..............: ${have_ecore}" echo " E17 real data......: ${enable_benchmark_e17}" fi +echo +echo "CPU Specific Extensions:" +echo +echo " MMX..................: ${have_mmx}" +echo " SSE..................: ${have_sse}" +echo " SSE2.................: ${have_sse2}" +echo " ALTIVEC..............: ${have_altivec}" +echo +echo " Thread Support.......: ${have_pthread}" +echo echo " Magic debug..........: ${enable_magic_debug}" echo echo " Memory pool:" diff --git a/legacy/eina/m4/efl_benchmark.m4 b/legacy/eina/m4/efl_benchmark.m4 index 2711d4cb88..9e968c44d8 100644 --- a/legacy/eina/m4/efl_benchmark.m4 +++ b/legacy/eina/m4/efl_benchmark.m4 @@ -15,21 +15,21 @@ AC_ARG_ENABLE([benchmark], [AC_HELP_STRING([--enable-benchmark], [enable tests @<:@default=no@:>@])], [ if test "x${enableval}" = "xyes" ; then - _eina_enable_benchmark="yes" + _efl_enable_benchmark="yes" else - _eina_enable_benchmark="no" + _efl_enable_benchmark="no" fi ], - [_eina_enable_benchmark="no"] + [_efl_enable_benchmark="no"] ) AC_MSG_CHECKING([whether benchmark are built]) -AC_MSG_RESULT([${_eina_enable_benchmark}]) +AC_MSG_RESULT([${_efl_enable_benchmark}]) -AM_CONDITIONAL(EFL_ENABLE_BENCHMARK, test "x${_eina_enable_benchmark}" = "xyes") +AM_CONDITIONAL(EFL_ENABLE_BENCHMARK, test "x${_efl_enable_benchmark}" = "xyes") -if test "x${_eina_enable_benchmark}" = "xyes" ; then +if test "x${_efl_enable_benchmark}" = "xyes" ; then ifelse([$1], , :, [$1]) else ifelse([$2], , :, [$2]) fi -]) \ No newline at end of file +]) diff --git a/legacy/eina/m4/efl_coverage.m4 b/legacy/eina/m4/efl_coverage.m4 index e8feaf2d84..1618f76fee 100644 --- a/legacy/eina/m4/efl_coverage.m4 +++ b/legacy/eina/m4/efl_coverage.m4 @@ -19,25 +19,25 @@ AC_ARG_ENABLE([coverage], [AC_HELP_STRING([--enable-coverage], [compile with coverage profiling instrumentation @<:@default=no@:>@])], [ if test "x${enableval}" = "xyes" ; then - _eina_enable_coverage="yes" + _efl_enable_coverage="yes" else - _eina_enable_coverage="no" + _efl_enable_coverage="no" fi ], - [_eina_enable_coverage="no"] + [_efl_enable_coverage="no"] ) AC_MSG_CHECKING([whether to use profiling instrumentation]) -AC_MSG_RESULT([$_eina_enable_coverage]) +AC_MSG_RESULT([$_efl_enable_coverage]) dnl lcov check -if test ! "x$1" = "xyes" -a "x$_eina_enable_coverage" = "xyes" ; then +if test ! "x$1" = "xyes" -a "x$_efl_enable_coverage" = "xyes" ; then AC_MSG_WARN([Coverage report requested but tests not being built, disable profiling instrumentation.]) AC_MSG_WARN([Run configure with --enable-tests]) - _eina_enable_coverage="no" + _efl_enable_coverage="no" fi -if test "x$_eina_enable_coverage" = "xyes" ; then +if test "x$_efl_enable_coverage" = "xyes" ; then AC_CHECK_PROG(have_lcov, [lcov], [yes], [no]) if test "x$have_lcov" = "xyes" ; then EFL_COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage" @@ -46,7 +46,7 @@ if test "x$_eina_enable_coverage" = "xyes" ; then EFL_DEBUG_CFLAGS="-g -O0 -DDEBUG" else AC_MSG_WARN([lcov is not found, disable profiling instrumentation]) - _eina_enable_coverage="no" + _efl_enable_coverage="no" fi fi @@ -54,11 +54,11 @@ dnl Substitution AC_SUBST(EFL_COVERAGE_CFLAGS) AC_SUBST(EFL_COVERAGE_LIBS) -AM_CONDITIONAL(EFL_ENABLE_COVERAGE, test "x${_eina_enable_coverage}" = "xyes") +AM_CONDITIONAL(EFL_ENABLE_COVERAGE, test "x${_efl_enable_coverage}" = "xyes") -if test "x${_eina_enable_coverage}" = "xyes" ; then +if test "x${_efl_enable_coverage}" = "xyes" ; then ifelse([$2], , :, [$2]) else ifelse([$3], , :, [$3]) fi -]) \ No newline at end of file +]) diff --git a/legacy/eina/m4/efl_cpu.m4 b/legacy/eina/m4/efl_cpu.m4 new file mode 100644 index 0000000000..28ee5a510e --- /dev/null +++ b/legacy/eina/m4/efl_cpu.m4 @@ -0,0 +1,288 @@ +dnl Copyright (C) 2008 Vincent Torri +dnl That code is public domain and can be freely used or copied. + +dnl Macro that check if several ASM instruction sets are available or not. + +dnl Usage: EFL_CHECK_CPU_MMX([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Add -mmmx to EFL_SIMD_FLAGS if the compiler supports it and call AC_SUBST(EFL_SIMD_FLAGS) +dnl Define EFL_HAVE_MMX + +AC_DEFUN([EFL_CHECK_CPU_MMX], +[ + +dnl configure option + +AC_ARG_ENABLE([cpu-mmx], + [AC_HELP_STRING([--enable-cpu-mmx], [enable mmx code @<:@default=yes@:>@])], + [ + if test "x${enableval}" = "xyes" ; then + _efl_enable_cpu_mmx="yes" + else + _efl_enable_cpu_mmx="no" + fi + ], + [_efl_enable_cpu_mmx="yes"] +) +AC_MSG_CHECKING([whether to build mmx code]) +AC_MSG_RESULT([${_efl_enable_cpu_mmx}]) + +dnl check if the CPU is supporting MMX instruction sets + +_efl_build_cpu_mmx="no" +if test "x${_efl_enable_cpu_mmx}" = "xyes" ; then +case $host_cpu in + i*86) + _efl_build_cpu_mmx="yes" + ;; + x86_64) + _efl_build_cpu_mmx="yes" + ;; +esac +fi + +dnl check if the compiler supports -mmmx + +SAVE_CFLAGS=${CFLAGS} +CFLAGS="-mmmx" +AC_LANG_PUSH([C]) + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], + [[]]) + ], + [EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} -mmmx"] +) + +AC_LANG_POP([C]) +CFLAGS=${SAVE_CFLAGS} + +AC_SUBST(EFL_SIMD_FLAGS) + +if test "x${_efl_build_cpu_mmx}" = "xyes" ; then + AC_DEFINE(EFL_HAVE_MMX, 1, [Define to mention that MMX is supported]) +fi + +if test "x${_efl_build_cpu_mmx}" = "xyes" ; then + ifelse([$1], , :, [$1]) +else + ifelse([$2], , :, [$2]) +fi +]) + +dnl Usage: EFL_CHECK_CPU_SSE([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Add -msse to EFL_SIMD_FLAGS if the compiler supports it and call AC_SUBST(EFL_SIMD_FLAGS) +dnl Define EFL_HAVE_SSE + +AC_DEFUN([EFL_CHECK_CPU_SSE], +[ + +dnl configure option + +AC_ARG_ENABLE([cpu-sse], + [AC_HELP_STRING([--enable-cpu-sse], [enable sse code @<:@default=yes@:>@])], + [ + if test "x${enableval}" = "xyes" ; then + _efl_enable_cpu_sse="yes" + else + _efl_enable_cpu_sse="no" + fi + ], + [_efl_enable_cpu_sse="yes"] +) +AC_MSG_CHECKING([whether to build sse code]) +AC_MSG_RESULT([${_efl_enable_cpu_sse}]) + +dnl check if the CPU is supporting SSE instruction sets + +_efl_build_cpu_sse="no" +if test "x${_efl_enable_cpu_sse}" = "xyes" ; then +case $host_cpu in + i*86) + _efl_build_cpu_sse="yes" + ;; + x86_64) + _efl_build_cpu_sse="yes" + ;; +esac +fi + +dnl check if the compiler supports -msse + +SAVE_CFLAGS=${CFLAGS} +CFLAGS="-msse" +AC_LANG_PUSH([C]) + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], + [[]]) + ], + [EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} -msse"] +) + +AC_LANG_POP([C]) +CFLAGS=${SAVE_CFLAGS} + +AC_SUBST(EFL_SIMD_FLAGS) + +if test "x${_efl_build_cpu_sse}" = "xyes" ; then + AC_DEFINE(EFL_HAVE_SSE, 1, [Define to mention that SSE is supported]) +fi + +if test "x${_efl_build_cpu_sse}" = "xyes" ; then + ifelse([$1], , :, [$1]) +else + ifelse([$2], , :, [$2]) +fi +]) + +dnl Usage: EFL_CHECK_CPU_SSE2([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Add -msse2 to EFL_SIMD_FLAGS if the compiler supports it and call AC_SUBST(EFL_SIMD_FLAGS) +dnl Define EFL_HAVE_SSE2 + +AC_DEFUN([EFL_CHECK_CPU_SSE2], +[ + +dnl configure option + +AC_ARG_ENABLE([cpu-sse2], + [AC_HELP_STRING([--enable-cpu-sse2], [enable sse2 code @<:@default=yes@:>@])], + [ + if test "x${enableval}" = "xyes" ; then + _efl_enable_cpu_sse2="yes" + else + _efl_enable_cpu_sse2="no" + fi + ], + [_efl_enable_cpu_sse2="yes"] +) +AC_MSG_CHECKING([whether to build sse2 code]) +AC_MSG_RESULT([${_efl_enable_cpu_sse2}]) + +dnl check if the CPU is supporting SSE2 instruction sets + +_efl_build_cpu_sse2="no" +if test "x${_efl_enable_cpu_sse2}" = "xyes" ; then +case $host_cpu in + i686) + _efl_build_cpu_sse2="yes" + ;; + x86_64) + _efl_build_cpu_sse2="yes" + ;; +esac +fi + +dnl check if the compiler supports -msse2 + +SAVE_CFLAGS=${CFLAGS} +CFLAGS="-msse2" +AC_LANG_PUSH([C]) + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], + [[]]) + ], + [EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} -msse2"] +) + +AC_LANG_POP([C]) +CFLAGS=${SAVE_CFLAGS} + +AC_SUBST(EFL_SIMD_FLAGS) + +if test "x${_efl_build_cpu_sse2}" = "xyes" ; then + AC_DEFINE(EFL_HAVE_SSE2, 1, [Define to mention that SSE2 is supported]) +fi + +if test "x${_efl_build_cpu_sse2}" = "xyes" ; then + ifelse([$1], , :, [$1]) +else + ifelse([$2], , :, [$2]) +fi +]) + +dnl Usage: EFL_CHECK_CPU_ALTIVEC([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Add -faltivec or -maltivec to EFL_SIMD_FLAGS if the compiler supports it and +dnl call AC_SUBST(EFL_SIMD_FLAGS) +dnl Define EFL_HAVE_ALTIVEC + +AC_DEFUN([EFL_CHECK_CPU_ALTIVEC], +[ + +dnl configure option + +AC_ARG_ENABLE([cpu-altivec], + [AC_HELP_STRING([--enable-cpu-altivec], [enable altivec code @<:@default=yes@:>@])], + [ + if test "x${enableval}" = "xyes" ; then + _efl_enable_cpu_altivec="yes" + else + _efl_enable_cpu_altivec="no" + fi + ], + [_efl_enable_cpu_altivec="yes"] +) +AC_MSG_CHECKING([whether to build altivec code]) +AC_MSG_RESULT([${_efl_enable_cpu_altivec}]) + +dnl check if the CPU is supporting ALTIVEC instruction sets + +_efl_build_cpu_altivec="no" +if test "x${_efl_enable_cpu_altivec}" = "xyes" ; then +case $host_cpu in + *power* | *ppc*) + _efl_build_cpu_altivec="yes" + ;; +esac +fi + +dnl check if the compiler supports -faltivec or -maltivec and +dnl if altivec.h is available. + +SAVE_CFLAGS=${CFLAGS} +CFLAGS="-faltivec" +AC_LANG_PUSH([C]) + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +#include + ]], + [[]])], + [_efl_have_faltivec="yes" + _efl_altivec_flag="-faltivec"], + [_efl_have_faltivec="no"] +) + +if test "x${_efl_have_faltivec}" = "xno" ; then + CFLAGS="-maltivec" + + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +#include + ]], + [[]])], + [_efl_have_faltivec="yes" + _efl_altivec_flag="-maltivec"], + [_efl_have_faltivec="no"] + ) +fi + +AC_MSG_CHECKING([whether altivec code is supported]) +AC_MSG_RESULT([${_efl_have_faltivec}]) + +AC_LANG_POP([C]) +CFLAGS=${SAVE_CFLAGS} + +EFL_SIMD_FLAGS="${EFL_SIMD_FLAGS} ${_efl_altivec_flag}" +AC_SUBST(EFL_SIMD_FLAGS) + +if test "x${_efl_have_faltivec}" = "xyes" ; then + AC_DEFINE(EFL_HAVE_ALTIVEC, 1, [Define to mention that ALTIVEC is supported]) +fi + +if test "x${_efl_have_faltivec}" = "xyes" ; then + ifelse([$1], , :, [$1]) +else + ifelse([$2], , :, [$2]) +fi +]) diff --git a/legacy/eina/m4/efl_pthread.m4 b/legacy/eina/m4/efl_pthread.m4 new file mode 100644 index 0000000000..172acef9ab --- /dev/null +++ b/legacy/eina/m4/efl_pthread.m4 @@ -0,0 +1,67 @@ +dnl Copyright (C) 2008 Vincent Torri +dnl That code is public domain and can be freely used or copied. + +dnl Macro that check if several ASM instruction sets are available or not. + +dnl Usage: EFL_CHECK_EFL_CHECK_PTHREAD([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Call AC_SUBST(EFL_PTHREAD_FLAGS) +dnl Define EFL_HAVE_PTHREAD + +AC_DEFUN([EFL_CHECK_PTHREAD], +[ + +dnl configure option + +AC_ARG_ENABLE([pthread], + [AC_HELP_STRING([--enable-pthread], [enable POSIX threads code @<:@default=no@:>@])], + [ + if test "x${enableval}" = "xyes" ; then + _efl_enable_pthread="yes" + else + _efl_enable_pthread="no" + fi + ], + [_efl_enable_pthread="no"] +) +AC_MSG_CHECKING([whether to build POSIX threads code]) +AC_MSG_RESULT([${_efl_enable_pthread}]) + +dnl check if the compiler supports pthreads + +_efl_have_pthread="no" + +if test "x${_efl_enable_pthread}" = "xyes" ; then + + SAVE_CFLAGS=${CFLAGS} + CFLAGS="-pthread" + AC_LANG_PUSH([C]) + + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +#include + ]], + [[]]) + ], + [_efl_have_pthread="yes" + EFL_PTHREAD_FLAGS="-pthread"] + ) + + AC_LANG_POP([C]) + CFLAGS=${SAVE_CFLAGS} +fi + +AC_MSG_CHECKING([whether POSIX threads are supported]) +AC_MSG_RESULT([${_efl_have_pthread}]) + +AC_SUBST(EFL_PTHREAD_FLAGS) + +if test "x${_efl_have_pthread}" = "xyes" ; then + AC_DEFINE(EFL_HAVE_PTHREAD, 1, [Define to mention that POSIX threads are supported]) +fi + +if test "x${_efl_have_pthread}" = "xyes" ; then + ifelse([$1], , :, [$1]) +else + ifelse([$2], , :, [$2]) +fi +]) diff --git a/legacy/eina/m4/efl_tests.m4 b/legacy/eina/m4/efl_tests.m4 index ca145f227e..3478b54a16 100644 --- a/legacy/eina/m4/efl_tests.m4 +++ b/legacy/eina/m4/efl_tests.m4 @@ -16,29 +16,29 @@ AC_ARG_ENABLE([tests], [AC_HELP_STRING([--enable-tests], [enable tests @<:@default=no@:>@])], [ if test "x${enableval}" = "xyes" ; then - _eina_enable_tests="yes" + _efl_enable_tests="yes" else - _eina_enable_tests="no" + _efl_enable_tests="no" fi ], - [_eina_enable_tests="no"] + [_efl_enable_tests="no"] ) AC_MSG_CHECKING([whether tests are built]) -AC_MSG_RESULT([${_eina_enable_tests}]) +AC_MSG_RESULT([${_efl_enable_tests}]) -if test "x${_eina_enable_tests}" = "xyes" ; then +if test "x${_efl_enable_tests}" = "xyes" ; then PKG_CHECK_MODULES([CHECK], [check >= 0.9.5], [dummy="yes"], - [_eina_enable_tests="no"] + [_efl_enable_tests="no"] ) fi -AM_CONDITIONAL(EFL_ENABLE_TESTS, test "x${_eina_enable_tests}" = "xyes") +AM_CONDITIONAL(EFL_ENABLE_TESTS, test "x${_efl_enable_tests}" = "xyes") -if test "x${_eina_enable_tests}" = "xyes" ; then +if test "x${_efl_enable_tests}" = "xyes" ; then ifelse([$1], , :, [$1]) else ifelse([$2], , :, [$2]) fi -]) \ No newline at end of file +])