+
+AC_DEFUN([CY_TEST_FLAG], [
+ CY_TEST_FLAG_(]$1[, [C], [CFLAGS], [cc])
+ CY_TEST_FLAG_(]$1[, [C++], [CXXFLAGS], [c++])
+ CY_TEST_FLAG_(]$1[, [Objective C++], [OBJCXXFLAGS], [c++ -ObjC])
+])
+
+AX_CFLAGS_WARN_ALL
+AX_CXXFLAGS_WARN_ALL
+AX_FLAGS_WARN_ALL
+
+CY_TEST_FLAG([-Werror])
+
+dnl XXX: this is used to support GNU Objective-C struct objc_method
+CY_TEST_FLAG([-Wno-deprecated-declarations])
+
+CY_TEST_FLAG([-Wno-dangling-else])
+CY_TEST_FLAG([-Wno-overloaded-virtual])
+CY_TEST_FLAG([-Wno-parentheses])
+CY_TEST_FLAG([-Wno-unneeded-internal-declaration])
+
+AC_DEFUN([CY_LT_LIB], [
+ cy_save=$LIBS
+ LIBS=
+ ]$2[
+ ]$1[=$LIBS
+ LIBS=$cy_save
+ AC_SUBST(]$1[)
+])
+
+dnl -arch * {{{
+for cy_arch in ppc ppc64 i386 x86_64 armv6 arm64; do
+ AC_MSG_CHECKING([for -arch $cy_arch])
+ CY_TRY([CXXFLAGS], ["-arch $cy_arch"], [
+ AC_TRY_LINK([], [], [CY_SUCCESS], [CY_FAILURE])
+ ], [
+ AC_MSG_RESULT([yes])
+ AC_LIB_APPENDTOVAR([CY_ARCH], ["-arch $cy_arch"])
+ ], [AC_MSG_RESULT([no])])
+done
+AC_SUBST([CY_ARCH])
+dnl }}}
+
+dnl --enable-javascript {{{
+AC_DEFUN([CY_CHECK_JAVASCRIPTCORE], [
+ CY_LT_LIB([LTJAVASCRIPTCORE], [AC_SEARCH_LIBS([JSEvaluateScript], [JavaScriptCore], [
+ AC_SUBST([CY_EXECUTE], [1])
+ ], [AC_CHECK_FRAMEWORK([JavaScriptCore], [
+ #include <JavaScriptCore/JSBase.h>
+ ], [
+ JSEvaluateScript(0, 0, 0, 0, 0, 0);
+ ], [
+ AC_SUBST([CY_EXECUTE], [1])
+ ], [
+ for cy_webkit_pkg in "webkit-1.0" "WebKitGtk"; do
+ PKG_CHECK_MODULES([WEBKIT], [$cy_webkit_pkg], [
+ AC_SUBST([CY_EXECUTE], [1])
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [`$PKG_CONFIG --cflags $cy_webkit_pkg`])
+ AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs $cy_webkit_pkg`])
+ ], [:]); if test "x$CY_EXECUTE" = x1; then break; fi
+ done
+ ])])])
+])
+
+AC_DEFUN([CY_CHECK_JAVASCRIPT], [
+ CY_CHECK_JAVASCRIPTCORE])
+
+AC_ARG_ENABLE([javascript], [AS_HELP_STRING(
+ [--enable-javascript@<:@=ENGINE@:>@],
+ [use a JavaScript runtime (currently the only available option for ENGINE is JavaScriptCore) @<:@default=yes@:>@]
+)], [
+ AS_CASE([$enableval],
+ [yes], [
+ CY_CHECK_JAVASCRIPT],
+ [no], [
+ AC_SUBST([CY_EXECUTE], [0])],
+ [JavaScriptCore], [
+ CY_CHECK_JAVASCRIPTCORE],
+ [AC_MSG_ERROR([Unknown JavaScript engine: $enableval])])
+], [CY_CHECK_JAVASCRIPT])
+dnl }}}
+
+AC_ARG_ENABLE([console], AS_HELP_STRING([--disable-console], [disable console]))
+AM_CONDITIONAL([CY_CONSOLE], [test "x$enable_console" != "xno"])
+
+AC_DEFUN([CY_CHECK_PKG_CONFIG_LIBFFI], [
+ PKG_CHECK_MODULES([LIBFFI], [libffi], [
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [`$PKG_CONFIG --cflags libffi`])
+ AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs libffi`])
+ ], [AC_MSG_ERROR([missing "libffi"])])])
+
+AM_CONDITIONAL([CY_EXECUTE], [test "x$CY_EXECUTE" = x1])
+