The compiler flag "-pthread" is hard-coded in the makefiles.
GCC isn't consistent about that on all platforms -- e.g., it uses
"-pthreads" on Solaris (which is why I noticed), so I borrowed the
required configury from apr.
This patch:
- adds an acinclude.m4 with tests for pthreads switches and
libraries;
- uses those tests in configure.in;
- removes explicit "CFLAGS = -pthread" from Makefile.am in
libsvn_string/tests, libsvn_subr/tests and libsvn_wc/tests.
--
Branko Čibej <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
voice: (+386 1) 586 53 49 fax: (+386 1) 586 52 70
Index: configure.in
===================================================================
RCS file: /cvs/subversion/configure.in,v
retrieving revision 1.14
diff -u -p -r1.14 configure.in
--- configure.in 2000/08/08 20:54:54 1.14
+++ configure.in 2000/08/08 22:13:25
@@ -62,6 +62,16 @@ dnl AC_PROG_RANLIB
dnl Check for libtool -- we'll definitely need it for all our shared libs!
AM_PROG_LIBTOOL
+dnl Check for pthreads flags
+AC_SUBST(PTHREAD_FLAGS)
+AC_SUBST(PTHREAD_LIBS)
+REENTRANCY_FLAGS
+PTHREADS_CHECK
+if test "$pthreads_working" = "yes"; then
+ AC_MSG_RESULT($threads_result)
+else
+ AC_MSG_ERROR($threads_result)
+fi
dnl Check for libraries --------------------
Index: subversion/libsvn_string/tests/Makefile.am
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_string/tests/Makefile.am,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.am
--- subversion/libsvn_string/tests/Makefile.am 2000/08/08 18:14:54 1.4
+++ subversion/libsvn_string/tests/Makefile.am 2000/08/08 22:05:00
@@ -4,7 +4,6 @@ noinst_PROGRAMS = stringtest
stringtest_SOURCES = stringtest.c
## Flags needed when compiling:
-CFLAGS = -pthread
INCLUDES = -I../../include -I../../../apr/include
## Libraries this binary depends upon:
Index: subversion/libsvn_subr/tests/Makefile.am
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_subr/tests/Makefile.am,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile.am
--- subversion/libsvn_subr/tests/Makefile.am 2000/08/08 18:14:57 1.3
+++ subversion/libsvn_subr/tests/Makefile.am 2000/08/08 22:05:00
@@ -4,7 +4,6 @@ noinst_PROGRAMS = hashdump-test
hashdump_test_SOURCES = hashdump-test.c
## Flags needed when compiling:
-CFLAGS = -pthread
INCLUDES = -I../../include -I../../../apr/include
## Libraries this binary depends upon:
Index: subversion/libsvn_wc/tests/Makefile.am
===================================================================
RCS file: /cvs/subversion/subversion/libsvn_wc/tests/Makefile.am,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.am
--- subversion/libsvn_wc/tests/Makefile.am 2000/08/08 18:15:00 1.4
+++ subversion/libsvn_wc/tests/Makefile.am 2000/08/08 22:05:00
@@ -4,7 +4,6 @@ noinst_PROGRAMS = checkout-test
checkout_test_SOURCES = checkout-test.c
## Flags needed when compiling:
-CFLAGS = -pthread
INCLUDES = -I../../include -I../../../apr/include -I../../../expat-lite
## Libraries this binary depends upon:
dnl
dnl Check for flags required to activate pthreads.
dnl This bit is borrowed from apr/apr_common.m4, for now.
dnl
dnl
dnl REENTRANCY_FLAGS
dnl
dnl Set some magic defines
dnl
AC_DEFUN(REENTRANCY_FLAGS,[
case "$host_alias" in
*solaris*)
PTHREAD_FLAGS="-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT";;
*freebsd*)
PTHREAD_FLAGS="-D_REENTRANT -D_THREAD_SAFE";;
*openbsd*)
PTHREAD_FLAGS="-D_POSIX_THREADS";;
*linux*)
PTHREAD_FLAGS="-D_REENTRANT";;
*aix*)
PTHREAD_FLAGS="-D_THREAD_SAFE";;
*irix*)
PTHREAD_FLAGS="-D_POSIX_THREAD_SAFE_FUNCTIONS";;
*hpux*)
PTHREAD_FLAGS="-D_REENTRANT";;
*sco*)
PTHREAD_FLAGS="-D_REENTRANT";;
dnl Solves sigwait() problem, creates problems with u_long etc.
dnl PTHREAD_FLAGS="-D_REENTRANT -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506 -D_XOPEN_SOURCE_EXTENDED=1";;
esac
if test -n "$PTHREAD_FLAGS"; then
CPPFLAGS="$CPPFLAGS $PTHREAD_FLAGS"
fi
])dnl
dnl
dnl PTHREADS_CHECK_COMPILE
dnl
dnl Check whether the current setup can use POSIX threads calls
dnl
AC_DEFUN(PTHREADS_CHECK_COMPILE, [
AC_TRY_RUN( [
#include <pthread.h>
#include <stddef.h>
void *thread_routine(void *data) {
return data;
}
int main() {
pthread_t thd;
pthread_mutexattr_t mattr;
int data = 1;
pthread_mutexattr_init(&mattr);
return pthread_create(&thd, NULL, thread_routine, &data);
} ], [
pthreads_working="yes"
], [
pthreads_working="no"
], pthreads_working="no" ) ] )dnl
dnl
dnl PTHREADS_CHECK()
dnl
dnl Try to find a way to enable POSIX threads
dnl
AC_DEFUN(PTHREADS_CHECK,[
if test -n "$ac_cv_pthreads_lib"; then
LIBS="$LIBS -l$ac_cv_pthreads_lib"
fi
if test -n "$ac_cv_pthreads_cflags"; then
CFLAGS="$CFLAGS $ac_cv_pthreads_cflags"
fi
PTHREADS_CHECK_COMPILE
AC_CACHE_CHECK(for pthreads_cflags,ac_cv_pthreads_cflags,[
ac_cv_pthreads_cflags=""
if test "$pthreads_working" != "yes"; then
for flag in -kthread -pthread -pthreads -mthreads -Kthread -threads -mt; do
ac_save="$CFLAGS"
CFLAGS="$CFLAGS $flag"
PTHREADS_CHECK_COMPILE
if test "$pthreads_working" = "yes"; then
ac_cv_pthreads_cflags="$flag"
break
fi
CFLAGS="$ac_save"
done
fi
])
AC_CACHE_CHECK(for pthreads_lib, ac_cv_pthreads_lib,[
ac_cv_pthreads_lib=""
if test "$pthreads_working" != "yes"; then
for lib in pthread pthreads c_r; do
ac_save="$LIBS"
LIBS="$LIBS -l$lib"
PTHREADS_CHECK_COMPILE
if test "$pthreads_working" = "yes"; then
ac_cv_pthreads_lib="$lib"
break
fi
LIBS="$ac_save"
done
fi
])
if test "$pthreads_working" = "yes"; then
threads_result="POSIX Threads found"
else
threads_result="POSIX Threads not found"
fi
])dnl
Received on Sat Oct 21 14:36:06 2006