]> git.saurik.com Git - cycript.git/blob - configure.ac
Better version checking for bison, flex, and gperf that falls through to other versio...
[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_CONFIG_SRCDIR([Console.cpp])
4 AC_CONFIG_AUX_DIR([.])
5 LT_INIT([disable-static])
6 PKG_PROG_PKG_CONFIG([0.22])
7 CHECK_GNU_MAKE
8 AC_SUBST([GMAKE], [$_cv_gnu_make_command])
9 AS_IF([test "x$GMAKE" = x], [AC_MSG_ERROR([You need GNU make])])
10 AC_PATH_PROGS([_BASH], [bash])
11 AS_IF([test "x$_BASH" = x], [AC_MSG_ERROR([You need GNU bash])])
12 AC_PATH_PROGS([TIME], [time])
13 AC_DEFUN([CY_CHECK_PROGS_VERSION], [
14 AC_MSG_CHECKING(for ]$2[ >= ]$5[)
15 AC_PATH_PROGS_FEATURE_CHECK(]$1[, ]$3[,
16 AS_VERSION_COMPARE(`$ac_path_]$1[ ]$4[`, ]$5[, ,
17 ac_cv_path_]$1[=$ac_path_]$1[
18 ,
19 ac_cv_path_]$1[=$ac_path_]$1[
20 )
21 ,
22 AC_MSG_RESULT(not found)
23 AC_MSG_ERROR(You need ]$2[ ]$5[ or greater)
24 )
25 AC_SUBST(]$1[, $ac_cv_path_]$1[)
26 AC_MSG_RESULT($]$1[)
27 ])
28 AC_ARG_VAR([BISON], [GNU Project parser generator (yacc replacement)])
29 CY_CHECK_PROGS_VERSION([BISON], [bison], [bison],
30 [-V | $SED -e '1 s/^bison (GNU Bison) \(.*\)$/\1/p;d'], [2.3])
31 AC_ARG_VAR([FLEX], [the fast lexical analyser generator])
32 CY_CHECK_PROGS_VERSION([FLEX], [flex], [flex],
33 [--version | $SED -e '1 s/^.* \(@<:@0-9.@:>@*\)$/\1/p;d'], [2.5.33])
34 AC_ARG_VAR([GPERF], [perfect hash function generator])
35 CY_CHECK_PROGS_VERSION([GPERF], [gperf], [gperf],
36 [--version | $SED -e '1 s/^.* \(@<:@0-9.@:>@*\)$/\1/p;d'], [3.0.3])
37 AC_PROG_INSTALL
38 AC_MSG_CHECKING([for GNU tar])
39 AC_PATH_PROGS_FEATURE_CHECK([GNUTAR], [tar gtar gnutar], [
40 AS_IF([test "x`$ac_path_GNUTAR --version | $SED -e '1 s/^tar (GNU tar)/&/p;d'`" != x], [
41 ac_cv_path_GNUTAR=$ac_path_GNUTAR
42 ])
43 ])
44 AS_IF([test "x$ac_cv_path_GNUTAR" != x], [
45 AC_SUBST([GNUTAR], [$ac_cv_path_GNUTAR])
46 AC_MSG_RESULT([$GNUTAR])
47 ], [
48 AC_SUBST([GNUTAR], [:])
49 AC_MSG_RESULT([not found])
50 ])
51 AC_PROG_CXX
52 AC_PROG_OBJCXX
53 AC_ARG_WITH([frameworks], [AS_HELP_STRING(
54 [--with-frameworks=DIRS],
55 [add to DIRS (space separated) to the Darwin include path for frameworks with -F]
56 )], [
57 for framework in $withval; do
58 AC_LIB_APPENDTOVAR([CFLAGS], [-F$framework])
59 AC_LIB_APPENDTOVAR([CXXFLAGS], [-F$framework])
60 AC_LIB_APPENDTOVAR([OBJCCXXFLAGS], [-F$framework])
61 done
62 ])
63 AC_LANG([C++])
64 APR_FIND_APR([], [], [1], [1])
65 AS_CASE([$apr_found], [yes], [
66 AC_LIB_APPENDTOVAR([CPPFLAGS], [`$apr_config --includes`])
67 AC_SUBST([LTLIBAPR], [`$apr_config --link-libtool`])
68 ], [AC_MSG_ERROR([You need apr])])
69 VL_LIB_READLINE
70 AC_LANG_PUSH([C])
71 AM_ICONV
72 AC_LANG_POP([C])
73 AS_CASE([$am_cv_func_iconv], [yes], [], [AC_MSG_ERROR([You need iconv])])
74 AC_DEFUN([CY_CHECK_JAVASCRIPTCORE], [
75 PKG_CHECK_MODULES([WEBKIT], [webkit-1.0], [
76 CY_EXECUTE=1
77 AC_LIB_APPENDTOVAR([CXXFLAGS], [`$PKG_CONFIG --cflags webkit-1.0`])
78 AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs webkit-1.0`])
79 ], [
80 PKG_CHECK_MODULES([WEBKIT], [WebKitGtk], [
81 CY_EXECUTE=1
82 AC_LIB_APPENDTOVAR([CXXFLAGS], [`$PKG_CONFIG --cflags WebKitGtk`])
83 AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs WebKitGtk`])
84 ], [
85 AC_CHECK_FRAMEWORK([JavaScriptCore], [
86 #include <JavaScriptCore/JSBase.h>
87 ], [JSEvaluateScript(0, 0, 0, 0, 0, 0);], [CY_EXECUTE=1])
88 ])
89 ])
90 ])
91 AC_DEFUN([CY_CHECK_JAVASCRIPT], [
92 CY_CHECK_JAVASCRIPTCORE
93 ])
94 AC_ARG_ENABLE([javascript], [AS_HELP_STRING(
95 [--enable-javascript@<:@=ENGINE@:>@],
96 [use a JavaScript runtime (currently the only available option for ENGINE is JavaScriptCore) @<:@default=yes@:>@]
97 )], [
98 AS_CASE([$enableval], [yes], [CY_CHECK_JAVASCRIPT], [no], [
99 AC_SUBST([CY_EXECUTE], [0])
100 ], [JavaScriptCore], [
101 CY_CHECK_JAVASCRIPTCORE
102 ], [AC_MSG_ERROR([Unknown JavaScript engine: $enableval])])
103 ], [CY_CHECK_JAVASCRIPT])
104 AS_CASE([$CY_EXECUTE], [1], [
105 AC_SUBST([CY_EXECUTE])
106 PKG_CHECK_MODULES([LIBFFI], [libffi], [
107 AC_LIB_APPENDTOVAR([CXXFLAGS], [`$PKG_CONFIG --cflags libffi`])
108 AC_LIB_APPENDTOVAR([LIBS], [`$PKG_CONFIG --libs libffi`])
109 ], [
110 AC_CHECK_HEADERS([ffi.h ffi/ffi.h], [break])
111 AS_IF([test "x$ac_cv_header_ffi_h" = xno && test "x$ac_cv_header_ffi_ffi_h" = xno], [
112 AC_MSG_ERROR([You need libffi])
113 ])
114 AC_SEARCH_LIBS([ffi_call], [ffi])
115 AS_CASE([$ac_cv_search_ffi_call], [no], [
116 AC_MSG_ERROR([You need libffi])
117 ])
118 ])
119 AC_LANG_PUSH([Objective C++])
120 AC_MSG_CHECKING([if we really have Objective C++])
121 AC_COMPILE_IFELSE([
122 // This space intentionally left blank
123 ], [
124 CY_OBJECTIVEC=1
125 AC_MSG_RESULT([yes])
126 ], [AC_MSG_RESULT([no])])
127 AS_IF([test "x$CY_OBJECTIVEC" = x1], [
128 AC_CHECK_FRAMEWORK([CoreFoundation], [
129 #include <CoreFoundation/CFBase.h>
130 ], [CFAllocatorGetDefault();], [
131 AC_SUBST([CY_OBJECTIVEC])
132 AC_CHECK_FRAMEWORK([Foundation], [
133 #include <Foundation/NSObject.h>
134 ], [[[[NSObject alloc] init];]])
135 AC_CHECK_FRAMEWORK([WebKit], [
136 #include <WebKit/WebScriptObject.h>
137 ], [[[[WebScriptObject alloc] init];]])
138 ], [
139 AC_ARG_VAR([GNUSTEP_CONFIG], [prints information about the current gnustep installation])
140 AC_CHECK_PROGS([GNUSTEP_CONFIG], [gnustep-config])
141 AS_IF([test "x$GNUSTEP_CONFIG" != x], [
142 AC_SUBST([CY_OBJECTIVEC])
143 AC_LIB_APPENDTOVAR([OBJCXXFLAGS], [`$GNUSTEP_CONFIG --objc-flags`])
144 AC_LIB_APPENDTOVAR([LIBS], [`$GNUSTEP_CONFIG --base-libs`])
145 ], [AC_SUBST([CY_OBJECTIVEC], [0])])
146 ])
147 ])
148 AC_LANG_POP([Objective C++])
149 ])
150 AS_IF([test "x$CY_OBJECTIVEC" = x1], [
151 AC_CHECK_HEADER([mach/mach.h], [
152 AS_CASE([$OTOOL], [:], [AC_MSG_WARN([Missing otool?])], [AC_SUBST([CY_OBJECTIVEC_MACH], [1])])
153 ])
154 ])
155 AS_IF([test "x$GMAKE" != xmake], [
156 AC_CONFIG_FILES([Makefile])
157 ])
158 AC_CONFIG_FILES([GNUmakefile])
159 AC_OUTPUT