[libdispatch-changes] [43] trunk
source_changes at macosforge.org
source_changes at macosforge.org
Sat Sep 26 11:30:57 PDT 2009
Revision: 43
http://trac.macosforge.org/projects/libdispatch/changeset/43
Author: robert at fledge.watson.org
Date: 2009-09-26 11:30:55 -0700 (Sat, 26 Sep 2009)
Log Message:
-----------
Autoconf/automake support for configuring and compiling Blocks support,
tested on FreeBSD/i386:
- Detect whether the blocks syntax is supported using -fblocks.
- If it is, try to link without additional libraries.
- If that fails, try -lBlocksRuntime in case clang -fblocks doesn't
automatically add a dependency on the runtime.
- Allow the user to specify the path to the lib directory where that
runtime can be found, if required.
Modified Paths:
--------------
trunk/configure.ac
trunk/src/Makefile.am
Modified: trunk/configure.ac
===================================================================
--- 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
===================================================================
--- 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+= \
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/libdispatch-changes/attachments/20090926/32a62c35/attachment.html>
More information about the libdispatch-changes
mailing list