]> git.saurik.com Git - cycript.git/blob - configure.ac
Detect jni.h and link Android build against Dalvik.
[cycript.git] / configure.ac
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
20 AC_PREREQ([2.65])
21 AC_INIT([Cycript], [0.9], [saurik@saurik.com], [cycript], [http://www.cycript.org/])
22 AC_COPYRIGHT([Copyright (C) 2009-2012 Jay Freeman (saurik)])
23
24 AC_CONFIG_SRCDIR([Console.cpp])
25 AC_CONFIG_AUX_DIR([.])
26 AC_CONFIG_MACRO_DIR([m4])
27 AC_CONFIG_HEADERS([config.h])
28
29 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
30 AM_MAINTAINER_MODE([disable])
31
32 AC_PROG_CC
33 AC_PROG_CXX
34 AC_PROG_OBJCXX
35
36 AM_PROG_AR
37 AC_PROG_INSTALL
38
39 LT_INIT([disable-static])
40
41 AC_LANG([C++])
42
43 PKG_PROG_PKG_CONFIG([0.22])
44
45 AC_PATH_PROG([GIT], [git])
46 AC_PATH_PROG([TIME], [time])
47
48 dnl CY_CHECK_PROGS_VERSION {{{
49 AC_DEFUN([CY_CHECK_PROGS_VERSION], [
50 AC_ARG_VAR(]$1[, ]$3[)
51
52 AC_MSG_CHECKING(for ]$2[ >= ]$5[)
53 AC_PATH_PROGS_FEATURE_CHECK(]$1[, ]$2[,
54 AS_VAR_SET(version, [`$ac_path_]$1[ ]$4[`])
55 AS_VAR_IF(version, [], ,
56 AS_VERSION_COMPARE($version, ]$5[, ,
57 ac_cv_path_]$1[=$ac_path_]$1[,
58 ac_cv_path_]$1[=$ac_path_]$1[))
59 , AC_MSG_RESULT(no))
60
61 AS_IF([true], [
62 AC_SUBST(]$1[, $ac_cv_path_]$1[)
63 AC_MSG_RESULT($]$1[)
64 ], AS_IF([true], [
65 AC_MSG_ERROR(You need ]$2[ ]$5[ or greater)
66 ], [
67 AC_SUBST(]$1[, [:])
68 AC_MSG_RESULT([no])
69 ]))
70 ]) dnl }}}
71
72 CY_CHECK_PROGS_VERSION([BISON], [bison], [GNU Project parser generator (yacc replacement)],
73 [-V | $SED -e '1 s/^bison (GNU Bison) \(.*\)$/\1/p;d'], [2.3])
74 CY_CHECK_PROGS_VERSION([FLEX], [flex], [the fast lexical analyser generator],
75 [--version | $SED -e '1 s/^@<:@^0-9.@:>@* \(@<:@0-9.@:>@*\).*$/\1/p;d'], [2.5.33])
76 CY_CHECK_PROGS_VERSION([GPERF], [gperf], [perfect hash function generator],
77 [--version | $SED -e '1 s/^.* \(@<:@0-9.@:>@*\)$/\1/p;d'], [3.0.3])
78 CY_CHECK_PROGS_VERSION([GNUTAR], [tar gtar gnutar], [a very sticky lump of files],
79 [--version | $SED -e '1 s/^tar (GNU tar) \(.*\)$/\1/p;d'], [1.19])
80
81 AC_MSG_CHECKING([bison for %code{}])
82 echo '%code{}%%_:' >conftest.y
83 if $BISON conftest.y -o/dev/null 2>/dev/null; then
84 AC_LIB_APPENDTOVAR([CY_FILTERS], [Bison24])
85 AC_MSG_RESULT([yes])
86 else
87 AC_LIB_APPENDTOVAR([CY_FILTERS], [Bison23])
88 AC_MSG_RESULT([no])
89 fi
90
91 rm -f conftest.y
92 AC_SUBST([CY_FILTERS])
93
94 dnl CY_TRY {{{
95 AC_DEFUN([CY_SUCCESS], [cy_good=1])
96 AC_DEFUN([CY_FAILURE], [cy_good=0])
97
98 AC_DEFUN([CY_TRY], [
99 cy_save=$]$1[
100 AC_LIB_APPENDTOVAR(]$1[, ]$2[)
101 ]$3[
102 ]$1[=$cy_save
103 AS_IF([test "x$cy_good" = x1], ]$4[, ]$5[)
104 ]) dnl }}}
105
106 AC_DEFUN([CY_TEST_FLAG_], [
107 AC_LANG_PUSH(]$2[)
108 AC_MSG_CHECKING([for ]]$4[[ ]]$1[)
109 CY_TRY(]$3[, $1, [
110 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
111 [CY_SUCCESS], [CY_FAILURE])
112 ], [
113 AC_MSG_RESULT([yes])
114 AC_LIB_APPENDTOVAR(]$3[, ]$1[)
115 ], [AC_MSG_RESULT([no])])
116 AC_LANG_POP(]$2[)
117 ])
118
119 AC_DEFUN([CY_TEST_FLAG], [
120 CY_TEST_FLAG_(]$1[, [C], [CFLAGS], [cc])
121 CY_TEST_FLAG_(]$1[, [C++], [CXXFLAGS], [c++])
122 CY_TEST_FLAG_(]$1[, [Objective C++], [OBJCXXFLAGS], [c++ -ObjC])
123 ])
124
125 AX_CFLAGS_WARN_ALL
126 AX_CXXFLAGS_WARN_ALL
127 AX_FLAGS_WARN_ALL
128
129 CY_TEST_FLAG([-Werror])
130
131 dnl XXX: this is used to support GNU Objective-C struct objc_method
132 CY_TEST_FLAG([-Wno-deprecated-declarations])
133
134 CY_TEST_FLAG([-Wno-dangling-else])
135 CY_TEST_FLAG([-Wno-overloaded-virtual])
136 CY_TEST_FLAG([-Wno-parentheses])
137 CY_TEST_FLAG([-Wno-unneeded-internal-declaration])
138
139 AC_DEFUN([CY_LT_LIB], [
140 cy_save=$LIBS
141 LIBS=
142 ]$2[
143 ]$1[=$LIBS
144 LIBS=$cy_save
145 AC_SUBST(]$1[)
146 ])
147
148 dnl -arch * {{{
149 for cy_arch in ppc ppc64 i386 x86_64 armv6 arm64; do
150 AC_MSG_CHECKING([for -arch $cy_arch])
151 CY_TRY([CXXFLAGS], ["-arch $cy_arch"], [
152 AC_TRY_LINK([], [], [CY_SUCCESS], [CY_FAILURE])
153 ], [
154 AC_MSG_RESULT([yes])
155 AC_LIB_APPENDTOVAR([CY_ARCH], ["-arch $cy_arch"])
156 ], [AC_MSG_RESULT([no])])
157 done
158 AC_SUBST([CY_ARCH])
159 dnl }}}
160
161 dnl --enable-javascript {{{
162 AC_DEFUN([CY_CHECK_JAVASCRIPTCORE], [
163 CY_LT_LIB([LTJAVASCRIPTCORE], [AC_SEARCH_LIBS([JSEvaluateScript], [JavaScriptCore], [
164 AC_SUBST([CY_EXECUTE], [1])
165 ], [AC_CHECK_FRAMEWORK([JavaScriptCore], [
166 #include <JavaScriptCore/JSBase.h>
167 ], [
168 JSEvaluateScript(0, 0, 0, 0, 0, 0);
169 ], [
170 AC_SUBST([CY_EXECUTE], [1])
171 ], [
172 for cy_webkit_pkg in "webkit-1.0" "WebKitGtk"; do
173 PKG_CHECK_MODULES([WEBKIT], [$cy_webkit_pkg], [
174 AC_SUBST([CY_EXECUTE], [1])
175 AC_LIB_APPENDTOVAR([CPPFLAGS], [`$PKG_CONFIG --cflags $cy_webkit_pkg`])
176 AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs $cy_webkit_pkg`])
177 ], [:]); if test "x$CY_EXECUTE" = x1; then break; fi
178 done
179 ])])])
180 ])
181
182 AC_DEFUN([CY_CHECK_JAVASCRIPT], [
183 CY_CHECK_JAVASCRIPTCORE])
184
185 AC_ARG_ENABLE([javascript], [AS_HELP_STRING(
186 [--enable-javascript@<:@=ENGINE@:>@],
187 [use a JavaScript runtime (currently the only available option for ENGINE is JavaScriptCore) @<:@default=yes@:>@]
188 )], [
189 AS_CASE([$enableval],
190 [yes], [
191 CY_CHECK_JAVASCRIPT],
192 [no], [
193 AC_SUBST([CY_EXECUTE], [0])],
194 [JavaScriptCore], [
195 CY_CHECK_JAVASCRIPTCORE],
196 [AC_MSG_ERROR([Unknown JavaScript engine: $enableval])])
197 ], [CY_CHECK_JAVASCRIPT])
198 dnl }}}
199
200 AC_ARG_ENABLE([console], AS_HELP_STRING([--disable-console], [disable console]))
201 AM_CONDITIONAL([CY_CONSOLE], [test "x$enable_console" != "xno"])
202
203 AC_DEFUN([CY_CHECK_PKG_CONFIG_LIBFFI], [
204 PKG_CHECK_MODULES([LIBFFI], [libffi], [
205 AC_LIB_APPENDTOVAR([CPPFLAGS], [`$PKG_CONFIG --cflags libffi`])
206 AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs libffi`])
207 ], [AC_MSG_ERROR([missing "libffi"])])])
208
209 AM_CONDITIONAL([CY_EXECUTE], [test "x$CY_EXECUTE" = x1])
210
211 AS_CASE([$CY_EXECUTE], [1], [
212 AC_CHECK_HEADERS([ffi.h ffi/ffi.h], [break])
213
214 CY_LT_LIB([LTLIBFFI], AS_IF([test "x$ac_cv_header_ffi_h" = xno && test "x$ac_cv_header_ffi_ffi_h" = xno], [
215 CY_CHECK_PKG_CONFIG_LIBFFI
216 ], [
217 AC_SEARCH_LIBS([ffi_call], [ffi])
218 AS_CASE([$ac_cv_search_ffi_call], [no], [CY_CHECK_PKG_CONFIG_LIBFFI])
219 ]))
220
221 AC_CHECK_HEADER([jni.h], [
222 AC_SUBST([CY_JAVA], [1])
223 CY_LT_LIB([LTJAVA], [AC_SEARCH_LIBS([JNI_GetCreatedJavaVMs], [dvm], [
224 ])])
225 ], [
226 AC_SUBST([CY_JAVA], [0])
227 ])
228
229 AC_LANG_PUSH([Objective C++])
230
231 AC_MSG_CHECKING([if we really have Objective C++])
232 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [
233 CY_OBJECTIVEC=1
234 AC_MSG_RESULT([yes])
235 ], [AC_MSG_RESULT([no])])
236
237 AS_IF([test "x$CY_OBJECTIVEC" = x1], [
238 CY_LT_LIB([LTOBJECTIVEC], [AC_CHECK_FRAMEWORK([CoreFoundation], [
239 #include <CoreFoundation/CFBase.h>
240 ], [CFAllocatorGetDefault();], [
241 AC_SUBST([CY_OBJECTIVEC])
242
243 AC_CHECK_FRAMEWORK([Foundation], [
244 #include <Foundation/NSObject.h>
245 ], [[[[NSObject alloc] init];]])
246 ], [
247 AC_ARG_VAR([GNUSTEP_CONFIG], [prints information about the current gnustep installation])
248 AC_CHECK_PROGS([GNUSTEP_CONFIG], [gnustep-config])
249
250 AS_IF([test "x$GNUSTEP_CONFIG" != x], [
251 AC_SUBST([CY_OBJECTIVEC])
252 AC_LIB_APPENDTOVAR([OBJCXXFLAGS], [`$GNUSTEP_CONFIG --objc-flags`])
253 AC_LIB_APPENDTOVAR([LIBS], [`$GNUSTEP_CONFIG --base-libs`])
254 ], [AC_SUBST([CY_OBJECTIVEC], [0])])
255 ])])
256 ])
257
258 AC_LANG_POP([Objective C++])
259 ])
260
261 AM_CONDITIONAL([CY_JAVA], [test "x$CY_JAVA" = x1])
262 AM_CONDITIONAL([CY_OBJECTIVEC], [test "x$CY_OBJECTIVEC" = x1])
263
264 CY_LT_LIB([LTLIBREADLINE], [AX_LIB_READLINE])
265 AS_CASE([$ax_cv_lib_readline], [no], [AC_MSG_ERROR([missing "libreadline"])])
266
267 CY_LT_LIB([LTLIBTERMCAP], [AC_SEARCH_LIBS([cur_term], [termcap ncurses])])
268
269 AC_SUBST([LTLIBGCC])
270
271 AC_SUBST([LTFLAGS])
272 AC_SUBST([SO], [$acl_shlibext])
273
274 AS_IF([test "x$CY_EXECUTE" = x1], [
275 AC_CHECK_HEADER([mach/mach.h], [
276 AC_CHECK_TOOLS([_LIPO], [lipo], [AC_MSG_ERROR([missing "lipo"])])
277 AC_CHECK_TOOLS([_NM], [nm], [AC_MSG_ERROR([missing "nm"])])
278 AC_CHECK_TOOLS([_OTOOL], [otool], [AC_MSG_ERROR([missing "otool"])])
279 AC_SUBST([CY_ATTACH_GROUP], [procmod])
280 AC_SUBST([CY_MACH], [1])])])
281 AM_CONDITIONAL([CY_MACH], [test "x$CY_MACH" = x1])
282
283 AC_CONFIG_FILES([Makefile])
284 AC_OUTPUT