configure.ac 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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=3:0:0
  17. dnl Minimum package versions
  18. LIBUSB_VERSION=1.0.3
  19. LIMD_GLUE_VERSION=1.0.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. # Checks for libraries.
  41. AC_CHECK_HEADERS([readline/readline.h], [],
  42. [AC_MSG_ERROR([Please install readline development headers])]
  43. )
  44. # Check additional platform flags
  45. AC_MSG_CHECKING([for platform-specific build settings])
  46. case ${host_os} in
  47. darwin*)
  48. AC_MSG_RESULT([${host_os}])
  49. AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h, [
  50. AC_CHECK_HEADER(IOKit/usb/IOUSBLib.h, [
  51. GLOBAL_LDFLAGS+=" -framework IOKit -framework CoreFoundation"
  52. have_iokit=yes
  53. ], [])
  54. ], [])
  55. ;;
  56. mingw32*)
  57. AC_MSG_RESULT([${host_os}])
  58. GLOBAL_LDFLAGS+=" -static-libgcc -lkernel32 -lsetupapi"
  59. win32=true
  60. ;;
  61. cygwin*)
  62. AC_MSG_RESULT([${host_os}])
  63. CC=gcc-3
  64. CFLAGS+=" -mno-cygwin"
  65. GLOBAL_LDFLAGS+=" -static-libgcc -lkernel32 -lsetupapi"
  66. win32=true
  67. ;;
  68. *)
  69. AC_MSG_RESULT([${host_os}])
  70. ;;
  71. esac
  72. AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
  73. # Check if the C compiler supports __attribute__((constructor))
  74. AC_CACHE_CHECK([wether the C compiler supports constructor/destructor attributes],
  75. ac_cv_attribute_constructor, [
  76. ac_cv_attribute_constructor=no
  77. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  78. [[
  79. static void __attribute__((constructor)) test_constructor(void) {
  80. }
  81. static void __attribute__((destructor)) test_destructor(void) {
  82. }
  83. ]], [])],
  84. [ac_cv_attribute_constructor=yes]
  85. )]
  86. )
  87. if test "$ac_cv_attribute_constructor" = "yes"; then
  88. AC_DEFINE(HAVE_ATTRIBUTE_CONSTRUCTOR, 1, [Define if the C compiler supports constructor/destructor attributes])
  89. fi
  90. AC_ARG_WITH([dummy],
  91. [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.])],
  92. [],
  93. [with_dummy=no])
  94. AS_IF([test "x$have_iokit" = "xyes"], [
  95. AC_ARG_WITH([iokit],
  96. [AS_HELP_STRING([--with-iokit], [Use IOKit instead of libusb on OS X [default=yes]])],
  97. [],
  98. [with_iokit=yes])
  99. ]
  100. )
  101. AS_IF([test "x$with_dummy" = "xyes"], [
  102. AC_DEFINE(USE_DUMMY, 1, [Define if we are using dummy USB driver])
  103. USB_BACKEND="dummy"
  104. ], [
  105. AS_IF([test "x$with_iokit" = "xyes" && test "x$have_iokit" = "xyes"], [
  106. AC_DEFINE(HAVE_IOKIT, 1, [Define if we have IOKit])
  107. USB_BACKEND="IOKit"
  108. ], [
  109. AS_IF([test "x$win32" = "xtrue"], [
  110. USB_BACKEND="win32 native (setupapi)"
  111. ], [
  112. PKG_CHECK_MODULES(libusb, libusb-1.0 >= $LIBUSB_VERSION)
  113. USB_BACKEND="libusb `$PKG_CONFIG --modversion libusb-1.0`"
  114. LIBUSB_REQUIRED="libusb-1.0 >= $LIBUSB_VERSION"
  115. AC_SUBST(LIBUSB_REQUIRED)
  116. ])
  117. ])
  118. ])
  119. AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fvisibility=hidden")
  120. AC_SUBST(GLOBAL_CFLAGS)
  121. AC_SUBST(GLOBAL_LDFLAGS)
  122. case "$GLOBAL_CFLAGS" in
  123. *-fvisibility=hidden*)
  124. AC_DEFINE([HAVE_FVISIBILITY], [1], [Define if compiled with -fvisibility=hidden])
  125. esac
  126. # check for large file support
  127. AC_SYS_LARGEFILE
  128. AC_ARG_WITH([udev],
  129. AS_HELP_STRING([--with-udev],
  130. [Configure and install udev rules file for DFU/Recovery mode devices]),
  131. [],
  132. [if $($PKG_CONFIG --exists udev); then with_udev=yes; else with_udev=no; fi])
  133. AC_ARG_WITH([udevrulesdir],
  134. AS_HELP_STRING([--with-udevrulesdir=DIR],
  135. [Directory for udev rules (implies --with-udev)]),
  136. [with_udev=yes],
  137. [with_udevrulesdir=auto])
  138. AC_ARG_WITH([udevrule],
  139. AS_HELP_STRING([--with-udevrule="RULE"],
  140. [udev activation rule (implies --with-udev)]),
  141. [with_udev=yes],
  142. [with_udevrule=auto])
  143. if test "x$with_udev" = "xyes"; then
  144. if test "x$with_udevrule" = "xauto"; then
  145. for I in plugdev storage disk staff; do
  146. if grep $I /etc/group >/dev/null; then
  147. USEGROUP=$I
  148. break
  149. fi
  150. done
  151. if test "x$USEGROUP" != "x"; then
  152. if ! groups |grep $USEGROUP >/dev/null; then
  153. 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.])
  154. fi
  155. else
  156. AC_MSG_ERROR([Could not determine an appropriate user group for the udev activation rule.
  157. Please manually specify a udev activation rule using --with-udevrule=<RULE>
  158. Example: --with-udevrule="OWNER=\\"root\\", GROUP=\\"myusergroup\\", MODE=\\"0660\\""])
  159. fi
  160. with_udevrule="OWNER=\"root\", GROUP=\"$USEGROUP\", MODE=\"0660\""
  161. fi
  162. if test "x$with_udevrulesdir" = "xauto"; then
  163. udevdir=$($PKG_CONFIG --silence-errors --variable=udevdir udev)
  164. if test "x$udevdir" != "x"; then
  165. with_udevrulesdir=$udevdir"/rules.d"
  166. else
  167. with_udevrulesdir="\${prefix}/lib/udev/rules.d"
  168. AC_MSG_WARN([Could not determine default udev rules directory. Using $with_udevrulesdir.])
  169. fi
  170. fi
  171. AC_SUBST([udev_activation_rule], [$with_udevrule])
  172. AC_SUBST([udevrulesdir], [$with_udevrulesdir])
  173. fi
  174. AM_CONDITIONAL(WITH_UDEV, test "x$with_udev" = "xyes")
  175. m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
  176. AC_CONFIG_FILES([
  177. Makefile
  178. src/Makefile
  179. src/libirecovery-1.0.pc
  180. include/Makefile
  181. tools/Makefile
  182. udev/Makefile
  183. ])
  184. AC_OUTPUT
  185. echo "
  186. Configuration for $PACKAGE $VERSION:
  187. -------------------------------------------
  188. Install prefix: .........: $prefix
  189. USB backend: ............: $USB_BACKEND
  190. Now type 'make' to build $PACKAGE $VERSION,
  191. and then 'make install' for installation.
  192. "