Merged comment cleanup (forgot this before).
[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
25
26 dnl check which thread implementation should be used
27
28 AC_DEFUN([AC_CHECK_ENABLE_THREADS],[
29 AC_MSG_CHECKING(whether to include threads support)
30 AC_ARG_ENABLE([threads],
31               [AS_HELP_STRING(--enable-threads,enable threads support (none,native) [[default=native]])],
32               [case "${enableval}" in
33                    no | none | single )
34                        ENABLE_THREADS=no
35                        ;;
36
37                    posix | pthreads )
38                        ENABLE_THREADS=posix
39                        ;;
40
41                    *)
42                        AC_MSG_ERROR($enableval is an unknown thread package)
43                        ;;
44                esac],
45                [ENABLE_THREADS=posix])
46
47 AC_MSG_RESULT(${ENABLE_THREADS})
48 AM_CONDITIONAL([ENABLE_THREADS], test x"${ENABLE_THREADS}" != "xno")
49
50 case "${ENABLE_THREADS}" in
51     no )
52         dnl no threads for boehm
53         ac_configure_args="$ac_configure_args --disable-boehm-threads"
54         ;;
55
56     posix )
57         AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
58         AC_CHECK_LIB(pthread, main)
59
60         OS_FLAGS="$OS_FLAGS -D_REENTRANT"
61
62         dnl We changed OS_FLAGS, set CFLAGS again.
63         CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
64         CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
65
66         dnl tell boehm to support threads as well
67         ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
68         ;;
69 esac
70 ])
71
72
73 dnl currently NOT USED
74
75 dnl AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--enable-__thread,use TLS features)], [use__thread=$enableval], [use__thread=no])
76 dnl 
77 dnl dnl Check whether the compiler supports the __thread keyword.
78 dnl if test "x$use__thread" != xno; then
79 dnl   AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
80 dnl   [cat > conftest.c <<\EOF
81 dnl __thread int a = 42;
82 dnl EOF
83 dnl   if AC_TRY_COMMAND([${CC-cc} $ARCH_CFLAGS $OPT_CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
84 dnl     ac_cv_gcc___thread=yes 
85 dnl   else
86 dnl     ac_cv_gcc___thread=no
87 dnl   fi
88 dnl   rm -f conftest*])
89 dnl   if test "$ac_cv_gcc___thread" = yes; then
90 dnl     AC_DEFINE([HAVE___THREAD], 1, [have __thread])
91 dnl   fi
92 dnl else
93 dnl   ac_cv_gcc___thread=no
94 dnl fi