configure.ac 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ(2.64)
  4. AC_INIT([libimobiledevice], [1.2.0], [https://github.com/libimobiledevice/libimobiledevice/issues],, [http://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. dnl Minimum package versions
  18. LIBUSBMUXD_VERSION=1.0.9
  19. LIBPLIST_VERSION=1.11
  20. LIBPLISTMM_VERSION=1.11
  21. AC_SUBST(LIBIMOBILEDEVICE_SO_VERSION)
  22. AC_SUBST(LIBUSBMUXD_VERSION)
  23. AC_SUBST(LIBPLIST_VERSION)
  24. AC_SUBST(LIBPLISTMM_VERSION)
  25. # Checks for programs.
  26. AC_PROG_CC
  27. AC_PROG_CXX
  28. AM_PROG_CC_C_O
  29. AC_PROG_LIBTOOL
  30. # Checks for libraries.
  31. PKG_CHECK_MODULES(libusbmuxd, libusbmuxd >= $LIBUSBMUXD_VERSION)
  32. PKG_CHECK_MODULES(libplist, libplist >= $LIBPLIST_VERSION)
  33. PKG_CHECK_MODULES(libplistmm, libplist++ >= $LIBPLISTMM_VERSION)
  34. AC_CHECK_LIB(pthread, [pthread_create, pthread_mutex_lock], [AC_SUBST(libpthread_LIBS,[-lpthread])], [AC_MSG_ERROR([libpthread is required to build libimobiledevice])])
  35. # Checks for header files.
  36. AC_HEADER_STDC
  37. AC_CHECK_HEADERS([stdint.h stdlib.h string.h gcrypt.h])
  38. # Checks for typedefs, structures, and compiler characteristics.
  39. AC_C_CONST
  40. AC_TYPE_SIZE_T
  41. AC_TYPE_SSIZE_T
  42. AC_TYPE_UINT16_T
  43. AC_TYPE_UINT32_T
  44. AC_TYPE_UINT8_T
  45. # Checks for library functions.
  46. AC_CHECK_FUNCS([asprintf strcasecmp strdup strerror strndup stpcpy vasprintf])
  47. AC_CHECK_HEADER(endian.h, [ac_cv_have_endian_h="yes"], [ac_cv_have_endian_h="no"])
  48. if test "x$ac_cv_have_endian_h" = "xno"; then
  49. AC_DEFINE(__LITTLE_ENDIAN,1234,[little endian])
  50. AC_DEFINE(__BIG_ENDIAN,4321,[big endian])
  51. AC_C_BIGENDIAN([ac_cv_c_bigendian="yes"], [ac_cv_c_bigendian="no"], [], [])
  52. if test "x$ac_cv_c_bigendian" = "xyes"; then
  53. AC_DEFINE(__BYTE_ORDER,4321,[big endian byte order])
  54. else
  55. AC_DEFINE(__BYTE_ORDER,1234,[little endian byte order])
  56. fi
  57. fi
  58. # Check for operating system
  59. AC_MSG_CHECKING([whether to enable WIN32 build settings])
  60. case ${host_os} in
  61. *mingw32*|*cygwin*)
  62. win32=true
  63. AC_MSG_RESULT([yes])
  64. AC_CHECK_TOOL([WINDRES], [windres], AC_MSG_ERROR([windres not found]))
  65. AC_SUBST(WINDRES)
  66. ;;
  67. *)
  68. win32=false
  69. AC_MSG_RESULT([no])
  70. ;;
  71. esac
  72. AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
  73. # Cython Python Bindings
  74. AC_ARG_WITH([cython],
  75. [AS_HELP_STRING([--without-cython],
  76. [build Python bindings using Cython (default is yes)])],
  77. [build_cython=false],
  78. [build_cython=true])
  79. if test "$build_cython" = "true"; then
  80. AM_PATH_PYTHON(2.3)
  81. AC_PROG_CYTHON(0.17.0)
  82. CYTHON_PYTHON
  83. else
  84. CYTHON=false
  85. fi
  86. if [test "x$CYTHON" != "xfalse"]; then
  87. AC_MSG_CHECKING([for libplist Cython bindings])
  88. CYTHON_PLIST_INCLUDE_DIR=$($PKG_CONFIG --variable=includedir libplist)/plist/cython
  89. if [test ! -d "$CYTHON_PLIST_INCLUDE_DIR"]; then
  90. CYTHON=false
  91. CYTHON_SUB=
  92. cython_python_bindings=no
  93. AC_MSG_RESULT([no])
  94. AC_MSG_WARN([cannot find libplist Cython bindings. You should install your distribution specific libplist Cython bindings package.])
  95. else
  96. AC_SUBST([CYTHON_PLIST_INCLUDE_DIR])
  97. AC_MSG_RESULT([$CYTHON_PLIST_INCLUDE_DIR])
  98. CYTHON_SUB=cython
  99. cython_python_bindings=yes
  100. fi
  101. else
  102. CYTHON_SUB=
  103. cython_python_bindings=no
  104. fi
  105. AM_CONDITIONAL([HAVE_CYTHON],[test "x$CYTHON_SUB" = "xcython"])
  106. AC_SUBST([CYTHON_SUB])
  107. AC_ARG_ENABLE([openssl],
  108. [AS_HELP_STRING([--disable-openssl],
  109. [Do not look for OpenSSL])],
  110. [use_openssl=no],
  111. [use_openssl=yes])
  112. pkg_req_openssl="openssl >= 0.9.8"
  113. PKG_CHECK_MODULES(openssl, $pkg_req_openssl, have_openssl=yes, have_openssl=no)
  114. if test "x$have_openssl" = "xyes"; then
  115. if test "x$use_openssl" != "xyes"; then
  116. enable_openssl=no
  117. echo "*** Note: OpenSSL support explicitly disabled ***"
  118. else
  119. enable_openssl=yes
  120. fi
  121. else
  122. if test "x$use_openssl" == "xyes" -a "x$have_openssl" != "xyes"; then
  123. AC_MSG_ERROR([OpenSSL support explicitly requested but OpenSSL could not be found])
  124. fi
  125. fi
  126. if test "x$enable_openssl" = "xyes"; then
  127. AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have OpenSSL support])
  128. AC_SUBST(openssl_CFLAGS)
  129. AC_SUBST(openssl_LIBS)
  130. ssl_provider="OpenSSL";
  131. ssl_requires="$pkg_req_openssl"
  132. AC_SUBST(ssl_requires)
  133. else
  134. pkg_req_gnutls="gnutls >= 2.2.0"
  135. pkg_req_libtasn1="libtasn1 >= 1.1"
  136. PKG_CHECK_MODULES(libgnutls, $pkg_req_gnutls)
  137. AC_CHECK_LIB(gcrypt, gcry_control, [AC_SUBST(libgcrypt_LIBS,[-lgcrypt])], [AC_MSG_ERROR([libgcrypt is required to build libimobiledevice with GnuTLS])])
  138. PKG_CHECK_MODULES(libtasn1, $pkg_req_libtasn1)
  139. ssl_provider="GnuTLS"
  140. ssl_requires="$pkg_req_gnutls $pkg_req_libtasn1"
  141. AC_SUBST(ssl_requires)
  142. fi
  143. AC_ARG_ENABLE([debug-code],
  144. [AS_HELP_STRING([--enable-debug-code],
  145. [enable debug message reporting in library (default is no)])],
  146. [no_debug_code=false],
  147. [no_debug_code=true])
  148. if test "$no_debug_code" = true; then
  149. building_debug_code=no
  150. AC_DEFINE(STRIP_DEBUG_CODE,1,[Strip debug reporting code])
  151. else
  152. building_debug_code=yes
  153. fi
  154. 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")
  155. AC_SUBST(GLOBAL_CFLAGS)
  156. case "$GLOBAL_CFLAGS" in
  157. *-fvisibility=hidden*)
  158. AC_DEFINE([HAVE_FVISIBILITY], [1], [Define if compiled with -fvisibility=hidden])
  159. esac
  160. # check for large file support
  161. AC_SYS_LARGEFILE
  162. LFS_CFLAGS=''
  163. if test "$enable_largefile" != no; then
  164. if test "$ac_cv_sys_file_offset_bits" != 'no'; then
  165. LFS_CFLAGS="$LFS_CFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
  166. else
  167. AC_MSG_CHECKING(for native large file support)
  168. AC_RUN_IFELSE([AC_LANG_SOURCE([#include <unistd.h>
  169. int main (int argc, char **argv)
  170. {
  171. exit(!(sizeof(off_t) == 8));
  172. }])],
  173. [ac_cv_sys_file_offset_bits=64; AC_DEFINE(_FILE_OFFSET_BITS,64)
  174. AC_MSG_RESULT(yes)],
  175. [AC_MSG_RESULT(no)])
  176. fi
  177. if test "$ac_cv_sys_large_files" != 'no'; then
  178. LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES=1"
  179. fi
  180. AC_FUNC_FSEEKO
  181. if test "$ac_cv_sys_largefile_source" != 'no'; then
  182. LFS_CFLAGS="$LFS_CFLAGS -D_LARGEFILE_SOURCE=1"
  183. fi
  184. fi
  185. AC_SUBST(LFS_CFLAGS)
  186. m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
  187. AC_OUTPUT([
  188. Makefile
  189. common/Makefile
  190. src/Makefile
  191. src/libimobiledevice-1.0.pc
  192. include/Makefile
  193. tools/Makefile
  194. cython/Makefile
  195. docs/Makefile
  196. doxygen.cfg
  197. ])
  198. echo "
  199. Configuration for $PACKAGE $VERSION:
  200. -------------------------------------------
  201. Install prefix: .........: $prefix
  202. Debug code ..............: $building_debug_code
  203. Python bindings .........: $cython_python_bindings
  204. SSL support backend .....: $ssl_provider
  205. Now type 'make' to build $PACKAGE $VERSION,
  206. and then 'make install' for installation.
  207. "