]> git.saurik.com Git - cycript.git/blame - configure.ac
Generate new configure script from autoconf inputs.
[cycript.git] / configure.ac
CommitLineData
9c60689e 1AC_PREREQ([2.65])
c7aa54aa 2AC_INIT([Cycript], [0.9], [saurik@saurik.com], [cycript], [http://www.cycript.org/])
66170b30
JF
3AC_COPYRIGHT([Copyright (C) 2009-2012 Jay Freeman (saurik)])
4
35fa52c0 5AC_CONFIG_SRCDIR([Console.cpp])
6b66678a 6AC_CONFIG_AUX_DIR([.])
66170b30
JF
7AC_CONFIG_MACRO_DIR([m4])
8
a243b558
JF
9AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability foreign])
10
11AC_PROG_CXX
12AC_PROG_OBJCXX
13AM_PROG_AR
14AC_PROG_INSTALL
15
549f29b5 16LT_INIT([disable-static])
66170b30
JF
17
18AC_LANG([C++])
19
3fd51f51 20PKG_PROG_PKG_CONFIG([0.22])
66170b30 21
b98e47e6 22AX_CHECK_GNU_MAKE
790e5246
DWT
23AC_SUBST([GMAKE], [$_cv_gnu_make_command])
24AS_IF([test "x$GMAKE" = x], [AC_MSG_ERROR([You need GNU make])])
66170b30
JF
25
26AC_PATH_PROG([_BASH], [bash], [AC_MSG_ERROR([missing "bash"])])
27AC_PATH_PROG([GIT], [git])
28AC_PATH_PROG([TIME], [time])
29
30dnl CY_CHECK_PROGS_VERSION {{{
e9c9a47c 31AC_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
54CY_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])
56CY_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])
58CY_CHECK_PROGS_VERSION([GPERF], [gperf], [perfect hash function generator],
59 [--version | $SED -e '1 s/^.* \(@<:@0-9.@:>@*\)$/\1/p;d'], [3.0.3])
60CY_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
66170b30
JF
63dnl CY_TRY {{{
64AC_DEFUN([CY_SUCCESS], [cy_good=1])
65AC_DEFUN([CY_FAILURE], [cy_good=0])
66
67AC_DEFUN([CY_TRY], [
68 cy_save=$]$1[
69 AC_LIB_APPENDTOVAR(]$1[, ]$2[)
70 ]$3[
71 ]$1[=$cy_save
72 AS_IF([test "x$cy_good" = x1], ]$4[, ]$5[)
73]) dnl }}}
74
75AC_DEFUN([CY_COMPILE_FLAG], [
76 AC_LIB_APPENDTOVAR([CFLAGS], ]$1[)
77 AC_LIB_APPENDTOVAR([CXXFLAGS], ]$1[)
78 AC_LIB_APPENDTOVAR([OBJCCXXFLAGS], ]$1[)
1504c9b8 79])
66170b30
JF
80
81AC_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])
86 ], [
87 AC_MSG_RESULT([yes])
88 CY_COMPILE_FLAG($1)
89 ], [AC_MSG_RESULT([no])])
90])
91
92AX_CFLAGS_WARN_ALL
93AX_CXXFLAGS_WARN_ALL
94
95CY_TEST_FLAG([-Wno-overloaded-virtual])
96CY_TEST_FLAG([-Wno-parentheses])
97CY_TEST_FLAG([-Wno-unneeded-internal-declaration])
98
99dnl -arch * {{{
100for 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])
104 ], [
105 AC_MSG_RESULT([yes])
a243b558 106 AC_LIB_APPENDTOVAR([CY_ARCH], ["-arch $cy_arch"])
66170b30 107 ], [AC_MSG_RESULT([no])])
a243b558
JF
108done
109AC_SUBST([CY_ARCH])
110dnl }}}
66170b30
JF
111
112dnl --with-frameworks {{{
632b71ea 113AC_ARG_WITH([frameworks], [AS_HELP_STRING(
66170b30
JF
114 [--with-frameworks=DIRS],
115 [add to DIRS (space separated) to the Darwin include path for frameworks with -F]
632b71ea 116)], [
66170b30
JF
117 for cy_framework in $withval; do
118 CY_COMPILE_FLAG([-F$cy_framework])
119 done
120]) dnl }}}
121dnl --enable-javascript {{{
b66977f1 122AC_DEFUN([CY_CHECK_JAVASCRIPTCORE], [
66170b30
JF
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`])
127 ], [
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`])
132 ], [
133 AC_CHECK_FRAMEWORK([JavaScriptCore], [
134 #include <JavaScriptCore/JSBase.h>
135 ], [
136 JSEvaluateScript(0, 0, 0, 0, 0, 0);
137 ], [
138 AC_SUBST([CY_EXECUTE], [1])
139 ])
140 ])
141 ])
35fa52c0 142])
66170b30 143
b66977f1 144AC_DEFUN([CY_CHECK_JAVASCRIPT], [
66170b30
JF
145 CY_CHECK_JAVASCRIPTCORE])
146
b66977f1 147AC_ARG_ENABLE([javascript], [AS_HELP_STRING(
66170b30
JF
148 [--enable-javascript@<:@=ENGINE@:>@],
149 [use a JavaScript runtime (currently the only available option for ENGINE is JavaScriptCore) @<:@default=yes@:>@]
b66977f1 150)], [
66170b30
JF
151 AS_CASE([$enableval],
152 [yes], [
153 CY_CHECK_JAVASCRIPT],
154 [no], [
155 AC_SUBST([CY_EXECUTE], [0])],
156 [JavaScriptCore], [
157 CY_CHECK_JAVASCRIPTCORE],
158 [AC_MSG_ERROR([Unknown JavaScript engine: $enableval])])
b66977f1 159], [CY_CHECK_JAVASCRIPT])
66170b30
JF
160dnl }}}
161
162dnl APR_FIND_APR {{{
163APR_FIND_APR([], [], [1], [1])
164AS_CASE([$apr_found], [yes], [
165 AC_LIB_APPENDTOVAR([CPPFLAGS], [`$apr_config --includes`])
812bb90b
JF
166 AC_LIB_APPENDTOVAR([LTLIBAPR], [`$apr_config --link-libtool`])
167 AC_SUBST([LTLIBAPR])
66170b30
JF
168], [AC_MSG_ERROR([missing "libapr"])])
169dnl }}}
170
e5cca37d 171AC_DEFUN([CY_CHECK_PKG_CONFIG_LIBFFI], [
66170b30
JF
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"])])])
176
a243b558
JF
177AM_CONDITIONAL([CY_EXECUTE], [test "x$CY_EXECUTE" = x1])
178
e5cca37d 179AS_CASE([$CY_EXECUTE], [1], [
66170b30
JF
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
183 ], [
184 AC_SEARCH_LIBS([ffi_call], [ffi])
185 AS_CASE([$ac_cv_search_ffi_call], [no], [CY_CHECK_PKG_CONFIG_LIBFFI])
186 ])
187
188 AC_LANG_PUSH([Objective C++])
189
190 AC_MSG_CHECKING([if we really have Objective C++])
191 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [
192 CY_OBJECTIVEC=1
193 AC_MSG_RESULT([yes])
194 ], [AC_MSG_RESULT([no])])
195
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])
201
202 AC_CHECK_FRAMEWORK([Foundation], [
203 #include <Foundation/NSObject.h>
204 ], [[[[NSObject alloc] init];]])
205
206 AC_CHECK_FRAMEWORK([WebKit], [
207 #include <WebKit/WebScriptObject.h>
208 ], [[[[WebScriptObject alloc] init];]])
209 ], [
210 AC_ARG_VAR([GNUSTEP_CONFIG], [prints information about the current gnustep installation])
211 AC_CHECK_PROGS([GNUSTEP_CONFIG], [gnustep-config])
212
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])])
218 ])
219 ])
220
221 AC_LANG_POP([Objective C++])
3fd51f51 222])
66170b30 223
a243b558
JF
224AM_CONDITIONAL([CY_OBJECTIVEC], [test "x$CY_OBJECTIVEC" = x1])
225
226AX_LIB_READLINE
66170b30
JF
227AS_CASE([$vl_cv_lib_readline], [no], [AC_MSG_ERROR([missing "libreadline"])])
228
a243b558
JF
229dnl XXX: AX_LIB_READLINE totally lied: it was suposed to figure this out :(
230dnl XXX: this should only be linked into the main binary (not the library)
231AC_SEARCH_LIBS([cur_term], [termcap])
232
66170b30
JF
233dnl XXX: saurik doesn't understand what this does
234dnl AM_ICONV {{{
5053a6d1
DWT
235AC_LANG_PUSH([C])
236AM_ICONV
058f1bc8 237AS_CASE([$am_cv_func_iconv], [yes], [], [
66170b30
JF
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$||'`])
241 ], [-L*], [
242 AC_LIB_APPENDTOVAR([cy_iconv_prefixes], [`echo $cy_iconv_prefix_arg | sed -e 's/^-L//;s|/lib$||'`])
243 ])
244 done
245 for with_libiconv_prefix in $cy_iconv_prefixes; do
246 AS_UNSET([am_cv_func_iconv])
247 AM_ICONV_LINKFLAGS_BODY
248 AM_ICONV
249 done
058f1bc8 250])
66170b30 251AS_CASE([$am_cv_func_iconv], [yes], [], [AC_MSG_ERROR([missing "libiconv"])])
058f1bc8 252AC_LANG_POP([C])
66170b30
JF
253dnl }}}
254
255AC_SUBST([LTFLAGS])
9777bd50 256AC_SUBST([SO], [$acl_shlibext])
66170b30
JF
257
258AC_CHECK_HEADER([mach/mach.h], [
66170b30
JF
259 AC_CHECK_TOOLS([_LIPO], [lipo], [AC_MSG_ERROR([missing "lipo"])])
260 AC_CHECK_TOOLS([_NM], [nm], [AC_MSG_ERROR([missing "nm"])])
a243b558 261 AC_CHECK_TOOLS([_OTOOL], [otool], [AC_MSG_ERROR([missing "otool"])])
66170b30
JF
262 AC_SUBST([CY_MACH], [1])
263 AC_SUBST([CY_ATTACH_GROUP], [procmod])
e1cce270 264])
66170b30 265
a243b558 266AM_CONDITIONAL([CY_MACH], [test "x$CY_MACH" = x1])
66170b30 267
a243b558 268AC_CONFIG_FILES([Makefile])
9c60689e 269AC_OUTPUT