summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac230
1 files changed, 230 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..94bb793
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,230 @@
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.68)
5AC_INIT([libirecovery], [m4_esyscmd(./git-version-gen $RELEASE_VERSION)], [https://github.com/libimobiledevice/libirecovery/issues], [], [https://libimobiledevice.org])
6AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip check-news])
7m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
8AC_CONFIG_SRCDIR([src/])
9AC_CONFIG_HEADERS([config.h])
10AC_CONFIG_MACRO_DIR([m4])
11
12dnl libtool versioning
13# +1 : 0 : +1 == adds new functions to the interface
14# +1 : 0 : 0 == changes or removes functions (changes include both
15# changes to the signature and the semantic)
16# ? :+1 : ? == just internal changes
17# CURRENT : REVISION : AGE
18LIBIRECOVERY_SO_VERSION=5:0:0
19
20dnl Minimum package versions
21LIBUSB_VERSION=1.0.3
22LIMD_GLUE_VERSION=1.2.0
23
24AC_SUBST(LIBIRECOVERY_SO_VERSION)
25AC_SUBST(LIMD_GLUE_VERSION)
26
27# Checks for programs.
28AC_PROG_CC
29#AC_PROG_CXX
30AM_PROG_CC_C_O
31LT_INIT
32
33# Checks for libraries.
34PKG_CHECK_MODULES(limd_glue, libimobiledevice-glue-1.0 >= $LIMD_GLUE_VERSION)
35
36# Checks for header files.
37AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
38
39# Checks for typedefs, structures, and compiler characteristics.
40AC_C_CONST
41AC_TYPE_SIZE_T
42AC_TYPE_SSIZE_T
43AC_TYPE_UINT16_T
44AC_TYPE_UINT32_T
45AC_TYPE_UINT8_T
46
47# Checks for library functions.
48AC_CHECK_FUNCS([strdup strerror strcasecmp strndup malloc realloc calloc])
49
50# Check additional platform flags
51AC_MSG_CHECKING([for platform-specific build settings])
52case ${host_os} in
53 darwin*)
54 AC_MSG_RESULT([${host_os}])
55 AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h, [
56 AC_CHECK_HEADER(IOKit/usb/IOUSBLib.h, [
57 GLOBAL_LDFLAGS+=" -framework IOKit -framework CoreFoundation"
58 have_iokit=yes
59 ], [])
60 ], [])
61 ;;
62 mingw32*)
63 AC_MSG_RESULT([${host_os}])
64 GLOBAL_LDFLAGS+=" -static-libgcc -lkernel32 -lsetupapi"
65 win32=true
66 ;;
67 cygwin*)
68 AC_MSG_RESULT([${host_os}])
69 CC=gcc-3
70 CFLAGS+=" -mno-cygwin"
71 GLOBAL_LDFLAGS+=" -static-libgcc -lkernel32 -lsetupapi"
72 win32=true
73 ;;
74 *)
75 AC_MSG_RESULT([${host_os}])
76 ;;
77esac
78AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
79
80# Check if the C compiler supports __attribute__((constructor))
81AC_CACHE_CHECK([wether the C compiler supports constructor/destructor attributes],
82 ac_cv_attribute_constructor, [
83 ac_cv_attribute_constructor=no
84 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
85 [[
86 static void __attribute__((constructor)) test_constructor(void) {
87 }
88 static void __attribute__((destructor)) test_destructor(void) {
89 }
90 ]], [])],
91 [ac_cv_attribute_constructor=yes]
92 )]
93)
94if test "$ac_cv_attribute_constructor" = "yes"; then
95 AC_DEFINE(HAVE_ATTRIBUTE_CONSTRUCTOR, 1, [Define if the C compiler supports constructor/destructor attributes])
96fi
97
98AC_ARG_WITH([tools],
99 [AS_HELP_STRING([--with-tools], [Build irecovery tools. (requires readline) [default=yes]])],
100 [],
101 [with_tools=yes])
102
103AS_IF([test "x$with_tools" = "xyes"], [
104 AC_DEFINE(BUILD_TOOLS, 1, [Define if we are building irecovery tools])
105 AC_CHECK_HEADERS([readline/readline.h], [],
106 [AC_MSG_ERROR([Please install readline development headers])]
107 )]
108)
109AM_CONDITIONAL(BUILD_TOOLS, test "x$with_tools" = "xyes")
110
111AC_ARG_WITH([dummy],
112 [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.])],
113 [],
114 [with_dummy=no])
115
116AS_IF([test "x$have_iokit" = "xyes"], [
117 AC_ARG_WITH([iokit],
118 [AS_HELP_STRING([--with-iokit], [Use IOKit instead of libusb on OS X [default=yes]])],
119 [],
120 [with_iokit=yes])
121 ]
122)
123
124AS_IF([test "x$with_dummy" = "xyes"], [
125 AC_DEFINE(USE_DUMMY, 1, [Define if we are using dummy USB driver])
126 USB_BACKEND="dummy"
127], [
128 AS_IF([test "x$with_iokit" = "xyes" && test "x$have_iokit" = "xyes"], [
129 AC_DEFINE(HAVE_IOKIT, 1, [Define if we have IOKit])
130 USB_BACKEND="IOKit"
131 ], [
132 AS_IF([test "x$win32" = "xtrue"], [
133 USB_BACKEND="win32 native (setupapi)"
134 ], [
135 PKG_CHECK_MODULES(libusb, libusb-1.0 >= $LIBUSB_VERSION)
136 USB_BACKEND="libusb `$PKG_CONFIG --modversion libusb-1.0`"
137 LIBUSB_REQUIRED="libusb-1.0 >= $LIBUSB_VERSION"
138 AC_SUBST(LIBUSB_REQUIRED)
139 ])
140 ])
141])
142
143AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fvisibility=hidden")
144
145if test "x$enable_static" = "xyes" -a "x$enable_shared" = "xno"; then
146 GLOBAL_CFLAGS+=" -DIRECV_STATIC"
147fi
148
149AC_SUBST(GLOBAL_CFLAGS)
150AC_SUBST(GLOBAL_LDFLAGS)
151
152# check for large file support
153AC_SYS_LARGEFILE
154
155AC_ARG_WITH([udev],
156 AS_HELP_STRING([--with-udev],
157 [Configure and install udev rules file for DFU/Recovery mode devices]),
158 [],
159 [if $($PKG_CONFIG --exists udev); then with_udev=yes; else with_udev=no; fi])
160
161AC_ARG_WITH([udevrulesdir],
162 AS_HELP_STRING([--with-udevrulesdir=DIR],
163 [Directory for udev rules (implies --with-udev)]),
164 [with_udev=yes],
165 [with_udevrulesdir=auto])
166
167AC_ARG_WITH([udevrule],
168 AS_HELP_STRING([--with-udevrule="RULE"],
169 [udev activation rule (implies --with-udev)]),
170 [with_udev=yes],
171 [with_udevrule=auto])
172
173if test "x$with_udev" = "xyes"; then
174 if test "x$with_udevrule" = "xauto"; then
175 for I in plugdev storage disk staff; do
176 if grep $I /etc/group >/dev/null; then
177 USEGROUP=$I
178 break
179 fi
180 done
181 if test "x$USEGROUP" != "x"; then
182 if ! groups |grep $USEGROUP >/dev/null; then
183 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.])
184 fi
185 else
186 AC_MSG_ERROR([Could not determine an appropriate user group for the udev activation rule.
187 Please manually specify a udev activation rule using --with-udevrule=<RULE>
188 Example: --with-udevrule="OWNER=\\"root\\", GROUP=\\"myusergroup\\", MODE=\\"0660\\""])
189 fi
190 with_udevrule="OWNER=\"root\", GROUP=\"$USEGROUP\", MODE=\"0660\""
191 fi
192
193 if test "x$with_udevrulesdir" = "xauto"; then
194 udevdir=$($PKG_CONFIG --silence-errors --variable=udevdir udev)
195 if test "x$udevdir" != "x"; then
196 with_udevrulesdir=$udevdir"/rules.d"
197 else
198 with_udevrulesdir="\${prefix}/lib/udev/rules.d"
199 AC_MSG_WARN([Could not determine default udev rules directory. Using $with_udevrulesdir.])
200 fi
201 fi
202
203 AC_SUBST([udev_activation_rule], [$with_udevrule])
204 AC_SUBST([udevrulesdir], [$with_udevrulesdir])
205fi
206AM_CONDITIONAL(WITH_UDEV, test "x$with_udev" = "xyes")
207
208m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
209
210AC_CONFIG_FILES([
211Makefile
212src/Makefile
213src/libirecovery-1.0.pc
214udev/39-libirecovery.rules
215include/Makefile
216tools/Makefile
217udev/Makefile
218])
219AC_OUTPUT
220
221echo "
222Configuration for $PACKAGE $VERSION:
223-------------------------------------------
224
225 Install prefix: .........: $prefix
226 USB backend: ............: $USB_BACKEND
227
228 Now type 'make' to build $PACKAGE $VERSION,
229 and then 'make install' for installation.
230"