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