configure.ac 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.68])
  4. AC_INIT([libimobiledevice], [m4_esyscmd(./git-version-gen $RELEASE_VERSION)], [https://github.com/libimobiledevice/libimobiledevice/issues], [], [https://libimobiledevice.org])
  5. AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip check-news])
  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. dnl libtool versioning
  11. # +1 : 0 : +1 == adds new functions to the interface
  12. # +1 : 0 : 0 == changes or removes functions (changes include both
  13. # changes to the signature and the semantic)
  14. # ? :+1 : ? == just internal changes
  15. # CURRENT : REVISION : AGE
  16. LIBIMOBILEDEVICE_SO_VERSION=6:0:0
  17. AC_SUBST(LIBIMOBILEDEVICE_SO_VERSION)
  18. # Check if we have a version defined
  19. if test -z $PACKAGE_VERSION; then
  20. 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.])
  21. fi
  22. dnl Minimum package versions
  23. LIBUSBMUXD_VERSION=2.0.2
  24. LIBPLIST_VERSION=2.3.0
  25. LIMD_GLUE_VERSION=1.3.0
  26. LIBTATSU_VERSION=1.0.3
  27. AC_SUBST(LIBUSBMUXD_VERSION)
  28. AC_SUBST(LIBPLIST_VERSION)
  29. AC_SUBST(LIMD_GLUE_VERSION)
  30. # Checks for programs.
  31. AC_PROG_CC
  32. AC_PROG_CXX
  33. AM_PROG_CC_C_O
  34. LT_INIT
  35. # Checks for libraries.
  36. PKG_CHECK_MODULES(libusbmuxd, libusbmuxd-2.0 >= $LIBUSBMUXD_VERSION)
  37. PKG_CHECK_MODULES(libplist, libplist-2.0 >= $LIBPLIST_VERSION)
  38. PKG_CHECK_MODULES(limd_glue, libimobiledevice-glue-1.0 >= $LIMD_GLUE_VERSION)
  39. PKG_CHECK_MODULES(libtatsu, libtatsu-1.0 >= $LIBTATSU_VERSION)
  40. AC_ARG_WITH([readline],
  41. [AS_HELP_STRING([--without-readline],
  42. [build without support for libreadline (default is yes)])],
  43. [check_libreadline=false],
  44. [check_libreadline=true])
  45. if test "$check_libreadline" = "true"; then
  46. PKG_CHECK_MODULES(readline, readline >= 1.0, have_readline=yes, have_readline=no)
  47. if test "x$have_readline" = "xyes"; then
  48. AC_DEFINE(HAVE_READLINE, 1, [Define if readline library is available])
  49. fi
  50. fi
  51. AM_CONDITIONAL([HAVE_READLINE],[test "x$have_readline" = "xyes"])
  52. # Checks for header files.
  53. AC_CHECK_HEADERS([stdint.h stdlib.h string.h sys/time.h])
  54. # Checks for typedefs, structures, and compiler characteristics.
  55. AC_C_CONST
  56. AC_TYPE_SIZE_T
  57. AC_TYPE_SSIZE_T
  58. AC_TYPE_UINT16_T
  59. AC_TYPE_UINT32_T
  60. AC_TYPE_UINT8_T
  61. # Checks for library functions.
  62. AC_CHECK_FUNCS([asprintf strcasecmp strdup strerror strndup stpcpy vasprintf getifaddrs])
  63. AC_CHECK_HEADER(endian.h, [ac_cv_have_endian_h="yes"], [ac_cv_have_endian_h="no"])
  64. if test "x$ac_cv_have_endian_h" = "xno"; then
  65. AC_DEFINE(__LITTLE_ENDIAN,1234,[little endian])
  66. AC_DEFINE(__BIG_ENDIAN,4321,[big endian])
  67. AC_C_BIGENDIAN([ac_cv_c_bigendian="yes"], [ac_cv_c_bigendian="no"], [], [])
  68. if test "x$ac_cv_c_bigendian" = "xyes"; then
  69. AC_DEFINE(__BYTE_ORDER,4321,[big endian byte order])
  70. else
  71. AC_DEFINE(__BYTE_ORDER,1234,[little endian byte order])
  72. fi
  73. fi
  74. AC_CHECK_DECL([plist_from_json], [AC_DEFINE([HAVE_PLIST_JSON], [1], [Define if libplist has JSON support])], [], [[#include <plist/plist.h>]])
  75. # Check for operating system
  76. AC_MSG_CHECKING([for platform-specific build settings])
  77. case ${host_os} in
  78. *mingw32*|*cygwin*)
  79. AC_MSG_RESULT([${host_os}])
  80. win32=true
  81. AC_DEFINE(WINVER, 0x0501, [minimum Windows version])
  82. deplibs_check_method='pass_all'
  83. ;;
  84. darwin*)
  85. AC_MSG_RESULT([${host_os}])
  86. darwin=true
  87. ;;
  88. *)
  89. AC_MSG_RESULT([${host_os}])
  90. AX_PTHREAD([], [AC_MSG_ERROR([pthread is required to build $PACKAGE_NAME])])
  91. AC_CHECK_LIB(pthread, [pthread_once], [], [AC_MSG_ERROR([pthread with pthread_once required to build $PACKAGE_NAME])])
  92. ;;
  93. esac
  94. AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
  95. AM_CONDITIONAL(DARWIN, test x$darwin = xtrue)
  96. AC_CHECK_MEMBER(struct dirent.d_type, AC_DEFINE(HAVE_DIRENT_D_TYPE, 1, [define if struct dirent has member d_type]),, [#include <dirent.h>])
  97. # Cython Python Bindings
  98. AC_ARG_WITH([cython],
  99. [AS_HELP_STRING([--without-cython],
  100. [build Python bindings using Cython (default is yes)])],
  101. [build_cython=false],
  102. [build_cython=true])
  103. if test "$build_cython" = "true"; then
  104. AC_PROG_CYTHON([3.0.0])
  105. if [test "x$CYTHON" != "xfalse"]; then
  106. AM_PATH_PYTHON([3.0], [
  107. CYTHON_PYTHON
  108. AS_COMPILER_FLAG([-Wno-cast-function-type -Werror], [
  109. CYTHON_CFLAGS+=" -Wno-cast-function-type"
  110. AC_SUBST([CYTHON_CFLAGS])
  111. ], [])
  112. ])
  113. else
  114. AC_MSG_WARN([Use the "--without-cython" option to avoid this warning.])
  115. fi
  116. else
  117. CYTHON=false
  118. fi
  119. if [test "x$CYTHON" != "xfalse"]; then
  120. PKG_PROG_PKG_CONFIG
  121. AC_MSG_CHECKING([for libplist Cython bindings])
  122. CYTHON_PLIST_INCLUDE_DIR=$($PKG_CONFIG --variable=includedir libplist-2.0)/plist/cython
  123. if [test ! -d "$CYTHON_PLIST_INCLUDE_DIR"]; then
  124. CYTHON=false
  125. CYTHON_SUB=
  126. cython_python_bindings=no
  127. AC_MSG_RESULT([no])
  128. AC_MSG_WARN([Unable to find libplist Cython bindings. You should install your distribution specific libplist Cython bindings package.])
  129. else
  130. AC_SUBST([CYTHON_PLIST_INCLUDE_DIR])
  131. AC_MSG_RESULT([$CYTHON_PLIST_INCLUDE_DIR])
  132. CYTHON_SUB=cython
  133. cython_python_bindings=yes
  134. fi
  135. else
  136. CYTHON_SUB=
  137. cython_python_bindings=no
  138. fi
  139. AM_CONDITIONAL([HAVE_CYTHON],[test "x$CYTHON_SUB" = "xcython"])
  140. AC_SUBST([CYTHON_SUB])
  141. default_openssl=yes
  142. AC_ARG_WITH([mbedtls],
  143. [AS_HELP_STRING([--without-mbedtls],
  144. [Do not look for mbedtls])],
  145. [use_mbedtls=$withval],
  146. [use_mbedtls=no])
  147. if test "x$use_mbedtls" = "xyes"; then
  148. default_openssl=no
  149. fi
  150. AC_ARG_WITH([gnutls],
  151. [AS_HELP_STRING([--without-gnutls],
  152. [Do not look for GnuTLS])],
  153. [use_gnutls=$withval],
  154. [use_gnutls=no])
  155. if test "x$use_gnutls" = "xyes"; then
  156. default_openssl=no
  157. fi
  158. AC_ARG_WITH([openssl],
  159. [AS_HELP_STRING([--without-openssl],
  160. [Do not look for OpenSSL])],
  161. [use_openssl=$withval],
  162. [use_openssl=$default_openssl])
  163. if test "x$use_mbedtls" = "xyes"; then
  164. CACHED_CFLAGS="$CFLAGS"
  165. conf_mbedtls_CFLAGS=""
  166. if test -n "$mbedtls_INCLUDES"; then
  167. CFLAGS=" -I$mbedtls_INCLUDES"
  168. conf_mbedtls_CFLAGS="-I$mbedtls_INCLUDES"
  169. fi
  170. conf_mbedtls_LIBS=""
  171. if test -n "$mbedtls_LIBDIR"; then
  172. conf_mbedtls_LIBS+=" -L$mbedtls_LIBDIR"
  173. fi
  174. if test -n "$mbedtls_LIBS"; then
  175. conf_mbedtls_LIBS+=" $mbedtls_LIBS"
  176. else
  177. conf_mbedtls_LIBS+=" -lmbedtls -lmbedx509 -lmbedcrypto"
  178. fi
  179. AC_CHECK_HEADER(mbedtls/ssl.h, [break], [AC_MSG_ERROR([MbedTLS support explicitly requested, but includes could not be found. Try setting mbedtls_INCLUDES=/path/to/mbedtls/include])])
  180. CFLAGS="$CACHED_CFLAGS"
  181. AC_DEFINE(HAVE_MBEDTLS, 1, [Define if you have MbedTLS support])
  182. ssl_lib_CFLAGS="$conf_mbedtls_CFLAGS"
  183. ssl_lib_LIBS="$conf_mbedtls_LIBS"
  184. AC_SUBST(ssl_lib_CFLAGS)
  185. AC_SUBST(ssl_lib_LIBS)
  186. ssl_provider="MbedTLS";
  187. ssl_requires=""
  188. AC_SUBST(ssl_requires)
  189. else
  190. if test "x$use_openssl" = "xyes"; then
  191. pkg_req_openssl="openssl >= 0.9.8"
  192. PKG_CHECK_MODULES(openssl, $pkg_req_openssl, have_openssl=yes, have_openssl=no)
  193. if test "x$have_openssl" != "xyes"; then
  194. AC_MSG_ERROR([OpenSSL support explicitly requested but OpenSSL could not be found])
  195. else
  196. AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have OpenSSL support])
  197. ssl_lib_CFLAGS="$openssl_CFLAGS"
  198. ssl_lib_LIBS="$openssl_LIBS"
  199. AC_SUBST(ssl_lib_CFLAGS)
  200. AC_SUBST(ssl_lib_LIBS)
  201. ssl_provider="OpenSSL";
  202. ssl_requires="$pkg_req_openssl"
  203. # test if we have LibreSSL
  204. CACHED_CFLAGS="$CFLAGS"
  205. CFLAGS="$openssl_CFLAGS"
  206. ac_cv_is_libressl=no
  207. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  208. [[
  209. #include <openssl/opensslv.h>
  210. ]], [
  211. #ifndef LIBRESSL_VERSION_NUMBER
  212. #error No LibreSSL
  213. #endif
  214. ])],
  215. [
  216. ac_cv_is_libressl=yes
  217. ],
  218. )
  219. CFLAGS="$CACHED_CFLAGS"
  220. if test "x$ac_cv_is_libressl" = "xyes"; then
  221. ssl_provider="LibreSSL"
  222. case ${host_os} in
  223. darwin*)
  224. case ${openssl_LIBS} in
  225. *.tbd*)
  226. # using system LibreSSL on Darwin
  227. ssl_requires=""
  228. ;;
  229. esac
  230. ;;
  231. esac
  232. fi
  233. AC_SUBST(ssl_requires)
  234. fi
  235. else
  236. if test "x$use_gnutls" = "xyes"; then
  237. pkg_req_gnutls="gnutls >= 2.2.0"
  238. pkg_req_libtasn1="libtasn1 >= 1.1"
  239. PKG_CHECK_MODULES(libgnutls, $pkg_req_gnutls)
  240. AC_CHECK_HEADERS([gcrypt.h])
  241. AC_CHECK_LIB(gcrypt, gcry_control, [AC_SUBST(libgcrypt_LIBS,[-lgcrypt])], [AC_MSG_ERROR([libgcrypt is required to build libimobiledevice with GnuTLS])])
  242. PKG_CHECK_MODULES(libtasn1, $pkg_req_libtasn1)
  243. AC_DEFINE(HAVE_GCRYPT, 1, [Define if you have libgcrypt support])
  244. AC_DEFINE(HAVE_GNUTLS, 1, [Define if you have GnuTLS support])
  245. ssl_lib_CFLAGS="$libgnutls_CFLAGS $libtasn1_CFLAGS $libgcrypt_CFLAGS"
  246. ssl_lib_LIBS="$libgnutls_LIBS $libtasn1_LIBS $libgcrypt_LIBS"
  247. AC_SUBST(ssl_lib_CFLAGS)
  248. AC_SUBST(ssl_lib_LIBS)
  249. ssl_provider="GnuTLS"
  250. ssl_requires="$pkg_req_gnutls $pkg_req_libtasn1"
  251. AC_SUBST(ssl_requires)
  252. else
  253. AC_MSG_ERROR([No SSL library configured. $PACKAGE cannot be built without a supported SSL library.])
  254. fi
  255. fi
  256. fi
  257. AM_CONDITIONAL(HAVE_MBEDTLS, test "x$use_mbedtls" = "xyes")
  258. AM_CONDITIONAL(HAVE_OPENSSL, test "x$use_openssl" = "xyes")
  259. AM_CONDITIONAL(HAVE_GCRYPT, test "x$use_gnutls" = "xyes")
  260. AC_ARG_ENABLE([wireless-pairing],
  261. [AS_HELP_STRING([--disable-wireless-pairing],
  262. [Do not build with wirless pairing support (default is yes)])])
  263. if test "$enable_wireless_pairing" != "no"; then
  264. AC_DEFINE(HAVE_WIRELESS_PAIRING,1,[Define if building with wireless pairing support])
  265. fi
  266. AM_CONDITIONAL(HAVE_WIRELESS_PAIRING, test "$enable_wireless_pairing" != "no")
  267. AC_ARG_ENABLE([debug],
  268. [AS_HELP_STRING([--enable-debug],
  269. [build debug message output code (default is no)])],
  270. [no_debug_code=false],
  271. [no_debug_code=true])
  272. if test "$no_debug_code" = true; then
  273. building_debug_code=no
  274. AC_DEFINE(STRIP_DEBUG_CODE,1,[Define if debug message output code should not be built.])
  275. else
  276. building_debug_code=yes
  277. fi
  278. AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden")
  279. if test "x$enable_static" = "xyes" -a "x$enable_shared" = "xno"; then
  280. GLOBAL_CFLAGS+=" -DLIBIMOBILEDEVICE_STATIC"
  281. fi
  282. AC_SUBST(GLOBAL_CFLAGS)
  283. # check for large file support
  284. AC_SYS_LARGEFILE
  285. m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
  286. AC_CONFIG_FILES([
  287. Makefile
  288. 3rd_party/Makefile
  289. 3rd_party/ed25519/Makefile
  290. 3rd_party/libsrp6a-sha512/Makefile
  291. common/Makefile
  292. src/Makefile
  293. src/libimobiledevice-1.0.pc
  294. include/Makefile
  295. tools/Makefile
  296. cython/Makefile
  297. docs/Makefile
  298. doxygen.cfg
  299. ])
  300. AC_OUTPUT
  301. echo "
  302. Configuration for $PACKAGE $VERSION:
  303. -------------------------------------------
  304. Install prefix: .........: $prefix
  305. Debug code ..............: $building_debug_code
  306. Python bindings .........: $cython_python_bindings
  307. SSL support backend .....: $ssl_provider
  308. Now type 'make' to build $PACKAGE $VERSION,
  309. and then 'make install' for installation.
  310. "