--- libpthread-stubs-0.1~orig/configure.ac 2006-11-22 16:51:21.000000000 +0900 +++ libpthread-stubs-0.1/configure.ac 2009-08-06 19:31:38.000000000 +0900 @@ -30,11 +30,81 @@ 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,POSSIBLE-SYMBOLS,TRYLINK-FUNC-BODY,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) +AC_DEFUN([CHECK_PTHREAD_STUB], +[dnl +have_stub__$1= +if test "x$have_stub__$1" = x; then + AC_CHECK_FUNCS([$2], [have_stub__$1=yes]) +fi +if test "x$have_stub__$1" = x; then + AC_MSG_CHECKING([for $1]) + AC_TRY_LINK([#include ], [$3], + [AC_MSG_RESULT([yes]); have_stub__$1=yes], + [AC_MSG_RESULT([no])]) +fi +if test "x$have_stub__$1" = "xyes"; then +m4_default([$4], [:]) +else +m4_default([$5], [:]) +fi +]) + + +lack_stubs= + +CHECK_PTHREAD_STUB([pthread_self], [pthread_self __libc_thr_self], + [(void)pthread_self();], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_equal], [pthread_equal __libc_thr_equal], + [pthread_t t1,t2; (void)pthread_equal(t1,t2);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_mutex_init], [pthread_mutex_init __libc_mutex_init], + [pthread_mutex_t m; (void)pthread_mutex_init(&m,(void*)0);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_mutex_destroy], [pthread_mutex_destroy __libc_mutex_destroy], + [pthread_mutex_t m; (void)pthread_mutex_destroy(&m);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_mutex_lock], [pthread_mutex_lock __libc_mutex_lock], + [pthread_mutex_t m; (void)pthread_mutex_lock(&m);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_mutex_unlock], [pthread_mutex_unlock __libc_mutex_unlock], + [pthread_mutex_t m; (void)pthread_mutex_unlock(&m);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_cond_init], [pthread_cond_init __libc_cond_init], + [pthread_cond_t c; (void)pthread_cond_init(&c,(void*)0);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_cond_destroy], [pthread_cond_destroy __libc_cond_destroy], + [pthread_cond_t c; (void)pthread_cond_destroy(&c);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_cond_wait], [pthread_cond_wait __libc_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_signal __libc_cond_signal], + [pthread_cond_t c; (void)pthread_cond_signal(&c);], + [], [lack_stubs=yes]) + +CHECK_PTHREAD_STUB([pthread_cond_broadcast], [pthread_cond_broadcast __libc_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