[libdispatch-dev] [PATCH 04/17] move blocks detection to separate autoconf macro
Paolo Bonzini
bonzini at gnu.org
Sun Oct 18 08:04:04 PDT 2009
... and here too.
---
configure.ac | 61 +---------------------------------------------------------
m4/blocks.m4 | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 60 deletions(-)
create mode 100644 m4/blocks.m4
diff --git a/configure.ac b/configure.ac
index db7cade..eee12e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,66 +166,7 @@ AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]])
AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sem_init])
DISPATCH_C_PRIVATE_EXTERN
-
-#
-# 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])
+DISPATCH_C_BLOCKS
#
# Temporary: some versions of clang do not mark __builtin_trap() as
diff --git a/m4/blocks.m4 b/m4/blocks.m4
new file mode 100644
index 0000000..ad74479
--- /dev/null
+++ b/m4/blocks.m4
@@ -0,0 +1,61 @@
+AC_DEFUN([DISPATCH_C_BLOCKS], [
+#
+# 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])
+])
--
1.6.2.5
More information about the libdispatch-dev
mailing list