From 62b1bb0c213c37b58e5a7bb8359f41168c34f817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Thu, 22 Mar 2007 20:44:58 +0000 Subject: Fix crosscompile to use build and host definition from autoconf, rather than using hacksaround. Also replace the whole pthread check with an improved macro originally written for XCB, this way it's not going to try linking the fake -lpthread on Darwin, and it also does not force a -I/usr/local/include on FreeBSD. The new macro respects the same variables set by ports, so that it's even more transparent to FreeBSD users. CVS patchset: 8739 CVS date: 2007/03/22 20:44:58 --- m4/Makefile.am | 3 ++- m4/pthreads.m4 | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 m4/pthreads.m4 (limited to 'm4') diff --git a/m4/Makefile.am b/m4/Makefile.am index 8f6fcc85d..d78fb6a88 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -31,4 +31,5 @@ EXTRA_DIST = glibc2.m4 intdiv0.m4 intmax.m4 inttypes.m4 inttypes_h.m4 inttypes-p progtest.m4 \ xine.m4 \ _xine.m4 \ - xv.m4 + xv.m4 \ + pthreads.m4 diff --git a/m4/pthreads.m4 b/m4/pthreads.m4 new file mode 100644 index 000000000..28d72dd4f --- /dev/null +++ b/m4/pthreads.m4 @@ -0,0 +1,59 @@ +dnl Detection of the Pthread implementation flags and libraries +dnl Diego Pettenò 2006-11-03 +dnl +dnl CC_PTHREAD_FLAGS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl This macro checks for the Pthread flags to use to build +dnl with support for PTHREAD_LIBS and PTHREAD_CFLAGS variables +dnl used in FreeBSD ports. +dnl +dnl This macro is released as public domain, but please mail +dnl to flameeyes@gmail.com if you want to add support for a +dnl new case, or if you're going to use it, so that there will +dnl always be a version available. +AC_DEFUN([CC_PTHREAD_FLAGS], [ + AC_REQUIRE([CC_CHECK_WERROR]) + AC_ARG_VAR([PTHREAD_CFLAGS], [C compiler flags for Pthread support]) + AC_ARG_VAR([PTHREAD_LIBS], [linker flags for Pthread support]) + + dnl if PTHREAD_* are not set, default to -pthread (GCC) + if test "${PTHREAD_CFLAGS-unset}" = "unset"; then + case $host in + *-hpux11*) PTHREAD_CFLAGS="" ;; + *-darwin*) PTHREAD_CFLAGS="" ;; + *) PTHREAD_CFLAGS="-pthread" ;; + esac + fi + if test "${PTHREAD_LIBS-unset}" = "unset"; then + case $host in + *-hpux11*) PTHREAD_LIBS="-lpthread" ;; + *-darwin*) PTHREAD_LIBS="" ;; + *) PTHREAD_LIBS="-pthread" ;; + esac + fi + + AC_CACHE_CHECK([if $CC supports Pthread], + AS_TR_SH([cc_cv_pthreads]), + [ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $cc_cv_werror $PTHREAD_CFLAGS" + LIBS="$LIBS $PTHREAD_LIBS" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[pthread_create(NULL, NULL, NULL, NULL);]] + )], + [cc_cv_pthreads=yes], + [cc_cv_pthreads=no]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + ]) + + AC_SUBST([PTHREAD_LIBS]) + AC_SUBST([PTHREAD_CFLAGS]) + + if test x$cc_cv_pthreads = xyes; then + ifelse([$1], , [:], [$1]) + else + ifelse([$2], , [:], [$2]) + fi +]) -- cgit v1.2.3