9b2e404a01323f7365115dfc2e653e31a9f56ac8
[cacao.git] / m4 / threads.m4
1 dnl m4/threads.m4
2 dnl
3 dnl Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
4 dnl C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 dnl E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 dnl J. Wenninger, Institut f. Computersprachen - TU Wien
7 dnl 
8 dnl This file is part of CACAO.
9 dnl 
10 dnl This program is free software; you can redistribute it and/or
11 dnl modify it under the terms of the GNU General Public License as
12 dnl published by the Free Software Foundation; either version 2, or (at
13 dnl your option) any later version.
14 dnl 
15 dnl This program is distributed in the hope that it will be useful, but
16 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
17 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 dnl General Public License for more details.
19 dnl 
20 dnl You should have received a copy of the GNU General Public License
21 dnl along with this program; if not, write to the Free Software
22 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 dnl 02110-1301, USA.
24 dnl 
25 dnl $Id: configure.ac 7228 2007-01-19 01:13:48Z edwin $
26
27
28 dnl check which thread implementation should be used
29
30 AC_DEFUN([AC_CHECK_ENABLE_THREADS],[
31 AC_MSG_CHECKING(whether to include threads support)
32 AC_ARG_ENABLE([threads],
33               [AS_HELP_STRING(--enable-threads,enable threads support (none,native) [[default=native]])],
34               [case "${enableval}" in
35                    no | none | single )
36                        ENABLE_THREADS=no
37                        ;;
38
39                    posix | pthreads )
40                        ENABLE_THREADS=posix
41                        ;;
42
43                    *)
44                        AC_MSG_ERROR($enableval is an unknown thread package)
45                        ;;
46                esac],
47                [ENABLE_THREADS=posix])
48
49 AC_MSG_RESULT(${ENABLE_THREADS})
50 AM_CONDITIONAL([ENABLE_THREADS], test x"${ENABLE_THREADS}" != "xno")
51
52 case "${ENABLE_THREADS}" in
53     no )
54         dnl no threads for boehm
55         ac_configure_args="$ac_configure_args --disable-boehm-threads"
56         ;;
57
58     posix )
59         AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
60         AC_CHECK_LIB(pthread, main)
61
62         ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT"
63
64         dnl we changed ARCH_CFLAGS, set CFLAGS again
65         CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
66
67         dnl tell boehm to support threads as well
68         ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
69         ;;
70 esac
71 ])
72
73
74 dnl currently NOT USED
75
76 dnl AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--enable-__thread,use TLS features)], [use__thread=$enableval], [use__thread=no])
77 dnl 
78 dnl dnl Check whether the compiler supports the __thread keyword.
79 dnl if test "x$use__thread" != xno; then
80 dnl   AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
81 dnl   [cat > conftest.c <<\EOF
82 dnl __thread int a = 42;
83 dnl EOF
84 dnl   if AC_TRY_COMMAND([${CC-cc} $ARCH_CFLAGS $OPT_CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
85 dnl     ac_cv_gcc___thread=yes 
86 dnl   else
87 dnl     ac_cv_gcc___thread=no
88 dnl   fi
89 dnl   rm -f conftest*])
90 dnl   if test "$ac_cv_gcc___thread" = yes; then
91 dnl     AC_DEFINE([HAVE___THREAD], 1, [have __thread])
92 dnl   fi
93 dnl else
94 dnl   ac_cv_gcc___thread=no
95 dnl fi