--- libpthread-stubs-0.1~orig/configure.ac 2006-11-22 16:51:21.000000000 +0900 +++ libpthread-stubs-0.1/configure.ac 2009-08-07 13:28:16.000000000 +0900 @@ -30,11 +30,78 @@ fi -PKG_CONFIG_LIBS= -AC_CHECK_FUNCS([pthread_self pthread_mutex_init pthread_mutex_destroy pthread_mutex_lock pthread_mutex_unlock pthread_cond_init pthread_cond_destroy pthread_cond_wait pthread_cond_signal pthread_cond_broadcast pthread_equal], - [], [PKG_CONFIG_LIBS='-L${libdir} -lpthread-stubs']) +# CHECK_PTHREAD_STUB(PTHREAD-FUNC,TRYLINK-FUNC-BODY,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) +AC_DEFUN([CHECK_PTHREAD_STUB], +[dnl +AH_TEMPLATE(AS_TR_CPP([HAVE_$1]), [Define to 1 if you have the `$1' function.]) +dnl +AC_CACHE_CHECK([for $1], [ac_cv_func_$1], + [AC_TRY_LINK([#include ], [$2], + [ac_cv_func_$1=yes], + [ac_cv_func_$1=no])]) +if test "x$ac_cv_func_$1" = "xyes"; then +AC_DEFINE(AS_TR_CPP([HAVE_$1])) +m4_default([$3], [:]) +else +m4_default([$4], [:]) +fi +]) + + +lack_stubs= + +CHECK_PTHREAD_STUB([pthread_self], + [(void)pthread_self();], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_equal], + [pthread_t t1,t2; (void)pthread_equal(t1,t2);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_mutex_init], + [pthread_mutex_t m; (void)pthread_mutex_init(&m,(void*)0);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_mutex_destroy], + [pthread_mutex_t m; (void)pthread_mutex_destroy(&m);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_mutex_lock], + [pthread_mutex_t m; (void)pthread_mutex_lock(&m);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_mutex_unlock], + [pthread_mutex_t m; (void)pthread_mutex_unlock(&m);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_cond_init], + [pthread_cond_t c; (void)pthread_cond_init(&c,(void*)0);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_cond_destroy], + [pthread_cond_t c; (void)pthread_cond_destroy(&c);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_cond_wait], + [pthread_cond_t c; pthread_mutex_t m; (void)pthread_cond_wait(&c,&m);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_cond_signal], + [pthread_cond_t c; (void)pthread_cond_signal(&c);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_cond_broadcast], + [pthread_cond_t c; (void)pthread_cond_broadcast(&c);], + [], [lack_stubs=yes]) + + +if test "x$lack_stubs" = "xyes"; then + PKG_CONFIG_LIBS='-L${libdir} -lpthread-stubs' +else + PKG_CONFIG_LIBS='' +fi AC_SUBST([PKG_CONFIG_LIBS]) -AM_CONDITIONAL(BUILD_LIB, test "x$PKG_CONFIG_LIBS" != x) +AM_CONDITIONAL(BUILD_LIB, test "x$lack_stubs" = "xyes") AC_CONFIG_FILES([Makefile pthread-stubs.pc]) AC_OUTPUT