]>
Commit | Line | Data |
---|---|---|
c15969fd JF |
1 | dnl Cycript - Optimizing JavaScript Compiler/Runtime |
2 | dnl Copyright (C) 2009-2013 Jay Freeman (saurik) | |
3 | ||
4 | dnl GNU General Public License, Version 3 {{{ | |
5 | dnl | |
6 | dnl Cycript is free software: you can redistribute it and/or modify | |
7 | dnl it under the terms of the GNU General Public License as published | |
8 | dnl by the Free Software Foundation, either version 3 of the License, | |
9 | dnl or (at your option) any later version. | |
10 | dnl | |
11 | dnl Cycript is distributed in the hope that it will be useful, but | |
12 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | dnl GNU General Public License for more details. | |
15 | dnl | |
16 | dnl You should have received a copy of the GNU General Public License | |
17 | dnl along with Cycript. If not, see <http://www.gnu.org/licenses/>. | |
18 | dnl }}} | |
19 | ||
9c60689e | 20 | AC_PREREQ([2.65]) |
c7aa54aa | 21 | AC_INIT([Cycript], [0.9], [saurik@saurik.com], [cycript], [http://www.cycript.org/]) |
66170b30 JF |
22 | AC_COPYRIGHT([Copyright (C) 2009-2012 Jay Freeman (saurik)]) |
23 | ||
35fa52c0 | 24 | AC_CONFIG_SRCDIR([Console.cpp]) |
6b66678a | 25 | AC_CONFIG_AUX_DIR([.]) |
66170b30 JF |
26 | AC_CONFIG_MACRO_DIR([m4]) |
27 | ||
9228a43a | 28 | AM_INIT_AUTOMAKE([-Wall -Werror foreign]) |
a243b558 JF |
29 | |
30 | AC_PROG_CXX | |
31 | AC_PROG_OBJCXX | |
32 | AM_PROG_AR | |
33 | AC_PROG_INSTALL | |
34 | ||
549f29b5 | 35 | LT_INIT([disable-static]) |
66170b30 JF |
36 | |
37 | AC_LANG([C++]) | |
38 | ||
3fd51f51 | 39 | PKG_PROG_PKG_CONFIG([0.22]) |
66170b30 | 40 | |
66170b30 JF |
41 | AC_PATH_PROG([_BASH], [bash], [AC_MSG_ERROR([missing "bash"])]) |
42 | AC_PATH_PROG([GIT], [git]) | |
43 | AC_PATH_PROG([TIME], [time]) | |
44 | ||
45 | dnl CY_CHECK_PROGS_VERSION {{{ | |
e9c9a47c | 46 | AC_DEFUN([CY_CHECK_PROGS_VERSION], [ |
66170b30 JF |
47 | AC_ARG_VAR(]$1[, ]$3[) |
48 | ||
49 | AC_MSG_CHECKING(for ]$2[ >= ]$5[) | |
50 | AC_PATH_PROGS_FEATURE_CHECK(]$1[, ]$2[, | |
51 | AS_VAR_SET(version, [`$ac_path_]$1[ ]$4[`]) | |
52 | AS_VAR_IF(version, [], , | |
53 | AS_VERSION_COMPARE($version, ]$5[, , | |
54 | ac_cv_path_]$1[=$ac_path_]$1[, | |
55 | ac_cv_path_]$1[=$ac_path_]$1[)) | |
56 | , AC_MSG_RESULT(no)) | |
57 | ||
58 | AS_IF([true], [ | |
59 | AC_SUBST(]$1[, $ac_cv_path_]$1[) | |
60 | AC_MSG_RESULT($]$1[) | |
61 | ], AS_IF([true], [ | |
62 | AC_MSG_ERROR(You need ]$2[ ]$5[ or greater) | |
63 | ], [ | |
64 | AC_SUBST(]$1[, [:]) | |
65 | AC_MSG_RESULT([no]) | |
66 | ])) | |
67 | ]) dnl }}} | |
68 | ||
69 | CY_CHECK_PROGS_VERSION([BISON], [bison], [GNU Project parser generator (yacc replacement)], | |
70 | [-V | $SED -e '1 s/^bison (GNU Bison) \(.*\)$/\1/p;d'], [2.3]) | |
71 | CY_CHECK_PROGS_VERSION([FLEX], [flex], [the fast lexical analyser generator], | |
72 | [--version | $SED -e '1 s/^@<:@^0-9.@:>@* \(@<:@0-9.@:>@*\).*$/\1/p;d'], [2.5.33]) | |
73 | CY_CHECK_PROGS_VERSION([GPERF], [gperf], [perfect hash function generator], | |
74 | [--version | $SED -e '1 s/^.* \(@<:@0-9.@:>@*\)$/\1/p;d'], [3.0.3]) | |
75 | CY_CHECK_PROGS_VERSION([GNUTAR], [tar gtar gnutar], [a very sticky lump of files], | |
76 | [--version | $SED -e '1 s/^tar (GNU tar) \(.*\)$/\1/p;d'], [1.19]) | |
77 | ||
9228a43a JF |
78 | AC_MSG_CHECKING([bison for %code{}]) |
79 | echo '%code{}%%_:' >conftest.y | |
80 | if $BISON conftest.y -o/dev/null 2>/dev/null; then | |
81 | AC_LIB_APPENDTOVAR([CY_FILTERS], [Bison24]) | |
82 | AC_MSG_RESULT([yes]) | |
83 | else | |
84 | AC_LIB_APPENDTOVAR([CY_FILTERS], [Bison23]) | |
85 | AC_MSG_RESULT([no]) | |
86 | fi | |
87 | ||
88 | rm -f conftest.y | |
89 | AC_SUBST([CY_FILTERS]) | |
90 | ||
66170b30 JF |
91 | dnl CY_TRY {{{ |
92 | AC_DEFUN([CY_SUCCESS], [cy_good=1]) | |
93 | AC_DEFUN([CY_FAILURE], [cy_good=0]) | |
94 | ||
95 | AC_DEFUN([CY_TRY], [ | |
96 | cy_save=$]$1[ | |
97 | AC_LIB_APPENDTOVAR(]$1[, ]$2[) | |
98 | ]$3[ | |
99 | ]$1[=$cy_save | |
100 | AS_IF([test "x$cy_good" = x1], ]$4[, ]$5[) | |
101 | ]) dnl }}} | |
102 | ||
103 | AC_DEFUN([CY_COMPILE_FLAG], [ | |
104 | AC_LIB_APPENDTOVAR([CFLAGS], ]$1[) | |
105 | AC_LIB_APPENDTOVAR([CXXFLAGS], ]$1[) | |
106 | AC_LIB_APPENDTOVAR([OBJCCXXFLAGS], ]$1[) | |
1504c9b8 | 107 | ]) |
66170b30 JF |
108 | |
109 | AC_DEFUN([CY_TEST_FLAG], [ | |
110 | AC_MSG_CHECKING([for ]]$1[) | |
111 | CY_TRY([CXXFLAGS], $1, [ | |
112 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], | |
113 | [CY_SUCCESS], [CY_FAILURE]) | |
114 | ], [ | |
115 | AC_MSG_RESULT([yes]) | |
116 | CY_COMPILE_FLAG($1) | |
117 | ], [AC_MSG_RESULT([no])]) | |
118 | ]) | |
119 | ||
120 | AX_CFLAGS_WARN_ALL | |
121 | AX_CXXFLAGS_WARN_ALL | |
122 | ||
123 | CY_TEST_FLAG([-Wno-overloaded-virtual]) | |
124 | CY_TEST_FLAG([-Wno-parentheses]) | |
125 | CY_TEST_FLAG([-Wno-unneeded-internal-declaration]) | |
126 | ||
127 | dnl -arch * {{{ | |
128 | for cy_arch in ppc ppc64 i386 x86_64 armv6; do | |
129 | AC_MSG_CHECKING([for -arch $cy_arch]) | |
130 | CY_TRY([CXXFLAGS], ["-arch $cy_arch"], [ | |
131 | AC_TRY_LINK([], [], [CY_SUCCESS], [CY_FAILURE]) | |
132 | ], [ | |
133 | AC_MSG_RESULT([yes]) | |
a243b558 | 134 | AC_LIB_APPENDTOVAR([CY_ARCH], ["-arch $cy_arch"]) |
66170b30 | 135 | ], [AC_MSG_RESULT([no])]) |
a243b558 JF |
136 | done |
137 | AC_SUBST([CY_ARCH]) | |
138 | dnl }}} | |
66170b30 JF |
139 | |
140 | dnl --with-frameworks {{{ | |
632b71ea | 141 | AC_ARG_WITH([frameworks], [AS_HELP_STRING( |
66170b30 JF |
142 | [--with-frameworks=DIRS], |
143 | [add to DIRS (space separated) to the Darwin include path for frameworks with -F] | |
632b71ea | 144 | )], [ |
66170b30 JF |
145 | for cy_framework in $withval; do |
146 | CY_COMPILE_FLAG([-F$cy_framework]) | |
147 | done | |
148 | ]) dnl }}} | |
149 | dnl --enable-javascript {{{ | |
b66977f1 | 150 | AC_DEFUN([CY_CHECK_JAVASCRIPTCORE], [ |
66170b30 JF |
151 | PKG_CHECK_MODULES([WEBKIT], [webkit-1.0], [ |
152 | AC_SUBST([CY_EXECUTE], [1]) | |
153 | AC_LIB_APPENDTOVAR([CXXFLAGS], [`$PKG_CONFIG --cflags webkit-1.0`]) | |
154 | AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs webkit-1.0`]) | |
155 | ], [ | |
156 | PKG_CHECK_MODULES([WEBKIT], [WebKitGtk], [ | |
157 | AC_SUBST([CY_EXECUTE], [1]) | |
158 | AC_LIB_APPENDTOVAR([CXXFLAGS], [`$PKG_CONFIG --cflags WebKitGtk`]) | |
159 | AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs WebKitGtk`]) | |
160 | ], [ | |
161 | AC_CHECK_FRAMEWORK([JavaScriptCore], [ | |
162 | #include <JavaScriptCore/JSBase.h> | |
163 | ], [ | |
164 | JSEvaluateScript(0, 0, 0, 0, 0, 0); | |
165 | ], [ | |
166 | AC_SUBST([CY_EXECUTE], [1]) | |
167 | ]) | |
168 | ]) | |
169 | ]) | |
35fa52c0 | 170 | ]) |
66170b30 | 171 | |
b66977f1 | 172 | AC_DEFUN([CY_CHECK_JAVASCRIPT], [ |
66170b30 JF |
173 | CY_CHECK_JAVASCRIPTCORE]) |
174 | ||
b66977f1 | 175 | AC_ARG_ENABLE([javascript], [AS_HELP_STRING( |
66170b30 JF |
176 | [--enable-javascript@<:@=ENGINE@:>@], |
177 | [use a JavaScript runtime (currently the only available option for ENGINE is JavaScriptCore) @<:@default=yes@:>@] | |
b66977f1 | 178 | )], [ |
66170b30 JF |
179 | AS_CASE([$enableval], |
180 | [yes], [ | |
181 | CY_CHECK_JAVASCRIPT], | |
182 | [no], [ | |
183 | AC_SUBST([CY_EXECUTE], [0])], | |
184 | [JavaScriptCore], [ | |
185 | CY_CHECK_JAVASCRIPTCORE], | |
186 | [AC_MSG_ERROR([Unknown JavaScript engine: $enableval])]) | |
b66977f1 | 187 | ], [CY_CHECK_JAVASCRIPT]) |
66170b30 JF |
188 | dnl }}} |
189 | ||
190 | dnl APR_FIND_APR {{{ | |
191 | APR_FIND_APR([], [], [1], [1]) | |
192 | AS_CASE([$apr_found], [yes], [ | |
193 | AC_LIB_APPENDTOVAR([CPPFLAGS], [`$apr_config --includes`]) | |
812bb90b JF |
194 | AC_LIB_APPENDTOVAR([LTLIBAPR], [`$apr_config --link-libtool`]) |
195 | AC_SUBST([LTLIBAPR]) | |
66170b30 JF |
196 | ], [AC_MSG_ERROR([missing "libapr"])]) |
197 | dnl }}} | |
198 | ||
e5cca37d | 199 | AC_DEFUN([CY_CHECK_PKG_CONFIG_LIBFFI], [ |
66170b30 JF |
200 | PKG_CHECK_MODULES([LIBFFI], [libffi], [ |
201 | AC_LIB_APPENDTOVAR([CXXFLAGS], [`$PKG_CONFIG --cflags libffi`]) | |
202 | AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs libffi`]) | |
203 | ], [AC_MSG_ERROR([missing "libffi"])])]) | |
204 | ||
a243b558 JF |
205 | AM_CONDITIONAL([CY_EXECUTE], [test "x$CY_EXECUTE" = x1]) |
206 | ||
e5cca37d | 207 | AS_CASE([$CY_EXECUTE], [1], [ |
66170b30 JF |
208 | AC_CHECK_HEADERS([ffi.h ffi/ffi.h], [break]) |
209 | AS_IF([test "x$ac_cv_header_ffi_h" = xno && test "x$ac_cv_header_ffi_ffi_h" = xno], [ | |
210 | CY_CHECK_PKG_CONFIG_LIBFFI | |
211 | ], [ | |
212 | AC_SEARCH_LIBS([ffi_call], [ffi]) | |
213 | AS_CASE([$ac_cv_search_ffi_call], [no], [CY_CHECK_PKG_CONFIG_LIBFFI]) | |
214 | ]) | |
215 | ||
216 | AC_LANG_PUSH([Objective C++]) | |
217 | ||
218 | AC_MSG_CHECKING([if we really have Objective C++]) | |
219 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [ | |
220 | CY_OBJECTIVEC=1 | |
221 | AC_MSG_RESULT([yes]) | |
222 | ], [AC_MSG_RESULT([no])]) | |
223 | ||
224 | AS_IF([test "x$CY_OBJECTIVEC" = x1], [ | |
225 | AC_CHECK_FRAMEWORK([CoreFoundation], [ | |
226 | #include <CoreFoundation/CFBase.h> | |
227 | ], [CFAllocatorGetDefault();], [ | |
228 | AC_SUBST([CY_OBJECTIVEC]) | |
229 | ||
230 | AC_CHECK_FRAMEWORK([Foundation], [ | |
231 | #include <Foundation/NSObject.h> | |
232 | ], [[[[NSObject alloc] init];]]) | |
233 | ||
234 | AC_CHECK_FRAMEWORK([WebKit], [ | |
235 | #include <WebKit/WebScriptObject.h> | |
236 | ], [[[[WebScriptObject alloc] init];]]) | |
237 | ], [ | |
238 | AC_ARG_VAR([GNUSTEP_CONFIG], [prints information about the current gnustep installation]) | |
239 | AC_CHECK_PROGS([GNUSTEP_CONFIG], [gnustep-config]) | |
240 | ||
241 | AS_IF([test "x$GNUSTEP_CONFIG" != x], [ | |
242 | AC_SUBST([CY_OBJECTIVEC]) | |
243 | AC_LIB_APPENDTOVAR([OBJCXXFLAGS], [`$GNUSTEP_CONFIG --objc-flags`]) | |
244 | AC_LIB_APPENDTOVAR([LIBS], [`$GNUSTEP_CONFIG --base-libs`]) | |
245 | ], [AC_SUBST([CY_OBJECTIVEC], [0])]) | |
246 | ]) | |
247 | ]) | |
248 | ||
249 | AC_LANG_POP([Objective C++]) | |
3fd51f51 | 250 | ]) |
66170b30 | 251 | |
a243b558 JF |
252 | AM_CONDITIONAL([CY_OBJECTIVEC], [test "x$CY_OBJECTIVEC" = x1]) |
253 | ||
6f9aea2b JF |
254 | AC_DEFUN([CY_LT_LIB], [ |
255 | cy_save=$LIBS | |
256 | LIBS= | |
257 | ]$2[ | |
258 | ]$1[=$LIBS | |
259 | LIBS=$cy_save | |
260 | AC_SUBST(]$1[) | |
261 | ]) | |
262 | ||
263 | CY_LT_LIB([LTLIBREADLINE], [AX_LIB_READLINE]) | |
264 | AS_CASE([$ax_cv_lib_readline], [no], [AC_MSG_ERROR([missing "libreadline"])]) | |
66170b30 | 265 | |
6f9aea2b | 266 | CY_LT_LIB([LTLIBTERMCAP], [AC_SEARCH_LIBS([cur_term], [termcap])]) |
a243b558 | 267 | |
66170b30 JF |
268 | dnl XXX: saurik doesn't understand what this does |
269 | dnl AM_ICONV {{{ | |
5053a6d1 DWT |
270 | AC_LANG_PUSH([C]) |
271 | AM_ICONV | |
058f1bc8 | 272 | AS_CASE([$am_cv_func_iconv], [yes], [], [ |
66170b30 JF |
273 | for cy_iconv_prefix_arg in $CFLAGS $CXXFLAGS $OBJCXXFLAGS $LDFLAGS $LIBS; do |
274 | AS_CASE([$cy_iconv_prefix_arg], [-I*], [ | |
275 | AC_LIB_APPENDTOVAR([cy_iconv_prefixes], [`echo $cy_iconv_prefix_arg | sed -e 's/^-I//;s|/include$||'`]) | |
276 | ], [-L*], [ | |
277 | AC_LIB_APPENDTOVAR([cy_iconv_prefixes], [`echo $cy_iconv_prefix_arg | sed -e 's/^-L//;s|/lib$||'`]) | |
278 | ]) | |
279 | done | |
280 | for with_libiconv_prefix in $cy_iconv_prefixes; do | |
281 | AS_UNSET([am_cv_func_iconv]) | |
282 | AM_ICONV_LINKFLAGS_BODY | |
283 | AM_ICONV | |
284 | done | |
058f1bc8 | 285 | ]) |
66170b30 | 286 | AS_CASE([$am_cv_func_iconv], [yes], [], [AC_MSG_ERROR([missing "libiconv"])]) |
058f1bc8 | 287 | AC_LANG_POP([C]) |
66170b30 JF |
288 | dnl }}} |
289 | ||
290 | AC_SUBST([LTFLAGS]) | |
9777bd50 | 291 | AC_SUBST([SO], [$acl_shlibext]) |
66170b30 JF |
292 | |
293 | AC_CHECK_HEADER([mach/mach.h], [ | |
66170b30 JF |
294 | AC_CHECK_TOOLS([_LIPO], [lipo], [AC_MSG_ERROR([missing "lipo"])]) |
295 | AC_CHECK_TOOLS([_NM], [nm], [AC_MSG_ERROR([missing "nm"])]) | |
a243b558 | 296 | AC_CHECK_TOOLS([_OTOOL], [otool], [AC_MSG_ERROR([missing "otool"])]) |
66170b30 JF |
297 | AC_SUBST([CY_MACH], [1]) |
298 | AC_SUBST([CY_ATTACH_GROUP], [procmod]) | |
e1cce270 | 299 | ]) |
66170b30 | 300 | |
a243b558 | 301 | AM_CONDITIONAL([CY_MACH], [test "x$CY_MACH" = x1]) |
66170b30 | 302 | |
a243b558 | 303 | AC_CONFIG_FILES([Makefile]) |
9c60689e | 304 | AC_OUTPUT |