1 AC_DEFUN([DISPATCH_C_BLOCKS], [
3 # Allow configure to be passed a path to the directory where it should look
4 # for the Blocks runtime library, if any.
6 AC_ARG_WITH([blocks-runtime],
7 [AS_HELP_STRING([--with-blocks-runtime],
8 [Specify path to the blocks runtime])],
9 [blocks_runtime=${withval}
10 LIBS="$LIBS -L$blocks_runtime"]
14 # Detect compiler support for Blocks; perhaps someday -fblocks won't be
15 # required, in which case we'll need to change this.
17 AC_CACHE_CHECK([for C Blocks support], [dispatch_cv_cblocks], [
19 CFLAGS="$CFLAGS -fblocks"
20 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[(void)^{int i; i = 0; }();])], [
22 dispatch_cv_cblocks="-fblocks"
25 dispatch_cv_cblocks="no"
29 AS_IF([test "x$dispatch_cv_cblocks" != "xno"], [
30 CBLOCKS_FLAGS="$dispatch_cv_cblocks"
33 # It may be necessary to directly link the Blocks runtime on some
34 # systems, so give it a try if we can't link a C program that uses
35 # Blocks. We will want to remove this at somepoint, as really -fblocks
36 # should force that linkage already.
39 CFLAGS="$CFLAGS -fblocks -O0"
40 AC_MSG_CHECKING([whether additional libraries are required for the Blocks runtime])
47 LIBS="$LIBS -lBlocksRuntime"
51 AC_MSG_RESULT([-lBlocksRuntime])
53 AC_MSG_ERROR([can't find Blocks runtime])
62 AM_CONDITIONAL(HAVE_CBLOCKS, $have_cblocks)
63 AC_SUBST([CBLOCKS_FLAGS])
66 # Because a different C++ compiler may be specified than C compiler, we have
67 # to do it again for C++.
70 AC_CACHE_CHECK([for C++ Blocks support], [dispatch_cv_cxxblocks], [
71 saveCXXFLAGS="$CXXFLAGS"
72 CXXFLAGS="$CXXFLAGS -fblocks"
73 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[(void)^{int i; i = 0; }();])], [
74 CXXFLAGS="$saveCXXFLAGS"
75 dispatch_cv_cxxblocks="-fblocks"
77 CXXFLAGS="$saveCXXFLAGS"
78 dispatch_cv_cxxblocks="no"
82 AS_IF([test "x$dispatch_cv_cxxblocks" != "xno"], [
83 CXXBLOCKS_FLAGS="$dispatch_cv_cxxblocks"
85 saveCXXFLAGS="$CXXFLAGS"
86 CXXFLAGS="$CXXFLAGS -fblocks -O0"
87 AC_MSG_CHECKING([whether additional libraries are required for the Blocks runtime])
94 LIBS="$LIBS -lBlocksRuntime"
98 AC_MSG_RESULT([-lBlocksRuntime])
100 AC_MSG_ERROR([can't find Blocks runtime])
103 CXXFLAGS="$saveCXXFLAGS"
110 AM_CONDITIONAL(HAVE_CXXBLOCKS, $have_cxxblocks)
111 AC_SUBST([CXXBLOCKS_FLAGS])