abort when pthread is requested but not found
authorcaro <caro>
Sun, 28 Feb 2010 17:27:38 +0000 (17:27 +0000)
committercaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 28 Feb 2010 17:27:38 +0000 (17:27 +0000)
patch by Albin Tonnerre

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eet@46655 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

m4/efl_binary.m4
m4/efl_pthread.m4

index 0fe85ab..0873256 100644 (file)
@@ -1,7 +1,7 @@
 dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
 dnl That code is public domain and can be freely used or copied.
 
-dnl Macro that check if a binary is built or not
+dnl Macro that checks if a binary is built or not
 
 dnl Usage: EFL_ENABLE_BIN(binary)
 dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being tranformed into _)
@@ -42,3 +42,38 @@ AM_CONDITIONAL(BUILD_[]UP, test "x$have_[]m4_defn([DOWN])" = "xyes")
 AS_IF([test "x$have_[]m4_defn([DOWN])" = "xyes"], [$2], [$3])
 
 ])
+
+dnl Macro that specifies the binary to be used
+
+dnl Usage: EFL_WITH_BIN(binary, package, msg)
+dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being tranformed into _)
+dnl Define with_binary (- is tranformed into _)
+dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being tranformed into _)
+
+AC_DEFUN([EFL_WITH_BIN],
+[
+
+m4_pushdef([UP], m4_translit([[$1]], [-a-z], [_A-Z]))dnl
+m4_pushdef([DOWN], m4_translit([[$1]], [-A-Z], [_a-z]))dnl
+
+AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+AC_MSG_NOTICE([$PKG_CONFIG])
+
+with_[]m4_defn([DOWN])=m4_esyscmd($PKG_CONFIG --variable=prefix $2)/bin/m4_defn([DOWN])
+
+dnl configure option
+
+AC_ARG_WITH([$1],
+   [AC_HELP_STRING([--with-$1-bin=PATH], [specify a specific path to ]DOWN)],
+   [
+    with_[]m4_defn([DOWN])=$withval
+    _efl_msg="( explicitely set)"
+   ])
+
+AC_MSG_NOTICE([$msg: ]m4_defn([DOWN])[$_efl_msg])
+
+AC_SUBST(with_[]m4_defn([DOWN]))
+
+AS_IF([test "x$have_[]m4_defn([DOWN])" = "xyes"], [$4], [$5])
+
+])
index c1f6e7a..e50964f 100644 (file)
@@ -1,11 +1,13 @@
-dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr>
+dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
 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 Macro that check if several pthread library is available or not.
 
-dnl Usage: EFL_CHECK_EFL_CHECK_PTHREAD(want_pthread_spin[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
-dnl Call AC_SUBST(EFL_PTHREAD_FLAGS)
+dnl Usage: EFL_CHECK_PTHREAD(want_pthread_spin[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
+dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
 dnl Define EFL_HAVE_PTHREAD
+dnl Define EFL_HAVE_PTHREAD_SPINLOCK
 
 AC_DEFUN([EFL_CHECK_PTHREAD],
 [
@@ -13,7 +15,7 @@ AC_DEFUN([EFL_CHECK_PTHREAD],
 dnl configure option
 
 AC_ARG_ENABLE([pthread],
-   [AC_HELP_STRING([--disable-pthread], [enable POSIX threads code @<:@default=yes@:>@])],
+   [AC_HELP_STRING([--disable-pthread], [enable POSIX threads code @<:@default=auto@:>@])],
    [
     if test "x${enableval}" = "xyes" ; then
        _efl_enable_pthread="yes"
@@ -21,7 +23,7 @@ AC_ARG_ENABLE([pthread],
        _efl_enable_pthread="no"
     fi
    ],
-   [_efl_enable_pthread="yes"])
+   [_efl_enable_pthread="auto"])
 
 AC_MSG_CHECKING([whether to build POSIX threads code])
 AC_MSG_RESULT([${_efl_enable_pthread}])
@@ -30,7 +32,7 @@ dnl check if the compiler supports pthreads
 
 _efl_have_pthread="no"
 
-if test "x${_efl_enable_pthread}" = "xyes" ; then
+if test "x${_efl_enable_pthread}" = "xyes" || test "x${_efl_enable_pthread}" = "xauto" ; then
 
    AC_COMPILE_IFELSE(
       [AC_LANG_PROGRAM([[
@@ -46,13 +48,16 @@ id = pthread_self();
 fi
 
 AC_MSG_CHECKING([whether system support POSIX threads])
-AC_MSG_RESULT([${_efl_enable_pthread}])
+AC_MSG_RESULT([${_efl_have_pthread}])
+if test "$x{_efl_enable_pthread}" = "xyes" && test "x${_efl_have_pthread}" = "xno"; then
+   AC_MSG_ERROR([pthread support requested but not found.])
+fi
 
 if test "x${_efl_have_pthread}" = "xyes" ; then
    case "$host_os" in
       mingw*)
          EFL_PTHREAD_CFLAGS=""
-         EFL_PTHREAD_LIBS="-lpthreadGCE2"
+         EFL_PTHREAD_LIBS="-lpthreadGC2"
          ;;
       solaris*)
          EFL_PTHREAD_CFLAGS="-mt"
@@ -94,6 +99,9 @@ fi
 
 AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
 AC_MSG_RESULT([${_efl_have_pthread_spinlock}])
+if test "$x{_efl_enable_pthread}" = "xyes" && test "x${_efl_have_pthread_spinlock}" = "xno"; then
+   AC_MSG_ERROR([pthread support requested but spinlocks are not supported])
+fi
 
 if test "x${_efl_have_pthread_spinlock}" = "xyes" ; then
    AC_DEFINE(EFL_HAVE_PTHREAD_SPINLOCK, 1, [Define to mention that POSIX threads spinlocks are supported])