]> git.saurik.com Git - cycript.git/blame - configure.ac
Stop using non-portable (GNU) Makefile features.
[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
9228a43a 9AM_INIT_AUTOMAKE([-Wall -Werror foreign])
a243b558
JF
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
9228a43a
JF
63AC_MSG_CHECKING([bison for %code{}])
64echo '%code{}%%_:' >conftest.y
65if $BISON conftest.y -o/dev/null 2>/dev/null; then
66 AC_LIB_APPENDTOVAR([CY_FILTERS], [Bison24])
67 AC_MSG_RESULT([yes])
68else
69 AC_LIB_APPENDTOVAR([CY_FILTERS], [Bison23])
70 AC_MSG_RESULT([no])
71fi
72
73rm -f conftest.y
74AC_SUBST([CY_FILTERS])
75
66170b30
JF
76dnl CY_TRY {{{
77AC_DEFUN([CY_SUCCESS], [cy_good=1])
78AC_DEFUN([CY_FAILURE], [cy_good=0])
79
80AC_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
88AC_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
94AC_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
105AX_CFLAGS_WARN_ALL
106AX_CXXFLAGS_WARN_ALL
107
108CY_TEST_FLAG([-Wno-overloaded-virtual])
109CY_TEST_FLAG([-Wno-parentheses])
110CY_TEST_FLAG([-Wno-unneeded-internal-declaration])
111
112dnl -arch * {{{
113for 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
121done
122AC_SUBST([CY_ARCH])
123dnl }}}
66170b30
JF
124
125dnl --with-frameworks {{{
632b71ea 126AC_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 }}}
134dnl --enable-javascript {{{
b66977f1 135AC_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 157AC_DEFUN([CY_CHECK_JAVASCRIPT], [
66170b30
JF
158 CY_CHECK_JAVASCRIPTCORE])
159
b66977f1 160AC_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
173dnl }}}
174
175dnl APR_FIND_APR {{{
176APR_FIND_APR([], [], [1], [1])
177AS_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"])])
182dnl }}}
183
e5cca37d 184AC_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
190AM_CONDITIONAL([CY_EXECUTE], [test "x$CY_EXECUTE" = x1])
191
e5cca37d 192AS_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
237AM_CONDITIONAL([CY_OBJECTIVEC], [test "x$CY_OBJECTIVEC" = x1])
238
239AX_LIB_READLINE
66170b30
JF
240AS_CASE([$vl_cv_lib_readline], [no], [AC_MSG_ERROR([missing "libreadline"])])
241
a243b558
JF
242dnl XXX: AX_LIB_READLINE totally lied: it was suposed to figure this out :(
243dnl XXX: this should only be linked into the main binary (not the library)
244AC_SEARCH_LIBS([cur_term], [termcap])
245
66170b30
JF
246dnl XXX: saurik doesn't understand what this does
247dnl AM_ICONV {{{
5053a6d1
DWT
248AC_LANG_PUSH([C])
249AM_ICONV
058f1bc8 250AS_CASE([$am_cv_func_iconv], [yes], [], [
66170b30
JF
251 for cy_iconv_prefix_arg in $CFLAGS $CXXFLAGS $OBJCXXFLAGS $LDFLAGS $LIBS; do
252 AS_CASE([$cy_iconv_prefix_arg], [-I*], [
253 AC_LIB_APPENDTOVAR([cy_iconv_prefixes], [`echo $cy_iconv_prefix_arg | sed -e 's/^-I//;s|/include$||'`])
254 ], [-L*], [
255 AC_LIB_APPENDTOVAR([cy_iconv_prefixes], [`echo $cy_iconv_prefix_arg | sed -e 's/^-L//;s|/lib$||'`])
256 ])
257 done
258 for with_libiconv_prefix in $cy_iconv_prefixes; do
259 AS_UNSET([am_cv_func_iconv])
260 AM_ICONV_LINKFLAGS_BODY
261 AM_ICONV
262 done
058f1bc8 263])
66170b30 264AS_CASE([$am_cv_func_iconv], [yes], [], [AC_MSG_ERROR([missing "libiconv"])])
058f1bc8 265AC_LANG_POP([C])
66170b30
JF
266dnl }}}
267
268AC_SUBST([LTFLAGS])
9777bd50 269AC_SUBST([SO], [$acl_shlibext])
66170b30
JF
270
271AC_CHECK_HEADER([mach/mach.h], [
66170b30
JF
272 AC_CHECK_TOOLS([_LIPO], [lipo], [AC_MSG_ERROR([missing "lipo"])])
273 AC_CHECK_TOOLS([_NM], [nm], [AC_MSG_ERROR([missing "nm"])])
a243b558 274 AC_CHECK_TOOLS([_OTOOL], [otool], [AC_MSG_ERROR([missing "otool"])])
66170b30
JF
275 AC_SUBST([CY_MACH], [1])
276 AC_SUBST([CY_ATTACH_GROUP], [procmod])
e1cce270 277])
66170b30 278
a243b558 279AM_CONDITIONAL([CY_MACH], [test "x$CY_MACH" = x1])
66170b30 280
a243b558 281AC_CONFIG_FILES([Makefile])
9c60689e 282AC_OUTPUT