2 AC_INIT([Cycript], [0.9], [saurik@saurik.com], [cycript], [http://www.cycript.org/])
3 AC_COPYRIGHT([Copyright (C) 2009-2012 Jay Freeman (saurik)])
5 AC_CONFIG_SRCDIR([Console.cpp])
7 AC_CONFIG_MACRO_DIR([m4])
9 AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability foreign])
16 LT_INIT([disable-static])
20 PKG_PROG_PKG_CONFIG([0.22])
23 AC_SUBST([GMAKE], [$_cv_gnu_make_command])
24 AS_IF([test "x$GMAKE" = x], [AC_MSG_ERROR([You need GNU make])])
26 AC_PATH_PROG([_BASH], [bash], [AC_MSG_ERROR([missing "bash"])])
27 AC_PATH_PROG([GIT], [git])
28 AC_PATH_PROG([TIME], [time])
30 dnl CY_CHECK_PROGS_VERSION {{{
31 AC_DEFUN([CY_CHECK_PROGS_VERSION], [
32 AC_ARG_VAR(]$1[, ]$3[)
34 AC_MSG_CHECKING(for ]$2[ >= ]$5[)
35 AC_PATH_PROGS_FEATURE_CHECK(]$1[, ]$2[,
36 AS_VAR_SET(version, [`$ac_path_]$1[ ]$4[`])
37 AS_VAR_IF(version, [], ,
38 AS_VERSION_COMPARE($version, ]$5[, ,
39 ac_cv_path_]$1[=$ac_path_]$1[,
40 ac_cv_path_]$1[=$ac_path_]$1[))
44 AC_SUBST(]$1[, $ac_cv_path_]$1[)
47 AC_MSG_ERROR(You need ]$2[ ]$5[ or greater)
54 CY_CHECK_PROGS_VERSION([BISON], [bison], [GNU Project parser generator (yacc replacement)],
55 [-V | $SED -e '1 s/^bison (GNU Bison) \(.*\)$/\1/p;d'], [2.3])
56 CY_CHECK_PROGS_VERSION([FLEX], [flex], [the fast lexical analyser generator],
57 [--version | $SED -e '1 s/^@<:@^0-9.@:>@* \(@<:@0-9.@:>@*\).*$/\1/p;d'], [2.5.33])
58 CY_CHECK_PROGS_VERSION([GPERF], [gperf], [perfect hash function generator],
59 [--version | $SED -e '1 s/^.* \(@<:@0-9.@:>@*\)$/\1/p;d'], [3.0.3])
60 CY_CHECK_PROGS_VERSION([GNUTAR], [tar gtar gnutar], [a very sticky lump of files],
61 [--version | $SED -e '1 s/^tar (GNU tar) \(.*\)$/\1/p;d'], [1.19])
64 AC_DEFUN([CY_SUCCESS], [cy_good=1])
65 AC_DEFUN([CY_FAILURE], [cy_good=0])
69 AC_LIB_APPENDTOVAR(]$1[, ]$2[)
72 AS_IF([test "x$cy_good" = x1], ]$4[, ]$5[)
75 AC_DEFUN([CY_COMPILE_FLAG], [
76 AC_LIB_APPENDTOVAR([CFLAGS], ]$1[)
77 AC_LIB_APPENDTOVAR([CXXFLAGS], ]$1[)
78 AC_LIB_APPENDTOVAR([OBJCCXXFLAGS], ]$1[)
81 AC_DEFUN([CY_TEST_FLAG], [
82 AC_MSG_CHECKING([for ]]$1[)
83 CY_TRY([CXXFLAGS], $1, [
84 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
85 [CY_SUCCESS], [CY_FAILURE])
89 ], [AC_MSG_RESULT([no])])
95 CY_TEST_FLAG([-Wno-overloaded-virtual])
96 CY_TEST_FLAG([-Wno-parentheses])
97 CY_TEST_FLAG([-Wno-unneeded-internal-declaration])
100 for cy_arch in ppc ppc64 i386 x86_64 armv6; do
101 AC_MSG_CHECKING([for -arch $cy_arch])
102 CY_TRY([CXXFLAGS], ["-arch $cy_arch"], [
103 AC_TRY_LINK([], [], [CY_SUCCESS], [CY_FAILURE])
106 AC_LIB_APPENDTOVAR([CY_ARCH], ["-arch $cy_arch"])
107 ], [AC_MSG_RESULT([no])])
112 dnl --with-frameworks {{{
113 AC_ARG_WITH([frameworks], [AS_HELP_STRING(
114 [--with-frameworks=DIRS],
115 [add to DIRS (space separated) to the Darwin include path for frameworks with -F]
117 for cy_framework in $withval; do
118 CY_COMPILE_FLAG([-F$cy_framework])
121 dnl --enable-javascript {{{
122 AC_DEFUN([CY_CHECK_JAVASCRIPTCORE], [
123 PKG_CHECK_MODULES([WEBKIT], [webkit-1.0], [
124 AC_SUBST([CY_EXECUTE], [1])
125 AC_LIB_APPENDTOVAR([CXXFLAGS], [`$PKG_CONFIG --cflags webkit-1.0`])
126 AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs webkit-1.0`])
128 PKG_CHECK_MODULES([WEBKIT], [WebKitGtk], [
129 AC_SUBST([CY_EXECUTE], [1])
130 AC_LIB_APPENDTOVAR([CXXFLAGS], [`$PKG_CONFIG --cflags WebKitGtk`])
131 AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs WebKitGtk`])
133 AC_CHECK_FRAMEWORK([JavaScriptCore], [
134 #include <JavaScriptCore/JSBase.h>
136 JSEvaluateScript(0, 0, 0, 0, 0, 0);
138 AC_SUBST([CY_EXECUTE], [1])
144 AC_DEFUN([CY_CHECK_JAVASCRIPT], [
145 CY_CHECK_JAVASCRIPTCORE])
147 AC_ARG_ENABLE([javascript], [AS_HELP_STRING(
148 [--enable-javascript@<:@=ENGINE@:>@],
149 [use a JavaScript runtime (currently the only available option for ENGINE is JavaScriptCore) @<:@default=yes@:>@]
151 AS_CASE([$enableval],
153 CY_CHECK_JAVASCRIPT],
155 AC_SUBST([CY_EXECUTE], [0])],
157 CY_CHECK_JAVASCRIPTCORE],
158 [AC_MSG_ERROR([Unknown JavaScript engine: $enableval])])
159 ], [CY_CHECK_JAVASCRIPT])
163 APR_FIND_APR([], [], [1], [1])
164 AS_CASE([$apr_found], [yes], [
165 AC_LIB_APPENDTOVAR([CPPFLAGS], [`$apr_config --includes`])
166 AC_LIB_APPENDTOVAR([LTLIBAPR], [`$apr_config --link-libtool`])
168 ], [AC_MSG_ERROR([missing "libapr"])])
171 AC_DEFUN([CY_CHECK_PKG_CONFIG_LIBFFI], [
172 PKG_CHECK_MODULES([LIBFFI], [libffi], [
173 AC_LIB_APPENDTOVAR([CXXFLAGS], [`$PKG_CONFIG --cflags libffi`])
174 AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs libffi`])
175 ], [AC_MSG_ERROR([missing "libffi"])])])
177 AM_CONDITIONAL([CY_EXECUTE], [test "x$CY_EXECUTE" = x1])
179 AS_CASE([$CY_EXECUTE], [1], [
180 AC_CHECK_HEADERS([ffi.h ffi/ffi.h], [break])
181 AS_IF([test "x$ac_cv_header_ffi_h" = xno && test "x$ac_cv_header_ffi_ffi_h" = xno], [
182 CY_CHECK_PKG_CONFIG_LIBFFI
184 AC_SEARCH_LIBS([ffi_call], [ffi])
185 AS_CASE([$ac_cv_search_ffi_call], [no], [CY_CHECK_PKG_CONFIG_LIBFFI])
188 AC_LANG_PUSH([Objective C++])
190 AC_MSG_CHECKING([if we really have Objective C++])
191 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [
194 ], [AC_MSG_RESULT([no])])
196 AS_IF([test "x$CY_OBJECTIVEC" = x1], [
197 AC_CHECK_FRAMEWORK([CoreFoundation], [
198 #include <CoreFoundation/CFBase.h>
199 ], [CFAllocatorGetDefault();], [
200 AC_SUBST([CY_OBJECTIVEC])
202 AC_CHECK_FRAMEWORK([Foundation], [
203 #include <Foundation/NSObject.h>
204 ], [[[[NSObject alloc] init];]])
206 AC_CHECK_FRAMEWORK([WebKit], [
207 #include <WebKit/WebScriptObject.h>
208 ], [[[[WebScriptObject alloc] init];]])
210 AC_ARG_VAR([GNUSTEP_CONFIG], [prints information about the current gnustep installation])
211 AC_CHECK_PROGS([GNUSTEP_CONFIG], [gnustep-config])
213 AS_IF([test "x$GNUSTEP_CONFIG" != x], [
214 AC_SUBST([CY_OBJECTIVEC])
215 AC_LIB_APPENDTOVAR([OBJCXXFLAGS], [`$GNUSTEP_CONFIG --objc-flags`])
216 AC_LIB_APPENDTOVAR([LIBS], [`$GNUSTEP_CONFIG --base-libs`])
217 ], [AC_SUBST([CY_OBJECTIVEC], [0])])
221 AC_LANG_POP([Objective C++])
224 AM_CONDITIONAL([CY_OBJECTIVEC], [test "x$CY_OBJECTIVEC" = x1])
227 AS_CASE([$vl_cv_lib_readline], [no], [AC_MSG_ERROR([missing "libreadline"])])
229 dnl XXX: AX_LIB_READLINE totally lied: it was suposed to figure this out :(
230 dnl XXX: this should only be linked into the main binary (not the library)
231 AC_SEARCH_LIBS([cur_term], [termcap])
233 dnl XXX: saurik doesn't understand what this does
237 AS_CASE([$am_cv_func_iconv], [yes], [], [
238 for cy_iconv_prefix_arg in $CFLAGS $CXXFLAGS $OBJCXXFLAGS $LDFLAGS $LIBS; do
239 AS_CASE([$cy_iconv_prefix_arg], [-I*], [
240 AC_LIB_APPENDTOVAR([cy_iconv_prefixes], [`echo $cy_iconv_prefix_arg | sed -e 's/^-I//;s|/include$||'`])
242 AC_LIB_APPENDTOVAR([cy_iconv_prefixes], [`echo $cy_iconv_prefix_arg | sed -e 's/^-L//;s|/lib$||'`])
245 for with_libiconv_prefix in $cy_iconv_prefixes; do
246 AS_UNSET([am_cv_func_iconv])
247 AM_ICONV_LINKFLAGS_BODY
251 AS_CASE([$am_cv_func_iconv], [yes], [], [AC_MSG_ERROR([missing "libiconv"])])
256 AC_SUBST([SO], [$acl_shlibext])
258 AC_CHECK_HEADER([mach/mach.h], [
259 AC_CHECK_TOOLS([_LIPO], [lipo], [AC_MSG_ERROR([missing "lipo"])])
260 AC_CHECK_TOOLS([_NM], [nm], [AC_MSG_ERROR([missing "nm"])])
261 AC_CHECK_TOOLS([_OTOOL], [otool], [AC_MSG_ERROR([missing "otool"])])
262 AC_SUBST([CY_MACH], [1])
263 AC_SUBST([CY_ATTACH_GROUP], [procmod])
266 AM_CONDITIONAL([CY_MACH], [test "x$CY_MACH" = x1])
268 AC_CONFIG_FILES([Makefile])