configure.ac 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ(2.64)
  4. AC_INIT([usbmuxd], [1.1.0], [https://github.com/libimobiledevice/usbmuxd/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. # Checks for programs.
  11. AC_PROG_CC
  12. AC_PROG_CXX
  13. AM_PROG_CC_C_O
  14. AC_PROG_LIBTOOL
  15. # Checks for libraries.
  16. PKG_CHECK_MODULES(libusb, libusb-1.0 >= 1.0.3)
  17. PKG_CHECK_MODULES(libplist, libplist >= 1.11)
  18. PKG_CHECK_MODULES(libimobiledevice, libimobiledevice-1.0 >= 1.1.6, have_limd=yes, have_limd=no)
  19. AC_CHECK_LIB(pthread, [pthread_create, pthread_mutex_lock], [AC_SUBST(libpthread_LIBS,[-lpthread])], [AC_MSG_ERROR([libpthread is required to build usbmuxd])])
  20. AC_ARG_WITH([preflight],
  21. [AS_HELP_STRING([--without-preflight],
  22. [do not build with preflight worker support @<:@default=yes@:>@])],
  23. [with_preflight=no],
  24. [with_preflight=yes])
  25. if test "x$have_limd" = "xyes"; then
  26. if test "x$with_preflight" != "xyes"; then
  27. have_limd=no
  28. echo "*** Note: preflight worker support has been disabled ***"
  29. else
  30. AC_DEFINE(HAVE_LIBIMOBILEDEVICE, 1, [Define if you have libimobiledevice support])
  31. AC_SUBST(libimobiledevice_CFLAGS)
  32. AC_SUBST(libimobiledevice_LIBS)
  33. fi
  34. else
  35. if test "x$with_preflight" == "xyes"; then
  36. AC_MSG_ERROR([preflight worker support requested but libimobiledevice could not be found])
  37. fi
  38. fi
  39. AC_ARG_WITH([udevrulesdir],
  40. AS_HELP_STRING([--with-udevrulesdir=DIR],
  41. [Directory for udev rules]),
  42. [],
  43. [with_udevrulesdir=auto])
  44. if test "x$with_udevrulesdir" = "xauto"; then
  45. udevdir=$($PKG_CONFIG --variable=udevdir udev)
  46. if test "x$udevdir" != "x"; then
  47. with_udevrulesdir=$udevdir"/rules.d"
  48. else
  49. with_udevrulesdir=$prefix/lib/udev/rules.d
  50. fi
  51. fi
  52. AC_ARG_WITH([systemd],
  53. [AS_HELP_STRING([--without-systemd],
  54. [do not build with systemd support @<:@default=yes@:>@])],
  55. [with_systemd=no],
  56. [with_systemd=yes])
  57. AC_ARG_WITH([systemdsystemunitdir],
  58. [AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
  59. [directory for systemd service files])],
  60. [with_systemdsystemunitdir=$withval],
  61. [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
  62. if test "x$with_systemdsystemunitdir" != xno; then
  63. AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
  64. fi
  65. AM_CONDITIONAL(WANT_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno -a "x$with_systemd" = "xyes" ])
  66. if test "x$with_systemd" = xyes; then
  67. udev_activation_rule="TAG+=\"systemd\", ENV{SYSTEMD_WANTS}=\"usbmuxd.service\""
  68. else
  69. udev_activation_rule="RUN+=\"@sbindir@/usbmuxd --user usbmux --udev\""
  70. fi
  71. AC_SUBST(udev_activation_rule)
  72. # Checks for header files.
  73. AC_HEADER_STDC
  74. AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
  75. # Checks for typedefs, structures, and compiler characteristics.
  76. AC_C_CONST
  77. AC_TYPE_SIZE_T
  78. AC_TYPE_SSIZE_T
  79. AC_TYPE_UINT16_T
  80. AC_TYPE_UINT32_T
  81. AC_TYPE_UINT8_T
  82. # Checks for library functions.
  83. AC_FUNC_MALLOC
  84. AC_FUNC_REALLOC
  85. AC_CHECK_FUNCS([strcasecmp strdup strerror strndup stpcpy])
  86. # Check for operating system
  87. AC_MSG_CHECKING([whether to enable WIN32 build settings])
  88. UDEV_SUB=
  89. SYSTEMD_SUB=
  90. case ${host_os} in
  91. *mingw32*|*cygwin*)
  92. win32=true
  93. AC_MSG_RESULT([yes])
  94. AC_CHECK_TOOL([WINDRES], [windres], AC_MSG_ERROR([windres not found]))
  95. AC_SUBST(WINDRES)
  96. activation_method="manual"
  97. ;;
  98. darwin*)
  99. win32=false
  100. AC_MSG_RESULT([no])
  101. # No support for launchd yet
  102. activation_method="manual"
  103. ;;
  104. *)
  105. win32=false
  106. AC_MSG_RESULT([no])
  107. UDEV_SUB=udev
  108. AC_SUBST([udevrulesdir], [$with_udevrulesdir])
  109. AC_DEFINE(HAVE_UDEV, 1, [Define to enable udev support])
  110. activation_method="systemd"
  111. if test "x$with_systemd" != "xyes"; then
  112. echo "*** Note: support for systemd activation has been disabled, using udev activation instead ***"
  113. activation_method="udev"
  114. else
  115. AC_DEFINE(HAVE_SYSTEMD, 1, [Define to enable systemd support])
  116. SYSTEMD_SUB=systemd
  117. fi
  118. ;;
  119. esac
  120. AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
  121. AC_SUBST([UDEV_SUB])
  122. AC_SUBST([SYSTEMD_SUB])
  123. AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-g -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter")
  124. AC_SUBST(GLOBAL_CFLAGS)
  125. m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
  126. AC_OUTPUT([
  127. Makefile
  128. src/Makefile
  129. udev/Makefile
  130. systemd/Makefile
  131. docs/Makefile
  132. ])
  133. echo "
  134. Configuration for $PACKAGE $VERSION:
  135. -------------------------------------------
  136. install prefix ............: $prefix
  137. preflight worker support ..: $have_limd
  138. activation method .........: $activation_method"
  139. if test "x$activation_method" = "xsystemd"; then
  140. echo " systemd unit directory ....: ${systemdsystemunitdir}"
  141. fi
  142. if test -n "$udevrulesdir"; then
  143. echo " udev rules directory ......: ${udevrulesdir}"
  144. fi
  145. echo " compiler ..................: ${CC}
  146. Now type 'make' to build $PACKAGE $VERSION,
  147. and then 'make install' for installation.
  148. "