summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-10-15 12:18:47 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-10-15 13:05:47 +0100
commitdac73d260a9b9a848bb97436ad84081c51629511 (patch)
tree192548a3f1708554c056c70f2e9b8ea002f662ba
parentef9286751d8346ecb803bfb5916581ee4dfc84db (diff)
[build] Link against pthread-stubs
Avoid pulling in the real pthread library if the application is single threaded and not using pthreads, by linking against pthread-stubs instead.
-rw-r--r--build/configure.ac.features1
-rw-r--r--configure.ac8
-rw-r--r--src/cairo-mutex-impl-private.h2
-rw-r--r--test/Makefile.am4
-rw-r--r--test/cairo-test-trace.c10
-rw-r--r--test/cairo-test.c6
-rw-r--r--util/cairo-trace/Makefile.am2
7 files changed, 22 insertions, 11 deletions
diff --git a/build/configure.ac.features b/build/configure.ac.features
index b3b7b851..e057e2c8 100644
--- a/build/configure.ac.features
+++ b/build/configure.ac.features
@@ -399,6 +399,7 @@ AC_DEFUN([CAIRO_REPORT],
echo " cairo-script-interpreter: $use_interpreter"
echo ""
echo "And the following internal features:"
+ echo " pthread: $use_pthread"
echo " gtk-doc: $enable_gtk_doc"
echo " gcov support: $use_gcov"
echo " symbol-lookup: $use_symbol_lookup"
diff --git a/configure.ac b/configure.ac
index c38d2c49..12a56ad5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -485,7 +485,13 @@ AC_ARG_ENABLE(pthread,
have_pthread=no
if test "x$use_pthread" != "xno"; then
- AC_CHECK_HEADERS([pthread.h], have_pthread=yes, have_pthread=no)
+ pthread_REQUIRES="pthread-stubs"
+ PKG_CHECK_MODULES(pthread, $pthread_REQUIRES,
+ [use_pthread=yes; have_pthread=yes],
+ [AC_CHECK_HEADERS([pthread.h], [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
fi
AM_CONDITIONAL(HAVE_PTHREAD, test "x$have_pthread" = "xyes")
if test "x$have_pthread" = xno -a "x$use_pthread" = xyes; then
diff --git a/src/cairo-mutex-impl-private.h b/src/cairo-mutex-impl-private.h
index f601db93..06938b5a 100644
--- a/src/cairo-mutex-impl-private.h
+++ b/src/cairo-mutex-impl-private.h
@@ -216,7 +216,7 @@
# define CAIRO_MUTEX_IMPL_FINI(mutex) delete (mutex)
# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER NULL
-#elif HAVE_PTHREAD_H /* and finally if there are no native mutexes ********/
+#elif CAIRO_HAS_PTHREAD /* and finally if there are no native mutexes ********/
# include <pthread.h>
diff --git a/test/Makefile.am b/test/Makefile.am
index 28909177..a6e8be32 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -77,6 +77,7 @@ cairo_test_suite_SOURCES = \
$(cairo_test_suite_headers) \
$(test_sources) \
cairo-test-constructors.c
+cairo_test_suite_CFLAGS = $(AM_CFLAGS)
cairo_test_suite_LDADD = \
$(top_builddir)/test/pdiff/libpdiff.la \
$(top_builddir)/boilerplate/libcairoboilerplate.la \
@@ -91,6 +92,7 @@ cairo_test_suite_DEPENDENCIES += \
any2ppm
endif
if HAVE_PTHREAD
+cairo_test_suite_CFLAGS += -pthread
cairo_test_suite_LDADD += -lpthread
endif
@@ -100,6 +102,7 @@ cairo_test_trace_SOURCES = \
cairo-test-trace.c \
buffer-diff.c \
buffer-diff.h
+cairo_test_trace_CFLAGS = $(AM_CFLAGS)
cairo_test_trace_LDADD = \
$(top_builddir)/test/pdiff/libpdiff.la \
$(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
@@ -108,6 +111,7 @@ cairo_test_trace_LDADD = \
$(CAIRO_LDADD) \
$(SHM_LIBS)
if HAVE_PTHREAD
+cairo_test_trace_CFLAGS += -pthread
cairo_test_trace_LDADD += -lpthread
endif
cairo_test_trace_DEPENDENCIES = \
diff --git a/test/cairo-test-trace.c b/test/cairo-test-trace.c
index 1d12f53d..2401d171 100644
--- a/test/cairo-test-trace.c
+++ b/test/cairo-test-trace.c
@@ -82,7 +82,7 @@
#include <sys/un.h>
#include <errno.h>
#include <assert.h>
-#if HAVE_PTHREAD_H
+#if CAIRO_HAS_PTHREAD
#include <pthread.h>
#endif
@@ -162,7 +162,7 @@ struct surface_tag {
};
static const cairo_user_data_key_t surface_tag;
-#if HAVE_PTHREAD_H
+#if CAIRO_HAS_PTHREAD
#define tr_die(t) t->is_meta ? pthread_exit(NULL) : exit(1)
#else
#define tr_die(t) exit(1)
@@ -245,7 +245,7 @@ send_meta_surface (test_runner_t *tr,
int width, int height,
struct context_closure *closure)
{
-#if HAVE_PTHREAD_H
+#if CAIRO_HAS_PTHREAD
const struct request_image rq = {
closure->id,
closure->start_line,
@@ -591,7 +591,7 @@ spawn_target (const char *socket_path,
exit (0);
}
-#if HAVE_PTHREAD_H
+#if CAIRO_HAS_PTHREAD
static void
cleanup_recorder (void *arg)
{
@@ -1274,7 +1274,7 @@ _test_trace (test_trace_t *test,
s = slaves = xcalloc (2*test->num_targets + 1, sizeof (struct slave));
-#if HAVE_PTHREAD_H
+#if CAIRO_HAS_PTHREAD
/* set-up a meta-surface to reconstruct errors */
slave = spawn_recorder (socket_path, trace);
if (slave < 0) {
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 72288656..edc9ae57 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -47,7 +47,7 @@
#if HAVE_FCFINI
#include <fontconfig/fontconfig.h>
#endif
-#if HAVE_PTHREAD_H
+#if CAIRO_HAS_PTHREAD
#include <pthread.h>
#endif
#if HAVE_SYS_STAT_H
@@ -1785,7 +1785,7 @@ _cairo_test_context_run (cairo_test_context_t *ctx)
return ret;
}
-#if HAVE_PTHREAD_H
+#if CAIRO_HAS_PTHREAD
typedef struct _cairo_test_thread {
pthread_t thread;
cairo_test_context_t *ctx;
@@ -1820,7 +1820,7 @@ cairo_test_expecting (const cairo_test_t *test)
_cairo_test_init (&ctx, NULL, test, test->name);
printf ("%s\n", test->description);
-#if HAVE_PTHREAD_H
+#if CAIRO_HAS_PTHREAD
num_threads = 0;
if (getenv ("CAIRO_TEST_NUM_THREADS"))
num_threads = atoi (getenv ("CAIRO_TEST_NUM_THREADS"));
diff --git a/util/cairo-trace/Makefile.am b/util/cairo-trace/Makefile.am
index 814a0f00..5b6e781a 100644
--- a/util/cairo-trace/Makefile.am
+++ b/util/cairo-trace/Makefile.am
@@ -13,7 +13,7 @@ cairo_trace_la_CPPFLAGS = -DCAIRO_TRACE_OUTDIR="\"$(cairooutdir)\"" \
cairo_trace_la_CFLAGS = $(CAIRO_CFLAGS)
cairo_trace_la_LDFLAGS = -module -no-undefined
-cairo_trace_la_LIBADD = -lz
+cairo_trace_la_LIBADD = -lz $(pthread_LIBS)
if CAIRO_HAS_DL
cairo_trace_la_LIBADD += -ldl
endif