configure.ac 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ(2.68)
  4. AC_INIT([libirecovery], [m4_esyscmd(./git-version-gen $RELEASE_VERSION)], [https://github.com/libimobiledevice/libirecovery/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. LIBIRECOVERY_SO_VERSION=5:1:0
  17. dnl Minimum package versions
  18. LIBUSB_VERSION=1.0.3
  19. LIMD_GLUE_VERSION=1.2.0
  20. AC_SUBST(LIBIRECOVERY_SO_VERSION)
  21. AC_SUBST(LIMD_GLUE_VERSION)
  22. # Checks for programs.
  23. AC_PROG_CC
  24. #AC_PROG_CXX
  25. AM_PROG_CC_C_O
  26. LT_INIT
  27. # Checks for libraries.
  28. PKG_CHECK_MODULES(limd_glue, libimobiledevice-glue-1.0 >= $LIMD_GLUE_VERSION)
  29. # Checks for header files.
  30. AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
  31. # Checks for typedefs, structures, and compiler characteristics.
  32. AC_C_CONST
  33. AC_TYPE_SIZE_T
  34. AC_TYPE_SSIZE_T
  35. AC_TYPE_UINT16_T
  36. AC_TYPE_UINT32_T
  37. AC_TYPE_UINT8_T
  38. # Checks for library functions.
  39. AC_CHECK_FUNCS([strdup strerror strcasecmp strndup malloc realloc calloc])
  40. # Check additional platform flags
  41. AC_MSG_CHECKING([for platform-specific build settings])
  42. case ${host_os} in
  43. darwin*)
  44. AC_MSG_RESULT([${host_os}])
  45. AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h, [
  46. AC_CHECK_HEADER(IOKit/usb/IOUSBLib.h, [
  47. GLOBAL_LDFLAGS+=" -framework IOKit -framework CoreFoundation"
  48. have_iokit=yes
  49. ], [])
  50. ], [])
  51. ;;
  52. mingw32*)
  53. AC_MSG_RESULT([${host_os}])
  54. GLOBAL_LDFLAGS+=" -static-libgcc -lkernel32 -lsetupapi"
  55. win32=true
  56. ;;
  57. cygwin*)
  58. AC_MSG_RESULT([${host_os}])
  59. CC=gcc-3
  60. CFLAGS+=" -mno-cygwin"
  61. GLOBAL_LDFLAGS+=" -static-libgcc -lkernel32 -lsetupapi"
  62. win32=true
  63. ;;
  64. *)
  65. AC_MSG_RESULT([${host_os}])
  66. ;;
  67. esac
  68. AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
  69. AC_ARG_WITH([tools],
  70. [AS_HELP_STRING([--with-tools], [Build irecovery tools. [default=yes]])],
  71. [],
  72. [with_tools=yes])
  73. AS_IF([test "x$with_tools" = "xyes"], [
  74. have_readline=no
  75. AC_DEFINE(BUILD_TOOLS, 1, [Define if we are building irecovery tools])
  76. AC_CHECK_HEADERS([readline/readline.h],
  77. [AC_DEFINE(HAVE_READLINE, 1, [Define if readline is available])
  78. have_readline=yes],
  79. [AC_MSG_NOTICE([NOTE: Building without readline support. If you want readline support, install its development package.])]
  80. )
  81. AM_CONDITIONAL(HAVE_READLINE, test "x$have_readline" = "xyes")
  82. ])
  83. AM_CONDITIONAL(BUILD_TOOLS, test "x$with_tools" = "xyes")
  84. AC_ARG_WITH([dummy],
  85. [AS_HELP_STRING([--with-dummy], [Use no USB driver at all [default=no]. This is only useful if you just want to query the device list by product type or hardware model. All other operations are no-ops or will return IRECV_E_UNSUPPORTED.])],
  86. [],
  87. [with_dummy=no])
  88. AS_IF([test "x$have_iokit" = "xyes"], [
  89. AC_ARG_WITH([iokit],
  90. [AS_HELP_STRING([--with-iokit], [Use IOKit instead of libusb on OS X [default=yes]])],
  91. [],
  92. [with_iokit=yes])
  93. ]
  94. )
  95. AS_IF([test "x$with_dummy" = "xyes"], [
  96. AC_DEFINE(USE_DUMMY, 1, [Define if we are using dummy USB driver])
  97. USB_BACKEND="dummy"
  98. ], [
  99. AS_IF([test "x$with_iokit" = "xyes" && test "x$have_iokit" = "xyes"], [
  100. AC_DEFINE(HAVE_IOKIT, 1, [Define if we have IOKit])
  101. USB_BACKEND="IOKit"
  102. ], [
  103. AS_IF([test "x$win32" = "xtrue"], [
  104. USB_BACKEND="win32 native (setupapi)"
  105. ], [
  106. PKG_CHECK_MODULES(libusb, libusb-1.0 >= $LIBUSB_VERSION)
  107. USB_BACKEND="libusb `$PKG_CONFIG --modversion libusb-1.0`"
  108. LIBUSB_REQUIRED="libusb-1.0 >= $LIBUSB_VERSION"
  109. AC_SUBST(LIBUSB_REQUIRED)
  110. ])
  111. ])
  112. ])
  113. AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fvisibility=hidden")
  114. if test "x$enable_static" = "xyes" -a "x$enable_shared" = "xno"; then
  115. GLOBAL_CFLAGS+=" -DIRECV_STATIC"
  116. fi
  117. AC_SUBST(GLOBAL_CFLAGS)
  118. AC_SUBST(GLOBAL_LDFLAGS)
  119. # check for large file support
  120. AC_SYS_LARGEFILE
  121. AC_ARG_WITH([udev],
  122. AS_HELP_STRING([--with-udev],
  123. [Configure and install udev rules file for DFU/Recovery mode devices]),
  124. [],
  125. [if $($PKG_CONFIG --exists udev); then with_udev=yes; else with_udev=no; fi])
  126. AC_ARG_WITH([udevrulesdir],
  127. AS_HELP_STRING([--with-udevrulesdir=DIR],
  128. [Directory for udev rules (implies --with-udev)]),
  129. [with_udev=yes],
  130. [with_udevrulesdir=auto])
  131. AC_ARG_WITH([udevrule],
  132. AS_HELP_STRING([--with-udevrule="RULE"],
  133. [udev activation rule (implies --with-udev)]),
  134. [with_udev=yes],
  135. [with_udevrule=auto])
  136. if test "x$with_udev" = "xyes"; then
  137. if test "x$with_udevrule" = "xauto"; then
  138. for I in plugdev storage disk staff; do
  139. if grep $I /etc/group >/dev/null; then
  140. USEGROUP=$I
  141. break
  142. fi
  143. done
  144. if test "x$USEGROUP" != "x"; then
  145. if ! groups |grep $USEGROUP >/dev/null; then
  146. AC_MSG_WARN([The group '$USEGROUP' was determined to be used for the udev rule, but the current user is not member of this group.])
  147. fi
  148. else
  149. AC_MSG_ERROR([Could not determine an appropriate user group for the udev activation rule.
  150. Please manually specify a udev activation rule using --with-udevrule=<RULE>
  151. Example: --with-udevrule="OWNER=\\"root\\", GROUP=\\"myusergroup\\", MODE=\\"0660\\""])
  152. fi
  153. with_udevrule="OWNER=\"root\", GROUP=\"$USEGROUP\", MODE=\"0660\""
  154. fi
  155. if test "x$with_udevrulesdir" = "xauto"; then
  156. udevdir=$($PKG_CONFIG --silence-errors --variable=udevdir udev)
  157. if test "x$udevdir" != "x"; then
  158. with_udevrulesdir=$udevdir"/rules.d"
  159. else
  160. with_udevrulesdir="\${prefix}/lib/udev/rules.d"
  161. AC_MSG_WARN([Could not determine default udev rules directory. Using $with_udevrulesdir.])
  162. fi
  163. fi
  164. AC_SUBST([udev_activation_rule], [$with_udevrule])
  165. AC_SUBST([udevrulesdir], [$with_udevrulesdir])
  166. fi
  167. AM_CONDITIONAL(WITH_UDEV, test "x$with_udev" = "xyes")
  168. m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
  169. AC_CONFIG_FILES([
  170. Makefile
  171. src/Makefile
  172. src/libirecovery-1.0.pc
  173. udev/39-libirecovery.rules
  174. include/Makefile
  175. tools/Makefile
  176. udev/Makefile
  177. ])
  178. AC_OUTPUT
  179. echo "
  180. Configuration for $PACKAGE $VERSION:
  181. -------------------------------------------
  182. Install prefix: .........: $prefix
  183. USB backend: ............: $USB_BACKEND
  184. Now type 'make' to build $PACKAGE $VERSION,
  185. and then 'make install' for installation.
  186. "