path: root/
diff options
authorM Joonas Pihlaja <>2010-06-27 03:03:17 +0300
committerM Joonas Pihlaja <>2010-07-11 21:40:26 +0300
commitfca8977219b857e2e61dd86ac39ae9f40086f306 (patch)
treea4c13879aa27adf0f3b1c936b973051bee2ed078 /
parent47c35e5e86a3c99fc39afe2e13a7c92d5247ee1e (diff)
build: Rework pthread detection.
Use two levels of pthread support: a minimal level used to build cairo itself, and a full level to build threaded apps which want to use cairo. The minimal level tries to use pthread stubs from libc if possible, but falls back to the full level if that's not possible. We use CFLAGS=-D_REENTRANT LIBS=-lpthread to find a real pthread library since that seems to work on every unix-like test box we can get our hands on.
Diffstat (limited to '')
1 files changed, 19 insertions, 28 deletions
diff --git a/ b/
index ee592249a..cb66294db 100644
--- a/
+++ b/
@@ -28,37 +28,11 @@ m4_include(build/ dnl checks for compiler warning
m4_include(build/ dnl checks for system functions, headers, libs
m4_include(build/ dnl checks for analysis tools (lcov, etc)
m4_include(build/ dnl disable builtin libtool versioning
+m4_include(build/ dnl checks for pthreads
dnl ===========================================================================
- AS_HELP_STRING([--disable-pthread],
- [Do not use pthread]),
- [use_pthread=$enableval], [use_pthread=auto])
-if test "x$use_pthread" != "xno"; then
- pthread_REQUIRES="pthread"
- [use_pthread=yes; have_pthread=yes],
- [AX_PTHREAD([use_pthread=yes;
- have_pthread=yes
- ], [use_pthread="no (requires $pthread_REQUIRES)"])])
- if test "x$have_pthread" = "xyes"; then
- AC_DEFINE([CAIRO_HAS_PTHREAD], 1, [Define to 1 if we have pthread support])
- fi
-AM_CONDITIONAL(HAVE_PTHREAD, test "x$have_pthread" = "xyes")
-if test "x$have_pthread" = xno -a "x$use_pthread" = xyes; then
- AC_MSG_ERROR([pthread requested but not found])
-dnl ===========================================================================
AC_CHECK_LIB(z, compress,
[AC_CHECK_HEADER(zlib.h, [
@@ -662,6 +636,22 @@ dnl ===========================================================================
CAIRO_ENABLE_FONT_BACKEND(user, user, always)
dnl ===========================================================================
+dnl This needs to be last on our list of features so that the pthread libs and flags
+dnl gets prefixed in front of everything else in CAIRO_{CFLAGS,LIBS}.
+CAIRO_ENABLE(pthread, pthread, auto, [CAIRO_CONFIGURE_PTHREAD])
+AM_CONDITIONAL(HAVE_REAL_PTHREAD, test "x$use_pthread" = "xyes" -a "x$have_real_pthread" = "xyes")
+AM_CONDITIONAL(HAVE_PTHREAD, test "x$use_pthread" = "xyes")
+dnl ===========================================================================
dnl Default to quick testing during development, but force a full test before
dnl release
@@ -715,8 +705,9 @@ esac
CAIRO_ENABLE(trace, cairo-trace, auto, [
if test "x$have_ld_preload" != "xyes" -o \
"x$have_libz" != "xyes" -o \
+ "x$have_real_pthread" != "xyes" -o \
"x$have_dlsym" != "xyes"; then
- use_trace="no (requires dynamic linker and zlib)"
+ use_trace="no (requires dynamic linker and zlib and real pthreads)"