configure.ac 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.68])
  4. AC_INIT([idevicerestore], [m4_esyscmd(./git-version-gen $RELEASE_VERSION)], [https://github.com/libimobiledevice/idevicerestore/issues], [], [https://libimobiledevice.org])
  5. AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip])
  6. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
  7. AC_CONFIG_SRCDIR([src/])
  8. AC_CONFIG_HEADERS([config.h])
  9. AC_CONFIG_MACRO_DIR([m4])
  10. # Check if we have a version defined
  11. if test -z $PACKAGE_VERSION; then
  12. 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.])
  13. fi
  14. # Minimum package versions
  15. LIBIRECOVERY_VERSION=1.2.1
  16. LIBIMOBILEDEVICE_VERSION=1.3.0
  17. LIBUSBMUXD_VERSION=2.0.2
  18. LIBPLIST_VERSION=2.6.0
  19. LIMD_GLUE_VERSION=1.3.0
  20. LIBTATSU_VERSION=1.0.4
  21. LIBZIP_VERSION=1.0
  22. LIBCURL_VERSION=7.0
  23. AC_SUBST(LIBIRECOVERY_VERSION)
  24. AC_SUBST(LIBIMOBILEDEVICE_VERSION)
  25. AC_SUBST(LIBUSBMUXD_VERSION)
  26. AC_SUBST(LIBPLIST_VERSION)
  27. AC_SUBST(LIMD_GLUE_VERSION)
  28. AC_SUBST(LIBTATSU_VERSION)
  29. AC_SUBST(LIBZIP_VERSION)
  30. AC_SUBST(LIBCURL_VERSION)
  31. # Checks for programs.
  32. AC_PROG_CC
  33. AM_PROG_CC_C_O
  34. LT_INIT
  35. # Checks for libraries.
  36. PKG_CHECK_MODULES(libirecovery, libirecovery-1.0 >= $LIBIRECOVERY_VERSION)
  37. PKG_CHECK_MODULES(libimobiledevice, libimobiledevice-1.0 >= $LIBIMOBILEDEVICE_VERSION)
  38. PKG_CHECK_MODULES(libusbmuxd, libusbmuxd-2.0 >= $LIBUSBMUXD_VERSION)
  39. PKG_CHECK_MODULES(libplist, libplist-2.0 >= $LIBPLIST_VERSION)
  40. PKG_CHECK_MODULES(limd_glue, libimobiledevice-glue-1.0 >= $LIMD_GLUE_VERSION)
  41. PKG_CHECK_MODULES(libtatsu, libtatsu-1.0 >= $LIBTATSU_VERSION)
  42. PKG_CHECK_MODULES(libzip, libzip >= $LIBZIP_VERSION)
  43. PKG_CHECK_MODULES(libcurl, libcurl >= $LIBCURL_VERSION)
  44. PKG_CHECK_MODULES(zlib, zlib)
  45. AC_CHECK_FUNCS([strsep strcspn mkstemp realpath])
  46. if test x$ac_cv_func_strsep != xyes; then
  47. if test x$ac_cv_func_strcspn != xyes; then
  48. AC_MSG_ERROR([You need either strsep or strcspn to build $PACKAGE])
  49. fi
  50. fi
  51. AC_SEARCH_LIBS([ceil], [m])
  52. AC_CHECK_HEADER(endian.h, [ac_cv_have_endian_h="yes"], [ac_cv_have_endian_h="no"])
  53. if test "x$ac_cv_have_endian_h" = "xno"; then
  54. AC_DEFINE(__LITTLE_ENDIAN,1234,[little endian])
  55. AC_DEFINE(__BIG_ENDIAN,4321,[big endian])
  56. AC_C_BIGENDIAN([ac_cv_c_bigendian="yes"], [ac_cv_c_bigendian="no"], [], [])
  57. if test "x$ac_cv_c_bigendian" = "xyes"; then
  58. AC_DEFINE(__BYTE_ORDER,4321,[big endian byte order])
  59. else
  60. AC_DEFINE(__BYTE_ORDER,1234,[little endian byte order])
  61. fi
  62. fi
  63. GLOBAL_CFLAGS="-Wno-multichar -O2"
  64. AC_LDADD=""
  65. AC_LDFLAGS=""
  66. CFLAGS="$CFLAGS $libplist_CFLAGS"
  67. AC_CHECK_DECL([plist_from_json], [], [AC_MSG_ERROR([libplist with JSON format support required to build $PACKAGE_NAME])], [[#include <plist/plist.h>]])
  68. # Check for operating system
  69. AC_MSG_CHECKING([for platform-specific build settings])
  70. case ${host_os} in
  71. *mingw32*|*cygwin*)
  72. AC_MSG_RESULT([${host_os}])
  73. win32=true
  74. GLOBAL_CFLAGS+=" -DWIN32 -D__LITTLE_ENDIAN__=1"
  75. AC_LDFLAGS+=" -static-libgcc"
  76. ;;
  77. darwin*)
  78. AC_MSG_RESULT([${host_os}])
  79. AC_DEFINE([_DARWIN_BETTER_REALPATH], [1], [Use better method for realpath])
  80. ;;
  81. *)
  82. AC_MSG_RESULT([${host_os}])
  83. ;;
  84. esac
  85. AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
  86. if test x$win32 != xtrue; then
  87. if test "x$ac_cv_func_mkstemp" != xyes; then
  88. AC_CHECK_LIB(pthread, [pthread_self], [], [AC_MSG_ERROR([pthread is required to build $PACKAGE])])
  89. fi
  90. fi
  91. CACHED_CFLAGS="$CFLAGS"
  92. CFLAGS+=" $libimobiledevice_CFLAGS"
  93. # check if libimobiledevice has timeout errors
  94. AC_CACHE_CHECK(for IDEVICE_E_TIMEOUT in enum idevice_error_t, ac_cv_idevice_error_has_timeout,
  95. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  96. #include <libimobiledevice/libimobiledevice.h>
  97. ]], [[
  98. return IDEVICE_E_TIMEOUT;
  99. ]])],[ac_cv_idevice_error_has_timeout=yes],[ac_cv_idevice_error_has_timeout=no]))
  100. if test "$ac_cv_idevice_error_has_timeout" = "yes"; then
  101. AC_DEFINE(HAVE_IDEVICE_E_TIMEOUT, 1, [Define if enum idevice_error_t defines IDEVICE_E_TIMEOUT])
  102. fi
  103. AC_CACHE_CHECK(for RESTORE_E_RECEIVE_TIMEOUT in enum restored_error_t, ac_cv_restored_error_has_timeout,
  104. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  105. #include <libimobiledevice/restore.h>
  106. ]], [[
  107. return RESTORE_E_RECEIVE_TIMEOUT;
  108. ]])],[ac_cv_restored_error_has_timeout=yes],[ac_cv_restored_error_has_timeout=no]))
  109. if test "$ac_cv_restored_error_has_timeout" = "yes"; then
  110. AC_DEFINE(HAVE_RESTORE_E_RECEIVE_TIMEOUT, 1, [Define if enum restored_error_t defines RESTORE_E_RECEIVE_TIMEOUT])
  111. fi
  112. # check if libimobiledevice has enum idevice_connection_type
  113. AC_CACHE_CHECK(for enum idevice_connection_type, ac_cv_enum_idevice_connection_type,
  114. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  115. #include <libimobiledevice/libimobiledevice.h>
  116. ]], [[
  117. enum idevice_connection_type conn_type = CONNECTION_USBMUXD;
  118. ]])],[ac_cv_enum_idevice_connection_type=yes],[ac_cv_enum_idevice_connection_type=no]))
  119. if test "$ac_cv_enum_idevice_connection_type" = "yes"; then
  120. AC_DEFINE(HAVE_ENUM_IDEVICE_CONNECTION_TYPE, 1, [Define if enum idevice_connection_type is available])
  121. fi
  122. # check if libimobiledevice has reverse proxy support
  123. AC_CACHE_CHECK(for reverse proxy support in libimobiledevice, ac_cv_reverse_proxy,
  124. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  125. #include <libimobiledevice/reverse_proxy.h>
  126. #include <stdlib.h>
  127. ]], [[
  128. reverse_proxy_client_t rp = NULL;
  129. reverse_proxy_client_create_with_port(NULL, &rp, REVERSE_PROXY_DEFAULT_PORT);
  130. ]])],[ac_cv_reverse_proxy=yes],[ac_cv_reverse_proxy=no]))
  131. if test "$ac_cv_reverse_proxy" = "yes"; then
  132. AC_DEFINE(HAVE_REVERSE_PROXY, 1, [Define if libimobiledevice has a reverse proxy implementation])
  133. fi
  134. AC_ARG_WITH([limera1n],
  135. [AS_HELP_STRING([--with-limera1n],
  136. [build with support for limera1n exploit (default is yes)])],
  137. [have_limera1n=$withval],
  138. [have_limera1n=yes])
  139. if test "x$have_limera1n" = "xyes"; then
  140. AC_DEFINE(HAVE_LIMERA1N, 1, [Define if limera1n support is available])
  141. fi
  142. AM_CONDITIONAL([HAVE_LIMERA1N],[test "x$have_limera1n" = "xyes"])
  143. CFLAGS="$CACHED_CFLAGS"
  144. AC_SUBST(GLOBAL_CFLAGS)
  145. AC_SUBST(AC_LDFLAGS)
  146. AC_SUBST(AC_LDADD)
  147. # check for large file support
  148. AC_SYS_LARGEFILE
  149. m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
  150. AC_CONFIG_FILES([
  151. Makefile
  152. src/Makefile
  153. docs/Makefile
  154. ])
  155. AC_OUTPUT
  156. echo "
  157. Configuration for $PACKAGE $VERSION:
  158. -------------------------------------------
  159. Install prefix: .........: $prefix
  160. Now type 'make' to build $PACKAGE $VERSION,
  161. and then 'make install' for installation.
  162. "