version 1.1, 2012/02/21 22:57:49
|
version 1.1.1.2, 2012/05/29 09:29:44
|
Line 1
|
Line 1
|
# threadlib.m4 serial 3 (gettext-0.18) | # threadlib.m4 serial 8 (gettext-0.18.2) |
dnl Copyright (C) 2005-2009 Free Software Foundation, Inc. | dnl Copyright (C) 2005-2011 Free Software Foundation, Inc. |
dnl This file is free software; the Free Software Foundation |
dnl This file is free software; the Free Software Foundation |
dnl gives unlimited permission to copy and/or distribute it, |
dnl gives unlimited permission to copy and/or distribute it, |
dnl with or without modifications, as long as this notice is preserved. |
dnl with or without modifications, as long as this notice is preserved. |
Line 9 dnl From Bruno Haible.
|
Line 9 dnl From Bruno Haible.
|
dnl gl_THREADLIB |
dnl gl_THREADLIB |
dnl ------------ |
dnl ------------ |
dnl Tests for a multithreading library to be used. |
dnl Tests for a multithreading library to be used. |
|
dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO |
|
dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the |
|
dnl default is 'no', otherwise it is system dependent. In both cases, the user |
|
dnl can change the choice through the options --enable-threads=choice or |
|
dnl --disable-threads. |
dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, |
dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, |
dnl USE_PTH_THREADS, USE_WIN32_THREADS |
dnl USE_PTH_THREADS, USE_WIN32_THREADS |
dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use |
dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use |
Line 44 AC_DEFUN([gl_THREADLIB_EARLY_BODY],
|
Line 49 AC_DEFUN([gl_THREADLIB_EARLY_BODY],
|
[AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], |
[AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], |
[AC_REQUIRE([AC_GNU_SOURCE])]) |
[AC_REQUIRE([AC_GNU_SOURCE])]) |
dnl Check for multithreading. |
dnl Check for multithreading. |
m4_divert_text([DEFAULTS], [gl_use_threads_default=]) | m4_ifdef([gl_THREADLIB_DEFAULT_NO], |
| [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], |
| [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) |
AC_ARG_ENABLE([threads], |
AC_ARG_ENABLE([threads], |
AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API]) | AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ |
AC_HELP_STRING([--disable-threads], [build without multithread safety]), | AC_HELP_STRING([--disable-threads], [build without multithread safety])]), |
[gl_use_threads=$enableval], |
[gl_use_threads=$enableval], |
[if test -n "$gl_use_threads_default"; then |
[if test -n "$gl_use_threads_default"; then |
gl_use_threads="$gl_use_threads_default" |
gl_use_threads="$gl_use_threads_default" |
else |
else |
|
changequote(,)dnl |
case "$host_os" in |
case "$host_os" in |
dnl Disable multithreading by default on OSF/1, because it interferes |
dnl Disable multithreading by default on OSF/1, because it interferes |
dnl with fork()/exec(): When msgexec is linked with -lpthread, its |
dnl with fork()/exec(): When msgexec is linked with -lpthread, its |
dnl child process gets an endless segmentation fault inside execvp(). |
dnl child process gets an endless segmentation fault inside execvp(). |
|
dnl Disable multithreading by default on Cygwin 1.5.x, because it has |
|
dnl bugs that lead to endless loops or crashes. See |
|
dnl <http://cygwin.com/ml/cygwin/2009-08/msg00283.html>. |
osf*) gl_use_threads=no ;; |
osf*) gl_use_threads=no ;; |
|
cygwin*) |
|
case `uname -r` in |
|
1.[0-5].*) gl_use_threads=no ;; |
|
*) gl_use_threads=yes ;; |
|
esac |
|
;; |
*) gl_use_threads=yes ;; |
*) gl_use_threads=yes ;; |
esac |
esac |
|
changequote([,])dnl |
fi |
fi |
]) |
]) |
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then |
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then |
Line 69 AC_HELP_STRING([--disable-threads], [build without mul
|
Line 87 AC_HELP_STRING([--disable-threads], [build without mul
|
# groks <pthread.h>. cc also understands the flag -pthread, but |
# groks <pthread.h>. cc also understands the flag -pthread, but |
# we don't use it because 1. gcc-2.95 doesn't understand -pthread, |
# we don't use it because 1. gcc-2.95 doesn't understand -pthread, |
# 2. putting a flag into CPPFLAGS that has an effect on the linker |
# 2. putting a flag into CPPFLAGS that has an effect on the linker |
# causes the AC_TRY_LINK test below to succeed unexpectedly, | # causes the AC_LINK_IFELSE test below to succeed unexpectedly, |
# leading to wrong values of LIBTHREAD and LTLIBTHREAD. |
# leading to wrong values of LIBTHREAD and LTLIBTHREAD. |
CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
;; |
;; |
Line 96 AC_DEFUN([gl_THREADLIB_BODY],
|
Line 114 AC_DEFUN([gl_THREADLIB_BODY],
|
LTLIBMULTITHREAD= |
LTLIBMULTITHREAD= |
if test "$gl_use_threads" != no; then |
if test "$gl_use_threads" != no; then |
dnl Check whether the compiler and linker support weak declarations. |
dnl Check whether the compiler and linker support weak declarations. |
AC_MSG_CHECKING([whether imported symbols can be declared weak]) | AC_CACHE_CHECK([whether imported symbols can be declared weak], |
gl_have_weak=no | [gl_cv_have_weak], |
AC_TRY_LINK([extern void xyzzy (); | [gl_cv_have_weak=no |
#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes]) | dnl First, test whether the compiler accepts it syntactically. |
AC_MSG_RESULT([$gl_have_weak]) | AC_LINK_IFELSE( |
| [AC_LANG_PROGRAM( |
| [[extern void xyzzy (); |
| #pragma weak xyzzy]], |
| [[xyzzy();]])], |
| [gl_cv_have_weak=maybe]) |
| if test $gl_cv_have_weak = maybe; then |
| dnl Second, test whether it actually works. On Cygwin 1.7.2, with |
| dnl gcc 4.3, symbols declared weak always evaluate to the address 0. |
| AC_RUN_IFELSE( |
| [AC_LANG_SOURCE([[ |
| #include <stdio.h> |
| #pragma weak fputs |
| int main () |
| { |
| return (fputs == NULL); |
| }]])], |
| [gl_cv_have_weak=yes], |
| [gl_cv_have_weak=no], |
| [dnl When cross-compiling, assume that only ELF platforms support |
| dnl weak symbols. |
| AC_EGREP_CPP([Extensible Linking Format], |
| [#ifdef __ELF__ |
| Extensible Linking Format |
| #endif |
| ], |
| [gl_cv_have_weak="guessing yes"], |
| [gl_cv_have_weak="guessing no"]) |
| ]) |
| fi |
| ]) |
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then |
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then |
# On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that |
# On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that |
# it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY. |
# it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY. |
Line 114 AC_DEFUN([gl_THREADLIB_BODY],
|
Line 162 AC_DEFUN([gl_THREADLIB_BODY],
|
# Test whether both pthread_mutex_lock and pthread_mutexattr_init exist |
# Test whether both pthread_mutex_lock and pthread_mutexattr_init exist |
# in libc. IRIX 6.5 has the first one in both libc and libpthread, but |
# in libc. IRIX 6.5 has the first one in both libc and libpthread, but |
# the second one only in libpthread, and lock.c needs it. |
# the second one only in libpthread, and lock.c needs it. |
AC_TRY_LINK([#include <pthread.h>], | AC_LINK_IFELSE( |
[pthread_mutex_lock((pthread_mutex_t*)0); | [AC_LANG_PROGRAM( |
pthread_mutexattr_init((pthread_mutexattr_t*)0);], | [[#include <pthread.h>]], |
| [[pthread_mutex_lock((pthread_mutex_t*)0); |
| pthread_mutexattr_init((pthread_mutexattr_t*)0);]])], |
[gl_have_pthread=yes]) |
[gl_have_pthread=yes]) |
# Test for libpthread by looking for pthread_kill. (Not pthread_self, |
# Test for libpthread by looking for pthread_kill. (Not pthread_self, |
# since it is defined as a macro on OSF/1.) |
# since it is defined as a macro on OSF/1.) |
Line 154 AC_DEFUN([gl_THREADLIB_BODY],
|
Line 204 AC_DEFUN([gl_THREADLIB_BODY],
|
AC_DEFINE([USE_POSIX_THREADS], [1], |
AC_DEFINE([USE_POSIX_THREADS], [1], |
[Define if the POSIX multithreading library can be used.]) |
[Define if the POSIX multithreading library can be used.]) |
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then |
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then |
if test $gl_have_weak = yes; then | if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then |
AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], |
AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], |
[Define if references to the POSIX multithreading library should be made weak.]) |
[Define if references to the POSIX multithreading library should be made weak.]) |
LIBTHREAD= |
LIBTHREAD= |
Line 169 AC_DEFUN([gl_THREADLIB_BODY],
|
Line 219 AC_DEFUN([gl_THREADLIB_BODY],
|
gl_have_solaristhread= |
gl_have_solaristhread= |
gl_save_LIBS="$LIBS" |
gl_save_LIBS="$LIBS" |
LIBS="$LIBS -lthread" |
LIBS="$LIBS -lthread" |
AC_TRY_LINK([#include <thread.h> | AC_LINK_IFELSE( |
#include <synch.h>], | [AC_LANG_PROGRAM( |
[thr_self();], | [[ |
| #include <thread.h> |
| #include <synch.h> |
| ]], |
| [[thr_self();]])], |
[gl_have_solaristhread=yes]) |
[gl_have_solaristhread=yes]) |
LIBS="$gl_save_LIBS" |
LIBS="$gl_save_LIBS" |
if test -n "$gl_have_solaristhread"; then |
if test -n "$gl_have_solaristhread"; then |
Line 182 AC_DEFUN([gl_THREADLIB_BODY],
|
Line 236 AC_DEFUN([gl_THREADLIB_BODY],
|
LTLIBMULTITHREAD="$LTLIBTHREAD" |
LTLIBMULTITHREAD="$LTLIBTHREAD" |
AC_DEFINE([USE_SOLARIS_THREADS], [1], |
AC_DEFINE([USE_SOLARIS_THREADS], [1], |
[Define if the old Solaris multithreading library can be used.]) |
[Define if the old Solaris multithreading library can be used.]) |
if test $gl_have_weak = yes; then | if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then |
AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1], |
AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1], |
[Define if references to the old Solaris multithreading library should be made weak.]) |
[Define if references to the old Solaris multithreading library should be made weak.]) |
LIBTHREAD= |
LIBTHREAD= |
Line 196 AC_DEFUN([gl_THREADLIB_BODY],
|
Line 250 AC_DEFUN([gl_THREADLIB_BODY],
|
AC_LIB_LINKFLAGS([pth]) |
AC_LIB_LINKFLAGS([pth]) |
gl_have_pth= |
gl_have_pth= |
gl_save_LIBS="$LIBS" |
gl_save_LIBS="$LIBS" |
LIBS="$LIBS -lpth" | LIBS="$LIBS $LIBPTH" |
AC_TRY_LINK([#include <pth.h>], [pth_self();], [gl_have_pth=yes]) | AC_LINK_IFELSE( |
| [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])], |
| [gl_have_pth=yes]) |
LIBS="$gl_save_LIBS" |
LIBS="$gl_save_LIBS" |
if test -n "$gl_have_pth"; then |
if test -n "$gl_have_pth"; then |
gl_threads_api=pth |
gl_threads_api=pth |
Line 208 AC_DEFUN([gl_THREADLIB_BODY],
|
Line 264 AC_DEFUN([gl_THREADLIB_BODY],
|
AC_DEFINE([USE_PTH_THREADS], [1], |
AC_DEFINE([USE_PTH_THREADS], [1], |
[Define if the GNU Pth multithreading library can be used.]) |
[Define if the GNU Pth multithreading library can be used.]) |
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then |
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then |
if test $gl_have_weak = yes; then | if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then |
AC_DEFINE([USE_PTH_THREADS_WEAK], [1], |
AC_DEFINE([USE_PTH_THREADS_WEAK], [1], |
[Define if references to the GNU Pth multithreading library should be made weak.]) |
[Define if references to the GNU Pth multithreading library should be made weak.]) |
LIBTHREAD= |
LIBTHREAD= |