configure.ac 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ(2.68)
  4. AC_INIT(libusbmuxd, [m4_esyscmd(./git-version-gen $RELEASE_VERSION)], [https://github.com/libimobiledevice/libusbmuxd/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. LIBUSBMUXD_SO_VERSION=7:0:0
  17. AC_SUBST(LIBUSBMUXD_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. LIBPLIST_VERSION=2.2.0
  24. LIMD_GLUE_VERSION=1.2.0
  25. AC_SUBST(LIBPLIST_VERSION)
  26. AC_SUBST(LIMD_GLUE_VERSION)
  27. # Checks for programs.
  28. AC_PROG_CC
  29. #AC_PROG_CXX
  30. AM_PROG_CC_C_O
  31. LT_INIT
  32. # Checks for libraries.
  33. PKG_CHECK_MODULES(libplist, libplist-2.0 >= $LIBPLIST_VERSION)
  34. PKG_CHECK_MODULES(limd_glue, libimobiledevice-glue-1.0 >= $LIMD_GLUE_VERSION)
  35. AC_CHECK_HEADERS([sys/inotify.h], have_inotify=yes, have_inotify=no)
  36. AC_ARG_WITH([inotify],
  37. [AS_HELP_STRING([--without-inotify],
  38. [(Linux only) do not build with inotify support (default is yes)])],
  39. [with_inotify=no],
  40. [with_inotify=yes])
  41. if test "x$have_inotify" = "xyes"; then
  42. if test "x$with_inotify" != "xyes"; then
  43. have_inotify=no
  44. echo "*** Note: inotify support has been disabled ***"
  45. else
  46. AC_DEFINE(HAVE_INOTIFY, 1, [Define if you have inotify support (linux only)])
  47. fi
  48. fi
  49. # Checks for header files.
  50. AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
  51. # Checks for typedefs, structures, and compiler characteristics.
  52. AC_C_CONST
  53. AC_TYPE_SIZE_T
  54. AC_TYPE_SSIZE_T
  55. AC_TYPE_UINT16_T
  56. AC_TYPE_UINT32_T
  57. AC_TYPE_UINT8_T
  58. # Checks for library functions.
  59. AC_CHECK_FUNCS([strcasecmp strdup strerror stpncpy malloc realloc getifaddrs])
  60. # Check for operating system
  61. AC_MSG_CHECKING([for platform-specific build settings])
  62. case ${host_os} in
  63. *mingw32*|*cygwin*)
  64. AC_MSG_RESULT([${host_os}])
  65. win32=true
  66. AC_DEFINE(WINVER, 0x0501, [minimum Windows version])
  67. ;;
  68. darwin*)
  69. AC_MSG_RESULT([${host_os}])
  70. ;;
  71. *)
  72. AC_MSG_RESULT([${host_os}])
  73. if test "x$have_inotify" = "xyes"; then
  74. AC_CHECK_FUNCS([pselect])
  75. AC_CHECK_FUNC(pthread_cancel, [AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if you have pthread_cancel])], [
  76. AC_CHECK_LIB(pthread, [pthread_cancel],[AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if you have pthread_cancel])])
  77. ])
  78. if test "$ac_cv_func_pselect" != "yes" || test "$ac_cv_func_pthread_cancel" != "yes" -a "$ac_cv_lib_pthread_pthread_cancel" != "yes"; then
  79. AX_PTHREAD([], [AC_MSG_ERROR([pthread is required to build $PACKAGE with inotify support])])
  80. fi
  81. fi
  82. AC_CACHE_CHECK(for program_invocation_short_name, ac_cv_program_invocation_short_name,[
  83. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([extern char* program_invocation_short_name;],[return program_invocation_short_name[0];])],
  84. [ac_cv_program_invocation_short_name=yes],
  85. [ac_cv_program_invocation_short_name=no]
  86. )
  87. ])
  88. if test "x$ac_cv_program_invocation_short_name" = "xyes"; then
  89. AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME, 1, [Define if you have program_invocation_short_name])
  90. AC_CACHE_CHECK(if program_invocation_short_name is declared in errno.h, ac_cv_program_invocation_short_name_errno_h,[
  91. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <errno.h>],[return program_invocation_short_name[0];])],
  92. [ac_cv_program_invocation_short_name_errno_h=yes],
  93. [ac_cv_program_invocation_short_name_errno_h=no]
  94. )
  95. ])
  96. if test "x$ac_cv_program_invocation_short_name_errno_h" = "xyes"; then
  97. AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME_ERRNO_H, 1, [Define if program_invocation_short_name is declared in errno.h])
  98. fi
  99. fi
  100. ;;
  101. esac
  102. AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
  103. AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fvisibility=hidden $PTHREAD_CFLAGS")
  104. GLOBAL_LDFLAGS="$PTHREAD_LIBS"
  105. if test "x$enable_static" = "xyes" -a "x$enable_shared" = "xno"; then
  106. GLOBAL_CFLAGS+=" -DLIBUSBMUXD_STATIC"
  107. fi
  108. AC_SUBST(GLOBAL_CFLAGS)
  109. AC_SUBST(GLOBAL_LDFLAGS)
  110. m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
  111. AC_CONFIG_FILES([
  112. Makefile
  113. src/Makefile
  114. include/Makefile
  115. tools/Makefile
  116. docs/Makefile
  117. src/libusbmuxd-2.0.pc
  118. ])
  119. AC_OUTPUT
  120. echo "
  121. Configuration for $PACKAGE $VERSION:
  122. -------------------------------------------
  123. Install prefix: .........: $prefix
  124. inotify support (Linux) .: $have_inotify
  125. Now type 'make' to build $PACKAGE $VERSION,
  126. and then 'make install' for installation.
  127. "