forked from libimobiledevice/idevicerestore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
243 lines (207 loc) · 8.22 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.68])
AC_INIT([idevicerestore], [m4_esyscmd(./git-version-gen $RELEASE_VERSION)], [https://github.com/libimobiledevice/idevicerestore/issues], [], [https://libimobiledevice.org])
AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
AC_CONFIG_SRCDIR([src/])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Check if we have a version defined
if test -z $PACKAGE_VERSION; then
AC_MSG_ERROR([PACKAGE_VERSION is not defined. Make sure to configure a source tree checked out from git or that .tarball-version is present.])
fi
# Minimum package versions
LIBIRECOVERY_VERSION=1.0.1
LIBIMOBILEDEVICE_VERSION=1.3.0
LIBUSBMUXD_VERSION=2.0.2
LIBPLIST_VERSION=2.3.0
LIMD_GLUE_VERSION=1.0.0
LIBZIP_VERSION=1.0
LIBCURL_VERSION=7.0
OPENSSL_VERSION=0.9.8
AC_SUBST(LIBIRECOVERY_VERSION)
AC_SUBST(LIBIMOBILEDEVICE_VERSION)
AC_SUBST(LIBUSBMUXD_VERSION)
AC_SUBST(LIBPLIST_VERSION)
AC_SUBST(LIMD_GLUE_VERSION)
AC_SUBST(LIBZIP_VERSION)
AC_SUBST(LIBCURL_VERSION)
AC_SUBST(OPENSSL_VERSION)
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT
# Checks for libraries.
LIBIRECOVERY_REQUIRES_STR="libirecovery-1.0 >= $LIBIRECOVERY_VERSION"
LIBIMOBILEDEVICE_REQUIRES_STR="libimobiledevice-1.0 >= $LIBIMOBILEDEVICE_VERSION"
LIBUSBMUXD_REQUIRES_STR="libusbmuxd-2.0 >= $LIBUSBMUXD_VERSION"
LIBPLIST_REQUIRES_STR="libplist-2.0 >= $LIBPLIST_VERSION"
LIMD_GLUE_REQUIRES_STR="libimobiledevice-glue-1.0 >= $LIMD_GLUE_VERSION"
LIBZIP_REQUIRES_STR="libzip >= $LIBZIP_VERSION"
LIBCURL_REQUIRES_STR="libcurl >= $LIBCURL_VERSION"
ZLIB_REQUIRES_STR="zlib"
OPENSSL_REQUIRES_STR="openssl >= $OPENSSL_VERSION"
PKG_CHECK_MODULES(libirecovery, $LIBIRECOVERY_REQUIRES_STR)
PKG_CHECK_MODULES(libimobiledevice, $LIBIMOBILEDEVICE_REQUIRES_STR)
PKG_CHECK_MODULES(libusbmuxd, $LIBUSBMUXD_REQUIRES_STR)
PKG_CHECK_MODULES(libplist, $LIBPLIST_REQUIRES_STR)
PKG_CHECK_MODULES(limd_glue, $LIMD_GLUE_REQUIRES_STR)
PKG_CHECK_MODULES(libzip, $LIBZIP_REQUIRES_STR)
PKG_CHECK_MODULES(libcurl, $LIBCURL_REQUIRES_STR)
PKG_CHECK_MODULES(zlib, $ZLIB_REQUIRES_STR)
# optional
PKG_CHECK_MODULES(openssl, $OPENSSL_REQUIRES_STR, have_openssl=yes, have_openssl=no)
AC_SUBST([libirecovery_requires], [$LIBIRECOVERY_REQUIRES_STR])
AC_SUBST([libimobiledevice_requires], [$LIBIMOBILEDEVICE_REQUIRES_STR])
AC_SUBST([libusbmuxd_requires], [$LIBUSBMUXD_REQUIRES_STR])
AC_SUBST([libplist_requires], [$LIBPLIST_REQUIRES_STR])
AC_SUBST([limd_glue_requires], [$LIMD_GLUE_REQUIRES_STR])
AC_SUBST([libzip_requires], [$LIBZIP_REQUIRES_STR])
AC_SUBST([libcurl_requires], [$LIBCURL_REQUIRES_STR])
AC_SUBST([zlib_requires], [$ZLIB_REQUIRES_STR])
AC_SUBST([release_version], [$VERSION])
AC_CHECK_FUNCS([strsep strcspn mkstemp realpath])
if test x$ac_cv_func_strsep != xyes; then
if test x$ac_cv_func_strcspn != xyes; then
AC_MSG_ERROR([You need either strsep or strcspn to build $PACKAGE])
fi
fi
AC_CHECK_HEADER(endian.h, [ac_cv_have_endian_h="yes"], [ac_cv_have_endian_h="no"])
if test "x$ac_cv_have_endian_h" = "xno"; then
AC_DEFINE(__LITTLE_ENDIAN,1234,[little endian])
AC_DEFINE(__BIG_ENDIAN,4321,[big endian])
AC_C_BIGENDIAN([ac_cv_c_bigendian="yes"], [ac_cv_c_bigendian="no"], [], [])
if test "x$ac_cv_c_bigendian" = "xyes"; then
AC_DEFINE(__BYTE_ORDER,4321,[big endian byte order])
else
AC_DEFINE(__BYTE_ORDER,1234,[little endian byte order])
fi
fi
GLOBAL_CFLAGS="-Wno-multichar -O2"
AC_LDADD=""
AC_LDFLAGS=""
CFLAGS="$CFLAGS $libplist_CFLAGS"
AC_CHECK_DECL([plist_from_json], [], [AC_MSG_ERROR([libplist with JSON format support required to build $PACKAGE_NAME])], [[#include <plist/plist.h>]])
# Check for operating system
AC_MSG_CHECKING([for platform-specific build settings])
case ${host_os} in
*mingw32*|*cygwin*)
AC_MSG_RESULT([${host_os}])
win32=true
GLOBAL_CFLAGS+=" -DWIN32 -D__LITTLE_ENDIAN__=1"
AC_LDFLAGS+=" -static-libgcc"
;;
darwin*)
AC_MSG_RESULT([${host_os}])
AC_DEFINE([_DARWIN_BETTER_REALPATH], [1], [Use better method for realpath])
;;
*)
AC_MSG_RESULT([${host_os}])
;;
esac
AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
if test x$win32 != xtrue; then
if test "x$ac_cv_func_mkstemp" != xyes; then
AC_CHECK_LIB(pthread, [pthread_self], [], [AC_MSG_ERROR([pthread is required to build $PACKAGE])])
fi
fi
CACHED_CFLAGS="$CFLAGS"
CFLAGS+=" $libimobiledevice_CFLAGS"
# check if libimobiledevice has timeout errors
AC_CACHE_CHECK(for IDEVICE_E_TIMEOUT in enum idevice_error_t, ac_cv_idevice_error_has_timeout,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <libimobiledevice/libimobiledevice.h>
]], [[
return IDEVICE_E_TIMEOUT;
]])],[ac_cv_idevice_error_has_timeout=yes],[ac_cv_idevice_error_has_timeout=no]))
if test "$ac_cv_idevice_error_has_timeout" = "yes"; then
AC_DEFINE(HAVE_IDEVICE_E_TIMEOUT, 1, [Define if enum idevice_error_t defines IDEVICE_E_TIMEOUT])
fi
AC_CACHE_CHECK(for RESTORE_E_RECEIVE_TIMEOUT in enum restored_error_t, ac_cv_restored_error_has_timeout,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <libimobiledevice/restore.h>
]], [[
return RESTORE_E_RECEIVE_TIMEOUT;
]])],[ac_cv_restored_error_has_timeout=yes],[ac_cv_restored_error_has_timeout=no]))
if test "$ac_cv_restored_error_has_timeout" = "yes"; then
AC_DEFINE(HAVE_RESTORE_E_RECEIVE_TIMEOUT, 1, [Define if enum restored_error_t defines RESTORE_E_RECEIVE_TIMEOUT])
fi
# check if libimobiledevice has enum idevice_connection_type
AC_CACHE_CHECK(for enum idevice_connection_type, ac_cv_enum_idevice_connection_type,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <libimobiledevice/libimobiledevice.h>
]], [[
enum idevice_connection_type conn_type = CONNECTION_USBMUXD;
]])],[ac_cv_enum_idevice_connection_type=yes],[ac_cv_enum_idevice_connection_type=no]))
if test "$ac_cv_enum_idevice_connection_type" = "yes"; then
AC_DEFINE(HAVE_ENUM_IDEVICE_CONNECTION_TYPE, 1, [Define if enum idevice_connection_type is available])
fi
# check if libimobiledevice has reverse proxy support
AC_CACHE_CHECK(for reverse proxy support in libimobiledevice, ac_cv_reverse_proxy,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <libimobiledevice/reverse_proxy.h>
#include <stdlib.h>
]], [[
reverse_proxy_client_t rp = NULL;
reverse_proxy_client_create_with_port(NULL, &rp, REVERSE_PROXY_DEFAULT_PORT);
]])],[ac_cv_reverse_proxy=yes],[ac_cv_reverse_proxy=no]))
if test "$ac_cv_reverse_proxy" = "yes"; then
AC_DEFINE(HAVE_REVERSE_PROXY, 1, [Define if libimobiledevice has a reverse proxy implementation])
fi
CFLAGS="$CACHED_CFLAGS"
AC_ARG_ENABLE([asan],
[AS_HELP_STRING([--enable-asan],
[enable ASAN build(default is no)])],
[asan_build=true],
[asan_build=false])
if test "$asan_build" = true; then
echo "*** Note: debug build requested ***"
CFLAGS+=" -g -O0 -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope"
CXXFLAGS+=" -g -O0 -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope"
fi
AC_ARG_WITH([openssl],
[AS_HELP_STRING([--without-openssl],
[Do not use OpenSSL])],
[use_openssl=$withval],
[use_openssl=$have_openssl])
if test "x$use_openssl" == "xyes"; then
if test "x$have_openssl" != "xyes"; then
echo "*** NOTE: --with-openssl passed but OpenSSL is not available ***"
use_openssl=no
fi
fi
if test "x$use_openssl" != "xyes"; then
echo "*** NOTE: Using internal SHA1 implementation ***"
have_openssl=no
openssl_CFLAGS=
openssl_LIBS=
fi
if test "x$have_openssl" == "xyes"; then
AC_DEFINE(HAVE_OPENSSL, [1], [Define if you have OpenSSL])
AC_SUBST([openssl_requires], [$OPENSSL_REQUIRES_STR])
fi
AC_SUBST(openssl_CFLAGS)
AC_SUBST(openssl_LIBS)
AM_CONDITIONAL(USE_INTERNAL_SHA, test x$use_openssl != xyes)
AC_SUBST(GLOBAL_CFLAGS)
AC_SUBST(AC_LDFLAGS)
AC_SUBST(AC_LDADD)
# check for large file support
AC_SYS_LARGEFILE
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_CONFIG_FILES([
Makefile
src/Makefile
docs/Makefile
include/Makefile
libidevicerestore.pc
])
AC_OUTPUT
echo "
Configuration for $PACKAGE $VERSION:
-------------------------------------------
Install prefix: .........: $prefix
Now type 'make' to build $PACKAGE $VERSION,
and then 'make install' for installation.
"