Update pthreads configure test to work on more platforms.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5661 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2007-02-05 18:39:27 +00:00
parent 1c61b1297d
commit 47fb93aa3c
3 changed files with 26 additions and 15 deletions

View File

@ -540,29 +540,40 @@ AC_EXEEXT
dnl Check for pthreads for multi-threaded apps...
have_pthread=no
PTHREAD_FLAGS=""
if test "x$enable_threads" = xyes; then
AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
AC_CHECK_FUNC(pthread_create,
have_pthread=yes,
[AC_CHECK_LIB(pthread, pthread_create)
if test "x$ac_cv_lib_pthread_pthread_create" = xyes -a x$ac_cv_header_pthread_h = xyes; then
have_pthread=yes
else
dnl *BSD uses -pthread option...
AC_MSG_CHECKING([for pthread_create using -pthread])
if test x$ac_cv_header_pthread_h = xyes; then
dnl Check various threading options for the platforms we support
for flag in -lpthreads -lpthread -pthread; do
AC_MSG_CHECKING([for pthread_create using $flag])
SAVELIBS="$LIBS"
LIBS="-pthread $LIBS"
LIBS="$flag $LIBS"
AC_TRY_LINK([#include <pthread.h>],
[pthread_create(0, 0, 0, 0);],
LIBS="-pthread $SAVELIBS"
have_pthread=yes,
LIBS="$SAVELIBS")
AC_MSG_RESULT([$have_pthread])
fi])
if test $have_pthread = yes; then
AC_DEFINE(HAVE_PTHREAD)
PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
# Solaris requires -D_POSIX_PTHREAD_SEMANTICS to
# be POSIX-compliant... :(
if test $uname = SunOS; then
PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
fi
break
fi
done
fi
fi
AC_SUBST(PTHREAD_FLAGS)
dnl Define OS-specific stuff...
HLINKS=
POSTBUILD=:

View File

@ -54,8 +54,8 @@ POSTBUILD="@POSTBUILD@"
# flags for C++ compiler:
ARCHFLAGS="@ARCHFLAGS@"
CFLAGS="@CFLAGS@ @LARGEFILE@"
CXXFLAGS="@CXXFLAGS@ @LARGEFILE@"
CFLAGS="@CFLAGS@ @LARGEFILE@ @PTHREAD_FLAGS@"
CXXFLAGS="@CXXFLAGS@ @LARGEFILE@ @PTHREAD_FLAGS@"
LDFLAGS="@LDFLAGS@"
LDLIBS="@LIBS@"

View File

@ -56,8 +56,8 @@ MAKEDEPEND = @MAKEDEPEND@
# flags for C++ compiler:
ARCHFLAGS = @ARCHFLAGS@
OPTIM = @OPTIM@
CFLAGS = $(OPTIM) @LARGEFILE@ @CPPFLAGS@ @CFLAGS@
CXXFLAGS = $(OPTIM) @LARGEFILE@ @CPPFLAGS@ @CXXFLAGS@
CFLAGS = $(OPTIM) @LARGEFILE@ @PTHREAD_FLAGS@ @CPPFLAGS@ @CFLAGS@
CXXFLAGS = $(OPTIM) @LARGEFILE@ @PTHREAD_FLAGS@ @CPPFLAGS@ @CXXFLAGS@
# program to make the archive:
LIBNAME = @LIBNAME@