Add more efl m4 macros
Signed-off-by: Chris Michael <devilhorns@comcast.net>
This commit is contained in:
parent
7e9bc95162
commit
6e217d768f
|
@ -0,0 +1,83 @@
|
|||
dnl Copyright (C) 2011 Vincent Torri <vtorri at univ-evry dot fr>
|
||||
dnl That code is public domain and can be freely used or copied.
|
||||
|
||||
dnl Macros for checking if the compiler supports some __attribute__ uses
|
||||
|
||||
dnl Usage: EFL_ATTRIBUTE_VECTOR
|
||||
dnl call AC_DEFINE for HAVE_GCC_ATTRIBUTE_VECTOR if __attribute__((vector)) is available
|
||||
|
||||
AC_DEFUN([EFL_ATTRIBUTE_VECTOR],
|
||||
[
|
||||
AC_MSG_CHECKING([for __attribute__ ((vector))])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
typedef int v4si __attribute__ ((vector_size (16)));
|
||||
]],
|
||||
[[
|
||||
if (sizeof(v4si) == 16)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
]])],
|
||||
[have_attribute_vector="yes"],
|
||||
[have_attribute_vector="no"])
|
||||
AC_MSG_RESULT([${have_attribute_vector}])
|
||||
|
||||
if test "x${have_attribute_vector}" = "xyes" ; then
|
||||
AC_DEFINE([HAVE_GCC_ATTRIBUTE_VECTOR], [1], [Define to 1 if your compiler supports __attribute__ ((vector)).])
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Usage: EFL_ATTRIBUTE_ALWAYS_INLINE
|
||||
dnl call AC_DEFINE for alway_inline if __attribute__((always_inline)) is available
|
||||
|
||||
AC_DEFUN([EFL_ATTRIBUTE_ALWAYS_INLINE],
|
||||
[
|
||||
|
||||
have_attribute_forceinline="no"
|
||||
|
||||
AC_MSG_CHECKING([for __forceinline])
|
||||
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
#include <windows.h>
|
||||
static __forceinline void foo(void) {}
|
||||
]],
|
||||
[[
|
||||
]])],
|
||||
[
|
||||
have_attribute_always_inline="yes"
|
||||
have_attribute_forceinline="yes"
|
||||
],
|
||||
[have_attribute_always_inline="no"])
|
||||
|
||||
AC_MSG_RESULT([${have_attribute_always_inline}])
|
||||
|
||||
if test "x${have_attribute_always_inline}" = "xno" ; then
|
||||
AC_MSG_CHECKING([for __attribute__ ((__always_inline__))])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
static __attribute__((__always_inline__)) inline void foo(void) {}
|
||||
]],
|
||||
[[
|
||||
]])],
|
||||
[have_attribute_always_inline="yes"],
|
||||
[have_attribute_always_inline="no"])
|
||||
AC_MSG_RESULT([${have_attribute_always_inline}])
|
||||
fi
|
||||
|
||||
if test "x${have_attribute_always_inline}" = "xyes" ; then
|
||||
if test "x${have_attribute_forceinline}" = "xyes" ; then
|
||||
AC_DEFINE([EFL_ALWAYS_INLINE], [__forceinline], [Macro declaring a function to always be inlined.])
|
||||
else
|
||||
AC_DEFINE([EFL_ALWAYS_INLINE], [__attribute__ ((__always_inline__)) inline], [Macro declaring a function to always be inlined.])
|
||||
fi
|
||||
else
|
||||
AC_DEFINE([EFL_ALWAYS_INLINE], [static inline], [Macro declaring a function to always be inlined.])
|
||||
fi
|
||||
])
|
||||
|
||||
dnl End of efl_attribute.m4
|
|
@ -0,0 +1,90 @@
|
|||
dnl Copyright (C) 2012 Vincent Torri <vincent dot torri at gmail dot com>
|
||||
dnl This code is public domain and can be freely used or copied.
|
||||
|
||||
dnl Macro that check if compiler of linker flags are available
|
||||
|
||||
|
||||
dnl Macro that checks for a compiler flag availability
|
||||
dnl
|
||||
dnl _EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS)
|
||||
dnl AC_SUBST : EFL_CFLAGS (EFL being replaced by its value)
|
||||
dnl have_flag: yes or no.
|
||||
AC_DEFUN([_EFL_CHECK_COMPILER_FLAGS],
|
||||
[dnl
|
||||
m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
|
||||
|
||||
dnl store in options -Wfoo if -Wno-foo is passed
|
||||
option="m4_bpatsubst([[$2]], [-Wno-], [-W])"
|
||||
CFLAGS_save="${CFLAGS}"
|
||||
CFLAGS="${CFLAGS} ${option}"
|
||||
AC_LANG_PUSH([C])
|
||||
|
||||
AC_MSG_CHECKING([whether the compiler supports $2])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[]])],
|
||||
[have_flag="yes"],
|
||||
[have_flag="no"])
|
||||
AC_MSG_RESULT([${have_flag}])
|
||||
|
||||
AC_LANG_POP([C])
|
||||
CFLAGS="${CFLAGS_save}"
|
||||
if test "x${have_flag}" = "xyes" ; then
|
||||
UPEFL[_CFLAGS]="${UPEFL[_CFLAGS]} [$2]"
|
||||
fi
|
||||
AC_SUBST(UPEFL[_CFLAGS])dnl
|
||||
m4_popdef([UPEFL])dnl
|
||||
])
|
||||
|
||||
dnl EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS)
|
||||
dnl Checks if FLAGS are supported and add to EFL_CLFAGS.
|
||||
dnl
|
||||
dnl It will first try every flag at once, if one fails will try them one by one.
|
||||
AC_DEFUN([EFL_CHECK_COMPILER_FLAGS],
|
||||
[dnl
|
||||
_EFL_CHECK_COMPILER_FLAGS([$1], [$2])
|
||||
if test "${have_flag}" != "yes"; then
|
||||
m4_foreach_w([flag], [$2], [_EFL_CHECK_COMPILER_FLAGS([$1], m4_defn([flag]))])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl Macro that checks for a linker flag availability
|
||||
dnl
|
||||
dnl _EFL_CHECK_LINKER_FLAGS(EFL, FLAGS)
|
||||
dnl AC_SUBST : EFL_LDFLAGS (EFL being replaced by its value)
|
||||
dnl have_flag: yes or no
|
||||
AC_DEFUN([_EFL_CHECK_LINKER_FLAGS],
|
||||
[dnl
|
||||
m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
|
||||
|
||||
LDFLAGS_save="${LDFLAGS}"
|
||||
LDFLAGS="${LDFLAGS} $2"
|
||||
AC_LANG_PUSH([C])
|
||||
|
||||
AC_MSG_CHECKING([whether the linker supports $2])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[]])],
|
||||
[have_flag="yes"],
|
||||
[have_flag="no"])
|
||||
AC_MSG_RESULT([${have_flag}])
|
||||
|
||||
AC_LANG_POP([C])
|
||||
LDFLAGS="${LDFLAGS_save}"
|
||||
if test "x${have_flag}" = "xyes" ; then
|
||||
UPEFL[_LDFLAGS]="${UPEFL[_LDFLAGS]} [$2]"
|
||||
fi
|
||||
AC_SUBST(UPEFL[_LDFLAGS])dnl
|
||||
m4_popdef([UPEFL])dnl
|
||||
])
|
||||
|
||||
dnl EFL_CHECK_LINKER_FLAGS(EFL, FLAGS)
|
||||
dnl Checks if FLAGS are supported and add to EFL_CLFAGS.
|
||||
dnl
|
||||
dnl It will first try every flag at once, if one fails will try them one by one.
|
||||
AC_DEFUN([EFL_CHECK_LINKER_FLAGS],
|
||||
[dnl
|
||||
_EFL_CHECK_LINKER_FLAGS([$1], [$2])
|
||||
if test "${have_flag}" != "yes"; then
|
||||
m4_foreach_w([flag], [$2], [_EFL_CHECK_LINKER_FLAGS([$1], m4_defn([flag]))])
|
||||
fi
|
||||
])dnl
|
|
@ -0,0 +1,132 @@
|
|||
dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
|
||||
dnl rwlock code added by Mike Blumenkrantz <mike at zentific dot com>
|
||||
dnl This code is public domain and can be freely used or copied.
|
||||
|
||||
dnl Macro that check if POSIX or Win32 threads library is available or not.
|
||||
|
||||
dnl Usage: EFL_CHECK_THREADS(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
|
||||
dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
|
||||
dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
|
||||
dnl Defines EFL_HAVE_POSIX_THREADS or EFL_HAVE_WIN32_THREADS, and EFL_HAVE_THREADS
|
||||
|
||||
AC_DEFUN([EFL_CHECK_THREADS],
|
||||
[
|
||||
|
||||
dnl Generic thread detection
|
||||
|
||||
EFL_PTHREAD_CFLAGS="-D_REENTRANT"
|
||||
EFL_PTHREAD_LIBS=""
|
||||
|
||||
_efl_have_posix_threads="no"
|
||||
_efl_have_win32_threads="no"
|
||||
|
||||
dnl Use generic infrastructure for pthread detection (What a hell of a mess !)
|
||||
gl_LOCK
|
||||
|
||||
AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
|
||||
|
||||
case "$host_os" in
|
||||
mingw*)
|
||||
_efl_have_win32_threads="yes"
|
||||
efl_have_setaffinity="yes"
|
||||
AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
|
||||
;;
|
||||
*)
|
||||
_efl_have_posix_threads="${gl_use_threads}"
|
||||
AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl System specific CFLAGS
|
||||
if test "x${_efl_have_posix_threads}" = "xyes"; then
|
||||
case "$host_os" in
|
||||
osf*) EFL_PTHREAD_CFLAGS="-D_REENTRANT" ;;
|
||||
aix* | freebsd*) EFL_PTHREAD_CFLAGS="-D_THREAD_SAFE" ;;
|
||||
solaris*) EFL_PTHREAD_CFLAGS="-D_REENTRANT" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
dnl check if the compiler supports POSIX threads
|
||||
if test "x${_efl_have_posix_threads}" = "xyes" ; then
|
||||
|
||||
SAVE_LIBS=${LIBS}
|
||||
LIBS="${LIBS} ${LIBMULTITHREAD}"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#include <pthread.h>
|
||||
]],
|
||||
[[
|
||||
pthread_barrier_t barrier;
|
||||
pthread_barrier_init(&barrier, NULL, 1);
|
||||
]])],
|
||||
[efl_have_pthread_barrier="yes"],
|
||||
[efl_have_pthread_barrier="no"])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
]],
|
||||
[[
|
||||
pthread_attr_setaffinity_np(NULL, 0, NULL);
|
||||
]])],
|
||||
[efl_have_setaffinity="yes"],
|
||||
[efl_have_setaffinity="no"])
|
||||
LIBS=${SAVE_LIBS}
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([which threads API is used])
|
||||
if test "x${_efl_have_posix_threads}" = "xyes" ; then
|
||||
efl_have_threads="POSIX"
|
||||
else
|
||||
if test "x${_efl_have_win32_threads}" = "xyes" ; then
|
||||
efl_have_threads="Windows"
|
||||
efl_have_pthread_barrier="no"
|
||||
else
|
||||
efl_have_threads="no"
|
||||
efl_have_pthread_barrier="no"
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT([${efl_have_threads}])
|
||||
|
||||
EFL_PTHREAD_LIBS="${LTLIBMULTITHREAD}"
|
||||
|
||||
AC_SUBST(EFL_PTHREAD_CFLAGS)
|
||||
AC_SUBST(EFL_PTHREAD_LIBS)
|
||||
|
||||
dnl check if the compiler supports pthreads spinlock
|
||||
|
||||
efl_have_posix_threads_spinlock="no"
|
||||
|
||||
if test "x${_efl_have_posix_threads}" = "xyes" ; then
|
||||
SAVE_LIBS=${LIBS}
|
||||
LIBS="${LIBS} ${LIBMULTITHREAD}"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
]],
|
||||
[[
|
||||
pthread_spinlock_t lock;
|
||||
int res;
|
||||
res = pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
|
||||
sched_yield();
|
||||
]])],
|
||||
[efl_have_posix_threads_spinlock="yes"],
|
||||
[efl_have_posix_threads_spinlock="no"])
|
||||
LIBS=${SAVE_LIBS}
|
||||
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
|
||||
AC_MSG_RESULT([${efl_have_posix_threads_spinlock}])
|
||||
|
||||
if test "x${efl_have_posix_threads_spinlock}" = "xyes" ; then
|
||||
AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported])
|
||||
fi
|
||||
|
||||
AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"],
|
||||
[$1],
|
||||
[m4_if([$2], [$2], [AC_MSG_ERROR([Threads are required.])])])
|
||||
|
||||
])
|
Loading…
Reference in New Issue