[libdispatch-changes] [127] trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Nov 4 08:04:53 PST 2009
Revision: 127
http://trac.macosforge.org/projects/libdispatch/changeset/127
Author: robert at fledge.watson.org
Date: 2009-11-04 08:04:51 -0800 (Wed, 04 Nov 2009)
Log Message:
-----------
Separately detect C++ blocks support from C blocks support, and compile the
dispatch_plusplus regression test only if C++ supports blocks.
Modified Paths:
--------------
trunk/configure.ac
trunk/m4/blocks.m4
trunk/testing/Makefile.am
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2009-11-04 12:00:04 UTC (rev 126)
+++ trunk/configure.ac 2009-11-04 16:04:51 UTC (rev 127)
@@ -111,6 +111,7 @@
)
AC_PROG_CC
+AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PATH_PROGS(MIG, mig)
Modified: trunk/m4/blocks.m4
===================================================================
--- trunk/m4/blocks.m4 2009-11-04 12:00:04 UTC (rev 126)
+++ trunk/m4/blocks.m4 2009-11-04 16:04:51 UTC (rev 127)
@@ -1,5 +1,16 @@
AC_DEFUN([DISPATCH_C_BLOCKS], [
#
+# Allow configure to be passed a path to the directory where it should look
+# for the Blocks runtime library, if any.
+#
+AC_ARG_WITH([blocks-runtime],
+ [AS_HELP_STRING([--with-blocks-runtime],
+ [Specify path to the blocks runtime])],
+ [blocks_runtime=${withval}
+ LIBS="$LIBS -L$blocks_runtime"]
+)
+
+#
# Detect compiler support for Blocks; perhaps someday -fblocks won't be
# required, in which case we'll need to change this.
#
@@ -15,17 +26,6 @@
])
])
-#
-# Allow configure to be passed a path to the directory where it should look
-# for the Blocks runtime library, if any.
-#
-AC_ARG_WITH([blocks-runtime],
- [AS_HELP_STRING([--with-blocks-runtime],
- [Specify path to the blocks runtime])],
- [blocks_runtime=${withval}
- LIBS="$LIBS -L$blocks_runtime"]
-)
-
AS_IF([test "x$dispatch_cv_cblocks" != "xno"], [
CBLOCKS_FLAGS="$dispatch_cv_cblocks"
@@ -59,6 +59,54 @@
CBLOCKS_FLAGS=""
have_cblocks=false
])
-AM_CONDITIONAL(HAVE_BLOCKS, $have_cblocks)
+AM_CONDITIONAL(HAVE_CBLOCKS, $have_cblocks)
AC_SUBST([CBLOCKS_FLAGS])
+
+#
+# Because a different C++ compiler may be specified than C compiler, we have
+# to do it again for C++.
+#
+AC_LANG_PUSH([C++])
+AC_CACHE_CHECK([for C++ Blocks support], [dispatch_cv_cxxblocks], [
+ saveCXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -fblocks"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[(void)^{int i; i = 0; }();])], [
+ CXXFLAGS="$saveCXXFLAGS"
+ dispatch_cv_cxxblocks="-fblocks"
+ ], [
+ CXXFLAGS="$saveCXXFLAGS"
+ dispatch_cv_cxxblocks="no"
+ ])
])
+
+AS_IF([test "x$dispatch_cv_cxxblocks" != "xno"], [
+ CXXBLOCKS_FLAGS="$dispatch_cv_cxxblocks"
+
+ saveCXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -fblocks"
+ AC_MSG_CHECKING([whether additional libraries are required for the Blocks runtime])
+ AC_TRY_LINK([], [
+ ^{ int j; j=0; }();
+ ], [
+ AC_MSG_RESULT([no]);
+ ], [
+ saveLIBS="$LIBS"
+ LIBS="$LIBS -lBlocksRuntime"
+ AC_TRY_LINK([], [
+ ^{ int k; k=0; }();
+ ], [
+ AC_MSG_RESULT([-lBlocksRuntime])
+ ], [
+ AC_MSG_ERROR([can't find Blocks runtime])
+ ])
+ ])
+ CXXFLAGS="$saveCXXFLAGS"
+ have_cxxblocks=true
+], [
+ CXXBLOCKS_FLAGS=""
+ have_cxxblocks=false
+])
+AC_LANG_POP([C++])
+AM_CONDITIONAL(HAVE_CXXBLOCKS, $have_cxxblocks)
+AC_SUBST([CXXBLOCKS_FLAGS])
+])
Modified: trunk/testing/Makefile.am
===================================================================
--- trunk/testing/Makefile.am 2009-11-04 12:00:04 UTC (rev 126)
+++ trunk/testing/Makefile.am 2009-11-04 16:04:51 UTC (rev 127)
@@ -18,8 +18,8 @@
dispatch_c99_CFLAGS=-std=c99
-if HAVE_BLOCKS
-BLOCKS_TESTS= \
+if HAVE_CBLOCKS
+CBLOCKS_TESTS= \
dispatch_after \
dispatch_apply \
dispatch_drift \
@@ -31,8 +31,15 @@
dispatch_timer_bit31 \
dispatch_timer_bit63
endif
-TESTS+=$(BLOCKS_TESTS)
+TESTS+=$(CBLOCKS_TESTS)
+if HAVE_CXXBLOCKS
+CXXBLOCKS_TESTS= \
+ dispatch_plusplus
+dispatch_plusplus_SOURCES=dispatch_plusplus.cpp
+endif
+TESTS+=$(CXXBLOCKS_TESTS)
+
if HAVE_CORESERVICES
CORESERVICES_TESTS= \
dispatch_cffd
@@ -70,4 +77,5 @@
INCLUDES=-I$(top_builddir) -I$(top_srcdir)
LDADD=libtest.la ../src/libdispatch.la
CFLAGS=-Wall $(MARCH_FLAGS) $(CBLOCKS_FLAGS)
+CXXFLAGS=-Wall $(MARCH_FLAGS) $(CXXBLOCKS_FLAGS)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/libdispatch-changes/attachments/20091104/ded0d986/attachment.html>
More information about the libdispatch-changes
mailing list