diff options
author | liujisi@google.com <liujisi@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2011-01-13 06:44:11 +0000 |
---|---|---|
committer | liujisi@google.com <liujisi@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2011-01-13 06:44:11 +0000 |
commit | d4a57f1557daba389d4af4d99afdc68a9fd5278a (patch) | |
tree | ddc3f2f9bf941021d592d0c947736361f958abba /m4 | |
parent | 57014ffa525ef16d5001872141c89b453eca7c10 (diff) | |
download | protobuf-d4a57f1557daba389d4af4d99afdc68a9fd5278a.tar.gz protobuf-d4a57f1557daba389d4af4d99afdc68a9fd5278a.tar.bz2 protobuf-d4a57f1557daba389d4af4d99afdc68a9fd5278a.zip |
Fix corner case in acx_pthread.m4 to work with -nostdlib, patch from Kacper Kowalik.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/acx_pthread.m4 | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/m4/acx_pthread.m4 b/m4/acx_pthread.m4 index 2cf20de1..89d42c74 100644 --- a/m4/acx_pthread.m4 +++ b/m4/acx_pthread.m4 @@ -340,6 +340,40 @@ if test "x$acx_pthread_ok" = xyes; then acx_pthread_ok=no fi + AC_MSG_CHECKING([whether what we have so far is sufficient with -nostdlib]) + CFLAGS="-nostdlib $CFLAGS" + # we need c with nostdlib + LIBS="$LIBS -lc" + AC_TRY_LINK([#include <pthread.h>], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], + [done=yes],[done=no]) + + if test "x$done" = xyes; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + + if test x"$done" = xno; then + AC_MSG_CHECKING([whether -lpthread saves the day]) + LIBS="-lpthread $LIBS" + AC_TRY_LINK([#include <pthread.h>], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], + [done=yes],[done=no]) + + if test "x$done" = xyes; then + AC_MSG_RESULT([yes]) + PTHREAD_LIBS="$PTHREAD_LIBS -lpthread" + else + AC_MSG_RESULT([no]) + AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries and -nostdlib]) + fi + fi + CFLAGS="$save_CFLAGS" LIBS="$save_LIBS" CC="$save_CC" |