1
# Process this file with autoconf to produce a configure script.
3
AC_INIT([libmtp], [1.1.3], [libmtp-discuss@lists.sourceforge.net])
4
AC_CONFIG_MACRO_DIR([m4])
5
AM_INIT_AUTOMAKE([foreign])
6
AC_CONFIG_SRCDIR([src/libmtp.c])
7
AM_CONFIG_HEADER(config.h)
17
# Optionally set install location of udev
20
AC_HELP_STRING([--with-udev=DIR],
21
[directory where udev is installed [default=/lib/udev]]),
22
[UDEV="${withval}"], [])
25
# Optionally set name of udev rules file, default
26
# priority is 69, to appear before 70-acl.rules which handles
27
# access control to the devices. We try to let all other userspace
28
# libusb-based device handlers take precedence since libmtp may
29
# attempt to autoprobe the devices.
31
# Later rules can then use the identifiers for its processing.
32
UDEV_RULES=69-libmtp.rules
33
AC_ARG_WITH(udev-rules,
34
AC_HELP_STRING([--with-udev-rules=NAME],
35
[file name for udev rules [default=69-libmtp.rules]]),
36
[UDEV_RULES="${withval}"], [])
39
# Optionally set group for device nodes
41
AC_ARG_WITH(udev-group,
42
AC_HELP_STRING([--with-udev-group=GROUP],
43
[file group for device nodes [default: none specified]]),
44
[UDEV_GROUP="-g\"${withval}\""], [])
47
# Optionally set mode for device nodes
49
AC_ARG_WITH(udev-mode,
50
AC_HELP_STRING([--with-udev-mode=GROUP],
51
[file mode for device nodes [default: none specified]]),
52
[UDEV_MODE="-m\"${withval}\""], [])
55
# Optionally enable and check for doxygen
56
AC_ARG_ENABLE([doxygen],
57
AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=no]]),
58
[ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto])
59
if test "x$ac_enable_doxygen" == "xyes"; then
60
AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
61
if test "x$HAVE_DOXYGEN" = "xfalse" -a "x$ac_enable_doxygen" = "xyes"; then
62
AC_MSG_ERROR([*** API documentation explicitly requested but Doxygen not found])
64
AC_MSG_NOTICE([API documentation will be generated using Doxygen])
67
AC_MSG_NOTICE([API documentation will not be generated])
69
AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
72
AC_MSG_CHECKING([if the host operating system is Darwin])
76
CFLAGS="$CFLAGS -DUSE_DARWIN"
77
OSFLAGS="-framework IOKit"
79
*) AC_MSG_RESULT([no]) ;;
83
AC_MSG_CHECKING([if the host operating system is Linux])
84
AC_TRY_COMPILE([#ifndef __linux__
90
AM_CONDITIONAL(USE_LINUX, true)
93
AM_CONDITIONAL(USE_LINUX, false)
96
# Check for mingw compiler platform
97
AC_MSG_CHECKING([For MinGW32])
103
*) AC_MSG_RESULT([no]) ;;
105
AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"])
107
# Check if Microsoft LIB.EXE is available
108
if test "$mingw_compiler" = "yes"; then
109
AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no)
111
AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes)
113
# Check for libusb-1.0
114
PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= 1.0.0, found_libusb1_pkg=yes, found_libusb1_pkg=no)
115
if test x"$found_libusb1_pkg" = "xyes" ; then
116
LIBUSB_VER=`pkg-config --modversion libusb-1.0`
117
LIBUSB_REQUIRES='libusb-1.0'
118
AC_DEFINE(HAVE_LIBUSB1, [], [Have libusb 1.0])
121
# Check for libusb 0.x
122
if test x"$found_libusb1_pkg" = "xno" ; then
123
if test x"$ac_cv_lib_openusb_openusb_init" = "xno" ; then
124
PKG_CHECK_MODULES(LIBUSB, libusb >= 0.1.8, found_libusb0_pkg=yes, found_libusb0_pkg=no)
125
if test x"$found_libusb0_pkg" = "xyes" ; then
126
LIBUSB_VER=`pkg-config --modversion libusb`
127
LIBUSB_REQUIRES='libusb'
128
AC_DEFINE(HAVE_LIBUSB0, [], [Have libusb 0.x])
130
# Some systems don't use pkg-config for libusb, so double check.
131
AC_CHECK_LIB([usb], [usb_open], found_libusb0_pkg=yes, found_libusb0_pkg=no)
132
if test x"$ac_cv_lib_usb_usb_open" = "xyes" ; then
134
AC_DEFINE(HAVE_LIBUSB0, [], [Have libusb 0.x])
135
found_libusb0_pkg=xyes
137
if test x"$found_libusb0_pkg" = "xno" ; then
138
AC_MSG_ERROR([*** libusb not found! (missing -dev/-devel package?) ***\n*** prefer to install libusb-1 if you can! ***])
144
# Check for libopenusb
145
if test x"$found_libusb1_pkg" = "xno" ; then
146
AC_CHECK_LIB([openusb], [openusb_init])
147
if test x"$found_libusb1_pkg" = "xno" ; then
148
if test x"$ac_cv_lib_openusb_openusb_init" = "xyes" ; then
149
AC_DEFINE(HAVE_OPENUSB, [], [Have libopenusb 1.0])
155
# Optionally disable MTPZ functionality.
156
AC_ARG_ENABLE([mtpz],
157
AC_HELP_STRING([--disable-mtpz], [Disable functionality to connect to MTPZ devices (e.g. Zune)]),
158
[use_mtpz=$enableval],
161
# Include MTPZ if not disabled.
162
if test x"$use_mtpz" = "xyes" ; then
163
# Check for libgcrypt.
164
AC_MSG_CHECKING([for libgcrypt])
165
AC_CHECK_LIB([gcrypt], [gcry_check_version], , [AC_MSG_NOTICE([*** libgcrypt not found - disabling MTPZ support ***]) ; use_mtpz="no"])
168
if test x"$use_mtpz" = "xyes" ; then
169
AC_DEFINE(USE_MTPZ, [], [Enable MTPZ functionality])
170
AC_MSG_NOTICE([MTPZ functionality enabled]);
172
AC_MSG_NOTICE([MTPZ functionality disable]);
176
AC_SUBST(LIBUSB_CFLAGS)
177
AC_SUBST(LIBUSB_LIBS)
178
AC_SUBST(LIBUSB_REQUIRES)
179
AM_CONDITIONAL(LIBUSB1_COMPILE, test x"$found_libusb1_pkg" = "xyes")
180
AM_CONDITIONAL(LIBUSB0_COMPILE, test x"$found_libusb0_pkg" = "xyes")
181
AM_CONDITIONAL(LIBOPENUSB_COMPILE, test x"$ac_cv_lib_openusb_openusb_init" = "xyes")
182
AC_MSG_NOTICE([*** using libusb $LIBUSB_VER ***])
184
# Checks for header files.
187
# zlib.h the day we need to decompress firmware
188
AC_CHECK_HEADERS([ctype.h errno.h fcntl.h getopt.h libgen.h \
189
limits.h stdio.h string.h sys/stat.h sys/time.h unistd.h \
190
langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h])
192
# Checks for typedefs, structures, and compiler characteristics.
199
# Checks for library functions.
203
AC_CHECK_FUNCS(basename memset select strdup strerror strndup strrchr strtoul usleep mkstemp)
206
# Enable LFS (Large File Support)
208
# Stick in "-Werror" if you want to be more aggressive.
209
# (No need to use AC_SUBST on this default substituted environment variable.)
210
# Only add these additional CFLAGS if we are using GCC. Other C compilers may
212
if test x"$GCC" == "xyes" ; then
213
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
218
# Create a stdint.h-like file containing size-specific integer definitions
219
# that will always be available. The <stdint.h> file is required by the
220
# library, but we provide this anyway because the libptp2 stuff wants this
222
AX_NEED_STDINT_H([src/_stdint.h])
224
# Create a header file containing NetBSD-style byte swapping macros.
225
# This m4 macros has caused severe pain, I am considering creating a
226
# hard-coded byte swapper that will be eternally portable.
227
AC_NEED_BYTEORDER_H(src/gphoto2-endian.h)
229
AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile
230
examples/Makefile util/Makefile libmtp.sh hotplug.sh libmtp.pc])