From 129ca450c29ba22014e10fc534fba8083bacceab Mon Sep 17 00:00:00 2001 From: Paolo Borelli Date: Mon, 31 Aug 2009 12:56:13 +0200 Subject: [PATCH] [build] properly link with pthread --- configure.ac | 7 ++++++- src/Makefile.am | 2 +- test/Makefile.am | 14 +++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index d1b105e..3d70403 100644 --- a/configure.ac +++ b/configure.ac @@ -471,12 +471,17 @@ 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) + AC_CHECK_HEADERS([pthread.h], + [AC_CHECK_LIB(pthread, pthread_mutex_init, + [PTHREAD_LIBS="-lpthread"; have_pthreads="yes"], + [PTHREAD_LIBS=""])], + have_pthread=no) 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]) fi +AC_SUBST(PTHREAD_LIBS) dnl =========================================================================== diff --git a/src/Makefile.am b/src/Makefile.am index dce2a08..a77fc5c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,7 @@ libcairo_la_SOURCES = \ $(enabled_cairo_sources) \ $(NULL) libcairo_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(CAIRO_LIBTOOL_VERSION_INFO) -no-undefined $(export_symbols) -libcairo_la_LIBADD = $(CAIRO_LIBS) +libcairo_la_LIBADD = $(PTHREAD_LIBS) $(CAIRO_LIBS) libcairo_la_DEPENDENCIES = $(cairo_def_dependency) # Special headers diff --git a/test/Makefile.am b/test/Makefile.am index 4ac776f..919e3f4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -79,6 +79,7 @@ cairo_test_suite_LDADD = \ $(top_builddir)/test/pdiff/libpdiff.la \ $(top_builddir)/boilerplate/libcairoboilerplate.la \ $(top_builddir)/src/libcairo.la \ + $(PTHREAD_LIBS) \ $(CAIRO_LDADD) cairo_test_suite_DEPENDENCIES = \ $(top_builddir)/test/pdiff/libpdiff.la \ @@ -88,9 +89,6 @@ if BUILD_ANY2PPM cairo_test_suite_DEPENDENCIES += \ any2ppm endif -if HAVE_PTHREAD -cairo_test_suite_LDADD += -lpthread -endif if HAVE_SHM EXTRA_PROGRAMS += cairo-test-trace @@ -101,13 +99,11 @@ cairo_test_trace_SOURCES = \ cairo_test_trace_LDADD = \ $(top_builddir)/test/pdiff/libpdiff.la \ $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \ - $(top_builddir)/boilerplate/libcairoboilerplate.la \ + $(top_builddir)/boilerplate/libcairoboilerplate.la \ $(top_builddir)/src/libcairo.la \ - $(CAIRO_LDADD) \ - $(SHM_LIBS) -if HAVE_PTHREAD -cairo_test_trace_LDADD += -lpthread -endif + $(PTHREAD_LIBS) \ + $(SHM_LIBS) \ + $(CAIRO_LDADD) cairo_test_trace_DEPENDENCIES = \ $(top_builddir)/test/pdiff/libpdiff.la \ $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \ -- 1.6.2.5