]>
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], [ |
4a762893 JF |
151 | AC_CHECK_FRAMEWORK([JavaScriptCore], [ |
152 | #include <JavaScriptCore/JSBase.h> | |
153 | ], [ | |
154 | JSEvaluateScript(0, 0, 0, 0, 0, 0); | |
155 | ], [ | |
66170b30 | 156 | AC_SUBST([CY_EXECUTE], [1]) |
66170b30 | 157 | ], [ |
4a762893 JF |
158 | for cy_webkit_pkg in "webkit-1.0" "WebKitGtk"; do |
159 | PKG_CHECK_MODULES([WEBKIT], [$cy_webkit_pkg], [ | |
66170b30 | 160 | AC_SUBST([CY_EXECUTE], [1]) |
4a762893 JF |
161 | CY_COMPILE_FLAG([`$PKG_CONFIG --cflags $cy_webkit_pkg`]) |
162 | AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs $cy_webkit_pkg`]) | |
163 | ], [:]); if test "x$CY_EXECUTE" = x1; then break; fi | |
164 | done | |
66170b30 | 165 | ]) |
35fa52c0 | 166 | ]) |
66170b30 | 167 | |
b66977f1 | 168 | AC_DEFUN([CY_CHECK_JAVASCRIPT], [ |
66170b30 JF |
169 | CY_CHECK_JAVASCRIPTCORE]) |
170 | ||
b66977f1 | 171 | AC_ARG_ENABLE([javascript], [AS_HELP_STRING( |
66170b30 JF |
172 | [--enable-javascript@<:@=ENGINE@:>@], |
173 | [use a JavaScript runtime (currently the only available option for ENGINE is JavaScriptCore) @<:@default=yes@:>@] | |
b66977f1 | 174 | )], [ |
66170b30 JF |
175 | AS_CASE([$enableval], |
176 | [yes], [ | |
177 | CY_CHECK_JAVASCRIPT], | |
178 | [no], [ | |
179 | AC_SUBST([CY_EXECUTE], [0])], | |
180 | [JavaScriptCore], [ | |
181 | CY_CHECK_JAVASCRIPTCORE], | |
182 | [AC_MSG_ERROR([Unknown JavaScript engine: $enableval])]) | |
b66977f1 | 183 | ], [CY_CHECK_JAVASCRIPT]) |
66170b30 JF |
184 | dnl }}} |
185 | ||
186 | dnl APR_FIND_APR {{{ | |
187 | APR_FIND_APR([], [], [1], [1]) | |
188 | AS_CASE([$apr_found], [yes], [ | |
189 | AC_LIB_APPENDTOVAR([CPPFLAGS], [`$apr_config --includes`]) | |
812bb90b JF |
190 | AC_LIB_APPENDTOVAR([LTLIBAPR], [`$apr_config --link-libtool`]) |
191 | AC_SUBST([LTLIBAPR]) | |
66170b30 JF |
192 | ], [AC_MSG_ERROR([missing "libapr"])]) |
193 | dnl }}} | |
194 | ||
e5cca37d | 195 | AC_DEFUN([CY_CHECK_PKG_CONFIG_LIBFFI], [ |
66170b30 | 196 | PKG_CHECK_MODULES([LIBFFI], [libffi], [ |
012153b8 | 197 | CY_COMPILE_FLAG([`$PKG_CONFIG --cflags libffi`]) |
66170b30 JF |
198 | AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs libffi`]) |
199 | ], [AC_MSG_ERROR([missing "libffi"])])]) | |
200 | ||
a243b558 JF |
201 | AM_CONDITIONAL([CY_EXECUTE], [test "x$CY_EXECUTE" = x1]) |
202 | ||
e5cca37d | 203 | AS_CASE([$CY_EXECUTE], [1], [ |
66170b30 JF |
204 | AC_CHECK_HEADERS([ffi.h ffi/ffi.h], [break]) |
205 | AS_IF([test "x$ac_cv_header_ffi_h" = xno && test "x$ac_cv_header_ffi_ffi_h" = xno], [ | |
206 | CY_CHECK_PKG_CONFIG_LIBFFI | |
207 | ], [ | |
208 | AC_SEARCH_LIBS([ffi_call], [ffi]) | |
209 | AS_CASE([$ac_cv_search_ffi_call], [no], [CY_CHECK_PKG_CONFIG_LIBFFI]) | |
210 | ]) | |
211 | ||
212 | AC_LANG_PUSH([Objective C++]) | |
213 | ||
214 | AC_MSG_CHECKING([if we really have Objective C++]) | |
215 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [ | |
216 | CY_OBJECTIVEC=1 | |
217 | AC_MSG_RESULT([yes]) | |
218 | ], [AC_MSG_RESULT([no])]) | |
219 | ||
220 | AS_IF([test "x$CY_OBJECTIVEC" = x1], [ | |
221 | AC_CHECK_FRAMEWORK([CoreFoundation], [ | |
222 | #include <CoreFoundation/CFBase.h> | |
223 | ], [CFAllocatorGetDefault();], [ | |
224 | AC_SUBST([CY_OBJECTIVEC]) | |
225 | ||
226 | AC_CHECK_FRAMEWORK([Foundation], [ | |
227 | #include <Foundation/NSObject.h> | |
228 | ], [[[[NSObject alloc] init];]]) | |
229 | ||
230 | AC_CHECK_FRAMEWORK([WebKit], [ | |
231 | #include <WebKit/WebScriptObject.h> | |
232 | ], [[[[WebScriptObject alloc] init];]]) | |
233 | ], [ | |
234 | AC_ARG_VAR([GNUSTEP_CONFIG], [prints information about the current gnustep installation]) | |
235 | AC_CHECK_PROGS([GNUSTEP_CONFIG], [gnustep-config]) | |
236 | ||
237 | AS_IF([test "x$GNUSTEP_CONFIG" != x], [ | |
238 | AC_SUBST([CY_OBJECTIVEC]) | |
239 | AC_LIB_APPENDTOVAR([OBJCXXFLAGS], [`$GNUSTEP_CONFIG --objc-flags`]) | |
240 | AC_LIB_APPENDTOVAR([LIBS], [`$GNUSTEP_CONFIG --base-libs`]) | |
241 | ], [AC_SUBST([CY_OBJECTIVEC], [0])]) | |
242 | ]) | |
243 | ]) | |
244 | ||
245 | AC_LANG_POP([Objective C++]) | |
3fd51f51 | 246 | ]) |
66170b30 | 247 | |
a243b558 JF |
248 | AM_CONDITIONAL([CY_OBJECTIVEC], [test "x$CY_OBJECTIVEC" = x1]) |
249 | ||
6f9aea2b JF |
250 | AC_DEFUN([CY_LT_LIB], [ |
251 | cy_save=$LIBS | |
252 | LIBS= | |
253 | ]$2[ | |
254 | ]$1[=$LIBS | |
255 | LIBS=$cy_save | |
256 | AC_SUBST(]$1[) | |
257 | ]) | |
258 | ||
259 | CY_LT_LIB([LTLIBREADLINE], [AX_LIB_READLINE]) | |
260 | AS_CASE([$ax_cv_lib_readline], [no], [AC_MSG_ERROR([missing "libreadline"])]) | |
66170b30 | 261 | |
6f9aea2b | 262 | CY_LT_LIB([LTLIBTERMCAP], [AC_SEARCH_LIBS([cur_term], [termcap])]) |
a243b558 | 263 | |
5053a6d1 DWT |
264 | AC_LANG_PUSH([C]) |
265 | AM_ICONV | |
66170b30 | 266 | AS_CASE([$am_cv_func_iconv], [yes], [], [AC_MSG_ERROR([missing "libiconv"])]) |
058f1bc8 | 267 | AC_LANG_POP([C]) |
66170b30 JF |
268 | |
269 | AC_SUBST([LTFLAGS]) | |
9777bd50 | 270 | AC_SUBST([SO], [$acl_shlibext]) |
66170b30 | 271 | |
1f11d1b4 JF |
272 | AS_IF([test "x$CY_EXECUTE" = x1], [ |
273 | AC_CHECK_HEADER([mach/mach.h], [ | |
274 | AC_CHECK_TOOLS([_LIPO], [lipo], [AC_MSG_ERROR([missing "lipo"])]) | |
275 | AC_CHECK_TOOLS([_NM], [nm], [AC_MSG_ERROR([missing "nm"])]) | |
276 | AC_CHECK_TOOLS([_OTOOL], [otool], [AC_MSG_ERROR([missing "otool"])]) | |
277 | AC_SUBST([CY_ATTACH_GROUP], [procmod]) | |
278 | AC_SUBST([CY_MACH], [1])])]) | |
a243b558 | 279 | AM_CONDITIONAL([CY_MACH], [test "x$CY_MACH" = x1]) |
66170b30 | 280 | |
a243b558 | 281 | AC_CONFIG_FILES([Makefile]) |
9c60689e | 282 | AC_OUTPUT |