Modified: trunk/configure.ac (42 => 43)
--- trunk/configure.ac 2009-09-26 11:43:02 UTC (rev 42)
+++ trunk/configure.ac 2009-09-26 18:30:55 UTC (rev 43)
@@ -188,6 +188,66 @@
])
#
+# Detect compiler support for Blocks; perhaps someday -fblocks won't be
+# required, in which case we'll need to change this.
+#
+AC_CACHE_CHECK([for C Blocks support], [dispatch_cv_cblocks], [
+ saveCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fblocks"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[(void)^{int i; i = 0; }();])], [
+ CFLAGS="$saveCFLAGS"
+ dispatch_cv_cblocks="-fblocks"
+ ], [
+ CFLAGS="$saveCFLAGS"
+ dispatch_cv_cblocks="no"
+ ])
+])
+
+#
+# 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"
+
+ #
+ # It may be necessary to directly link the Blocks runtime on some
+ # systems, so give it a try if we can't link a C program that uses
+ # Blocks. We will want to remove this at somepoint, as really -fblocks
+ # should force that linkage already.
+ #
+ saveCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -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])
+ ])
+ ])
+ CFLAGS="$saveCFLAGS"
+], [
+ CBLOCKS_FLAGS=""
+])
+AC_SUBST([CBLOCKS_FLAGS])
+
+#
# Generate Makefiles.
#
AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile src/Makefile])
Modified: trunk/src/Makefile.am (42 => 43)
--- trunk/src/Makefile.am 2009-09-26 11:43:02 UTC (rev 42)
+++ trunk/src/Makefile.am 2009-09-26 18:30:55 UTC (rev 43)
@@ -19,7 +19,7 @@
INCLUDES=-I$(top_builddir) -I$(top_srcdir) \
@APPLE_LIBC_SOURCE_PATH@ @APPLE_XNU_SOURCE_PATH@
-libdispatch_la_CFLAGS+=$(MARCH_FLAGS)
+libdispatch_la_CFLAGS+=$(MARCH_FLAGS) $(CBLOCKS_FLAGS)
if USE_LEGACY_API
libdispatch_la_SOURCES+= \