[vlc-devel] [PATCH] Add detection of POSIX threads via cc -pthread

Rémi Denis-Courmont remi at remlab.net
Mon Oct 17 14:14:55 CEST 2011


On Mon, 17 Oct 2011 06:58:47 -0400, Brad <brad at comstyle.com> wrote:
> The following diff adds detection of POSIX threads linking via
> cc -pthread. This corrects the POSIX threads flag used for OpenBSD.

This patch causes -pthread to be used instead of -lpthread on Linux.

> diff --git a/configure.ac b/configure.ac
> index 212d9fd..5a0a210 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -194,9 +194,9 @@ case "${host_os}" in
>      ;;
>    *bsd*)
>      SYS="${host_os}"
> -    CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
>      case "${host_os}" in
>        freebsd*)
> +        CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
>          CPPFLAGS_save="${CPPFLAGS_save} -I/usr/local/include"
>          CPPFLAGS="${CPPFLAGS_save}"
>          LDFLAGS_save="${LDFLAGS_save} -L/usr/local/lib"
> @@ -721,6 +721,20 @@ if test "${SYS}" != "mingw32" -a "${SYS}" !=
> "mingwce"; then
>    dnl Check for pthreads - borrowed from XMMS
>    THREAD_LIB=error
>    if test "${THREAD_LIB}" = "error"; then
> +    AC_MSG_CHECKING(for pthread_create in -pthread)
> +    save_LDFLAGS="${LDFLAGS}"
> +    LDFLAGS="${LDFLAGS} -pthread"
> +    AC_LINK_IFELSE(
> +      [AC_LANG_PROGRAM(
> +        [[#include <pthread.h>
> +        pthread_t thr;]],
> +        [pthread_create(&thr, NULL, NULL, NULL);])],
> +      [THREAD_LIB="-pthread"
> +       AC_MSG_RESULT(yes)],
> +       [AC_MSG_RESULT(no)])
> +    LDFLAGS="${save_LDFLAGS}"
> +  fi
> +  if test "${THREAD_LIB}" = "error"; then
>      AC_CHECK_LIB(pthread,main,THREAD_LIB="-lpthread")
>    fi
>    if test "${THREAD_LIB}" = "error"; then

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list