* configure.ac: New switch for disabling -O2 (--disable-optimizations).
[cacao.git] / m4 / threads.m4
index 8c8614d9ea5dfec61bc69e8fd51753163d88f81b..c123401d305abd9d3ba810fb6174795e7165d6b3 100644 (file)
@@ -21,8 +21,6 @@ dnl You should have received a copy of the GNU General Public License
 dnl along with this program; if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 dnl 02110-1301, USA.
-dnl 
-dnl $Id: configure.ac 7228 2007-01-19 01:13:48Z edwin $
 
 
 dnl check which thread implementation should be used
@@ -31,7 +29,7 @@ AC_DEFUN([AC_CHECK_ENABLE_THREADS],[
 AC_MSG_CHECKING(whether to include threads support)
 AC_ARG_ENABLE([threads],
               [AS_HELP_STRING(--enable-threads,enable threads support (none,native) [[default=native]])],
-              [case "$enableval}" in
+              [case "${enableval}" in
                    no | none | single )
                        ENABLE_THREADS=no
                        ;;
@@ -59,10 +57,11 @@ case "${ENABLE_THREADS}" in
         AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
         AC_CHECK_LIB(pthread, main)
 
-        ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT"
+        OS_FLAGS="$OS_FLAGS -D_REENTRANT"
 
-        dnl we changed ARCH_CFLAGS, set CFLAGS again
-        CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
+        dnl We changed OS_FLAGS, set CFLAGS again.
+        CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
+        CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
 
         dnl tell boehm to support threads as well
         ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
@@ -71,25 +70,25 @@ esac
 ])
 
 
-dnl currently NOT USED
+AC_DEFUN([AC_CHECK_USE___THREAD],[
+AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--enable-__thread,use TLS features [[default=yes]])], [use__thread=$enableval], [use__thread=yes])
 
-dnl AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--enable-__thread,use TLS features)], [use__thread=$enableval], [use__thread=no])
-dnl 
-dnl dnl Check whether the compiler supports the __thread keyword.
-dnl if test "x$use__thread" != xno; then
-dnl   AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
-dnl   [cat > conftest.c <<\EOF
-dnl __thread int a = 42;
-dnl EOF
-dnl   if AC_TRY_COMMAND([${CC-cc} $ARCH_CFLAGS $OPT_CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
-dnl     ac_cv_gcc___thread=yes 
-dnl   else
-dnl     ac_cv_gcc___thread=no
-dnl   fi
-dnl   rm -f conftest*])
-dnl   if test "$ac_cv_gcc___thread" = yes; then
-dnl     AC_DEFINE([HAVE___THREAD], 1, [have __thread])
-dnl   fi
-dnl else
-dnl   ac_cv_gcc___thread=no
-dnl fi
+dnl Check whether the compiler supports the __thread keyword.
+if test "x$use__thread" != xno; then
+  AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
+  [cat > conftest.c <<\EOF
+__thread int a = 42;
+EOF
+  if AC_TRY_COMMAND([${CC-cc} $ARCH_CFLAGS $OPT_CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
+    ac_cv_gcc___thread=yes 
+  else
+    ac_cv_gcc___thread=no
+  fi
+  rm -f conftest*])
+  if test "$ac_cv_gcc___thread" = yes; then
+    AC_DEFINE([HAVE___THREAD], 1, [have __thread])
+  fi
+else
+  ac_cv_gcc___thread=no
+fi
+])