]> git.saurik.com Git - cycript.git/blob - configure.ac
Avoid libapr's .la from breaking libiconv search.
[cycript.git] / configure.ac
1 AC_PREREQ([2.65])
2 AC_INIT([Cycript], [0.9], [saurik@saurik.com], [cycript], [http://www.cycript.org/])
3 AC_COPYRIGHT([Copyright (C) 2009-2012 Jay Freeman (saurik)])
4
5 AC_CONFIG_SRCDIR([Console.cpp])
6 AC_CONFIG_AUX_DIR([.])
7 AC_CONFIG_MACRO_DIR([m4])
8
9 AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability foreign])
10
11 AC_PROG_CXX
12 AC_PROG_OBJCXX
13 AM_PROG_AR
14 AC_PROG_INSTALL
15
16 LT_INIT([disable-static])
17
18 AC_LANG([C++])
19
20 PKG_PROG_PKG_CONFIG([0.22])
21
22 AX_CHECK_GNU_MAKE
23 AC_SUBST([GMAKE], [$_cv_gnu_make_command])
24 AS_IF([test "x$GMAKE" = x], [AC_MSG_ERROR([You need GNU make])])
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 {{{
31 AC_DEFUN([CY_CHECK_PROGS_VERSION], [
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
63 dnl CY_TRY {{{
64 AC_DEFUN([CY_SUCCESS], [cy_good=1])
65 AC_DEFUN([CY_FAILURE], [cy_good=0])
66
67 AC_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
75 AC_DEFUN([CY_COMPILE_FLAG], [
76 AC_LIB_APPENDTOVAR([CFLAGS], ]$1[)
77 AC_LIB_APPENDTOVAR([CXXFLAGS], ]$1[)
78 AC_LIB_APPENDTOVAR([OBJCCXXFLAGS], ]$1[)
79 ])
80
81 AC_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
92 AX_CFLAGS_WARN_ALL
93 AX_CXXFLAGS_WARN_ALL
94
95 CY_TEST_FLAG([-Wno-overloaded-virtual])
96 CY_TEST_FLAG([-Wno-parentheses])
97 CY_TEST_FLAG([-Wno-unneeded-internal-declaration])
98
99 dnl -arch * {{{
100 for 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])
106 AC_LIB_APPENDTOVAR([CY_ARCH], ["-arch $cy_arch"])
107 ], [AC_MSG_RESULT([no])])
108 done
109 AC_SUBST([CY_ARCH])
110 dnl }}}
111
112 dnl --with-frameworks {{{
113 AC_ARG_WITH([frameworks], [AS_HELP_STRING(
114 [--with-frameworks=DIRS],
115 [add to DIRS (space separated) to the Darwin include path for frameworks with -F]
116 )], [
117 for cy_framework in $withval; do
118 CY_COMPILE_FLAG([-F$cy_framework])
119 done
120 ]) dnl }}}
121 dnl --enable-javascript {{{
122 AC_DEFUN([CY_CHECK_JAVASCRIPTCORE], [
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 ])
142 ])
143
144 AC_DEFUN([CY_CHECK_JAVASCRIPT], [
145 CY_CHECK_JAVASCRIPTCORE])
146
147 AC_ARG_ENABLE([javascript], [AS_HELP_STRING(
148 [--enable-javascript@<:@=ENGINE@:>@],
149 [use a JavaScript runtime (currently the only available option for ENGINE is JavaScriptCore) @<:@default=yes@:>@]
150 )], [
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])])
159 ], [CY_CHECK_JAVASCRIPT])
160 dnl }}}
161
162 dnl APR_FIND_APR {{{
163 APR_FIND_APR([], [], [1], [1])
164 AS_CASE([$apr_found], [yes], [
165 AC_LIB_APPENDTOVAR([CPPFLAGS], [`$apr_config --includes`])
166 AC_LIB_APPENDTOVAR([LTLIBAPR], [`$apr_config --link-libtool`])
167 AC_SUBST([LTLIBAPR])
168 ], [AC_MSG_ERROR([missing "libapr"])])
169 dnl }}}
170
171 AC_DEFUN([CY_CHECK_PKG_CONFIG_LIBFFI], [
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
177 AM_CONDITIONAL([CY_EXECUTE], [test "x$CY_EXECUTE" = x1])
178
179 AS_CASE([$CY_EXECUTE], [1], [
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++])
222 ])
223
224 AM_CONDITIONAL([CY_OBJECTIVEC], [test "x$CY_OBJECTIVEC" = x1])
225
226 AX_LIB_READLINE
227 AS_CASE([$vl_cv_lib_readline], [no], [AC_MSG_ERROR([missing "libreadline"])])
228
229 dnl XXX: AX_LIB_READLINE totally lied: it was suposed to figure this out :(
230 dnl XXX: this should only be linked into the main binary (not the library)
231 AC_SEARCH_LIBS([cur_term], [termcap])
232
233 dnl XXX: saurik doesn't understand what this does
234 dnl AM_ICONV {{{
235 AC_LANG_PUSH([C])
236 AM_ICONV
237 AS_CASE([$am_cv_func_iconv], [yes], [], [
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
250 ])
251 AS_CASE([$am_cv_func_iconv], [yes], [], [AC_MSG_ERROR([missing "libiconv"])])
252 AC_LANG_POP([C])
253 dnl }}}
254
255 AC_SUBST([LTFLAGS])
256 AC_SUBST([SO], [$acl_shlibext])
257
258 AC_CHECK_HEADER([mach/mach.h], [
259 AC_CHECK_TOOLS([_LIPO], [lipo], [AC_MSG_ERROR([missing "lipo"])])
260 AC_CHECK_TOOLS([_NM], [nm], [AC_MSG_ERROR([missing "nm"])])
261 AC_CHECK_TOOLS([_OTOOL], [otool], [AC_MSG_ERROR([missing "otool"])])
262 AC_SUBST([CY_MACH], [1])
263 AC_SUBST([CY_ATTACH_GROUP], [procmod])
264 ])
265
266 AM_CONDITIONAL([CY_MACH], [test "x$CY_MACH" = x1])
267
268 AC_CONFIG_FILES([Makefile])
269 AC_OUTPUT