Commit f560ae8f authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Build system: give the possibility to disable POSIX threads in configure script

parent a98a5106
...@@ -162,7 +162,7 @@ License: LGPL-3+ ...@@ -162,7 +162,7 @@ License: LGPL-3+
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
Files: m4/ax_blas.m4, m4/ax_lapack.m4, m4/ax_pthread.m4 Files: m4/ax_blas.m4, m4/ax_lapack.m4
Copyright: 2008, Steven G. Johnson <stevenj@alum.mit.edu> Copyright: 2008, Steven G. Johnson <stevenj@alum.mit.edu>
License: GPL-3+ with special Autoconf exception License: GPL-3+ with special Autoconf exception
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
...@@ -191,6 +191,36 @@ License: GPL-3+ with special Autoconf exception ...@@ -191,6 +191,36 @@ License: GPL-3+ with special Autoconf exception
modified version of the Autoconf Macro, you may extend this special modified version of the Autoconf Macro, you may extend this special
exception to the GPL to apply to your modified version as well. exception to the GPL to apply to your modified version as well.
Files: m4/ax_pthread.m4
Copyright: 2008, Steven G. Johnson <stevenj@alum.mit.edu>
2010, Dynare Team
License: GPL-3+ with special Autoconf exception
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
.
As a special exception, the respective Autoconf Macro's copyright owner
gives unlimited permission to copy, distribute and modify the configure
scripts that are the output of Autoconf when processing the Macro. You
need not follow the terms of the GNU General Public License when using
or distributing such scripts, even though portions of the text of the
Macro appear in them. The GNU General Public License (GPL) does govern
all other use of the material that constitutes the Autoconf Macro.
.
This special exception to the GPL applies to versions of the Autoconf
Macro released by the Autoconf Archive. When you make and distribute a
modified version of the Autoconf Macro, you may extend this special
exception to the GPL to apply to your modified version as well.
Files: m4/ax_boost_base.m4 Files: m4/ax_boost_base.m4
Copyright: 2008, Thomas Porschberg <thomas@randspringer.de> Copyright: 2008, Thomas Porschberg <thomas@randspringer.de>
2009, Dynare Team 2009, Dynare Team
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
# LICENSE # LICENSE
# #
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu> # Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2010 Dynare Team
# #
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the # under the terms of the GNU General Public License as published by the
...@@ -82,14 +83,18 @@ AC_LANG_SAVE ...@@ -82,14 +83,18 @@ AC_LANG_SAVE
AC_LANG_C AC_LANG_C
ax_pthread_ok=no ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h AC_ARG_WITH([pthread], [AS_HELP_STRING([--without-pthread], [don't use POSIX threads])], [], [with_readline=check])
# requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS, if test "x$with_pthread" != "xno"; then
# etcetera environment variables, and if threads linking works using
# them: # We used to check for pthread.h first, but this fails if pthread.h
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then # requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_CFLAGS="$CFLAGS" save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS" save_LIBS="$LIBS"
...@@ -103,41 +108,41 @@ if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then ...@@ -103,41 +108,41 @@ if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
fi fi
LIBS="$save_LIBS" LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS" CFLAGS="$save_CFLAGS"
fi fi
# We must check for the threads library under a number of different # We must check for the threads library under a number of different
# names; the ordering is very important because some systems # names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX). # libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are # Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none" # C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config" # which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library. # which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the # The ordering *is* (sometimes) important. Some notes on the
# individual items follow: # individual items follow:
# pthreads: AIX (must check this before -lpthread) # pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and # none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings # other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -pthreads: Solaris/gcc # -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc # -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too; # doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT) # also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC # ... -mt is also the pthreads flag for HP/aCC
# pthread: Linux, etcetera # pthread: Linux, etcetera
# --thread-safe: KAI C++ # --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library) # pthread-config: use pthread-config program (for GNU Pth library)
case "${host_cpu}-${host_os}" in case "${host_cpu}-${host_os}" in
*solaris*) *solaris*)
# On Solaris (at least, for some versions), libc contains stubbed # On Solaris (at least, for some versions), libc contains stubbed
...@@ -150,10 +155,10 @@ case "${host_cpu}-${host_os}" in ...@@ -150,10 +155,10 @@ case "${host_cpu}-${host_os}" in
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
;; ;;
esac esac
if test x"$ax_pthread_ok" = xno; then if test x"$ax_pthread_ok" = xno; then
for flag in $ax_pthread_flags; do for flag in $ax_pthread_flags; do
case $flag in case $flag in
none) none)
...@@ -208,11 +213,11 @@ for flag in $ax_pthread_flags; do ...@@ -208,11 +213,11 @@ for flag in $ax_pthread_flags; do
PTHREAD_LIBS="" PTHREAD_LIBS=""
PTHREAD_CFLAGS="" PTHREAD_CFLAGS=""
done done
fi fi
# Various other checks: # Various other checks:
if test "x$ax_pthread_ok" = xyes; then if test "x$ax_pthread_ok" = xyes; then
save_LIBS="$LIBS" save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS" save_CFLAGS="$CFLAGS"
...@@ -252,13 +257,15 @@ if test "x$ax_pthread_ok" = xyes; then ...@@ -252,13 +257,15 @@ if test "x$ax_pthread_ok" = xyes; then
else else
PTHREAD_CC=$CC PTHREAD_CC=$CC
fi fi
else else
PTHREAD_CC="$CC" PTHREAD_CC="$CC"
fi fi
AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC) AC_SUBST(PTHREAD_CC)
fi
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_pthread_ok" = xyes; then if test x"$ax_pthread_ok" = xyes; then
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment