blob: 3dcb0f00bc9a818772878438c935214db227ed47 [file] [log] [blame]
Linus Walleijeb8c6fe2006-02-03 09:46:22 +00001# Process this file with autoconf to produce a configure script.
2AC_PREREQ(2.52)
Marcus Meissner53c70572017-04-02 21:26:27 +02003AC_INIT([libmtp], [1.1.13], [libmtp-discuss@lists.sourceforge.net])
Linus Walleijd4637502009-06-14 23:03:33 +00004AC_CONFIG_MACRO_DIR([m4])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +00005AM_INIT_AUTOMAKE([foreign])
6AC_CONFIG_SRCDIR([src/libmtp.c])
Linus Walleij8609af32006-12-28 21:25:17 +00007AM_CONFIG_HEADER(config.h)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +00008
Linus Walleijeb8c6fe2006-02-03 09:46:22 +00009# Checks for programs.
10AC_PROG_CC
11AC_PROG_INSTALL
12AC_PROG_LN_S
13AC_LIBTOOL_WIN32_DLL
14AC_PROG_LIBTOOL
Linus Walleijd4637502009-06-14 23:03:33 +000015AM_ICONV
16
Denis Dupeyronb9eed542011-01-26 22:31:16 -070017# Optionally set install location of udev
Marcus Meissner4b1b2c72015-03-22 18:37:30 +010018UDEV=/usr/lib/udev
Denis Dupeyronb9eed542011-01-26 22:31:16 -070019AC_ARG_WITH(udev,
20 AC_HELP_STRING([--with-udev=DIR],
Marcus Meissnerb0c0b0d2015-03-29 15:16:39 +020021 [directory where udev is installed [default=/usr/lib/udev]]),
Denis Dupeyronb9eed542011-01-26 22:31:16 -070022 [UDEV="${withval}"], [])
23AC_SUBST(UDEV)
Linus Walleij925cd452010-12-05 21:26:48 +000024
Linus Walleijd5ab76b2011-10-22 15:04:02 +020025# 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.
30#
Linus Walleij6a81a342011-02-16 16:39:26 +010031# Later rules can then use the identifiers for its processing.
Linus Walleijd5ab76b2011-10-22 15:04:02 +020032UDEV_RULES=69-libmtp.rules
Denis Dupeyronb9eed542011-01-26 22:31:16 -070033AC_ARG_WITH(udev-rules,
34 AC_HELP_STRING([--with-udev-rules=NAME],
Linus Walleijd5ab76b2011-10-22 15:04:02 +020035 [file name for udev rules [default=69-libmtp.rules]]),
Denis Dupeyronb9eed542011-01-26 22:31:16 -070036 [UDEV_RULES="${withval}"], [])
37AC_SUBST(UDEV_RULES)
Linus Walleij5cf12e72011-01-18 15:33:09 +010038
Denis Dupeyron83e79a22011-02-07 22:40:45 -070039# Optionally set group for device nodes
40UDEV_GROUP=
41AC_ARG_WITH(udev-group,
42 AC_HELP_STRING([--with-udev-group=GROUP],
Linus Walleijb7087922011-12-13 00:36:23 +010043 [file group for device nodes [default: none specified]]),
Denis Dupeyron83e79a22011-02-07 22:40:45 -070044 [UDEV_GROUP="-g\"${withval}\""], [])
45AC_SUBST(UDEV_GROUP)
46
47# Optionally set mode for device nodes
48UDEV_MODE=
49AC_ARG_WITH(udev-mode,
50 AC_HELP_STRING([--with-udev-mode=GROUP],
Linus Walleijb7087922011-12-13 00:36:23 +010051 [file mode for device nodes [default: none specified]]),
Denis Dupeyron83e79a22011-02-07 22:40:45 -070052 [UDEV_MODE="-m\"${withval}\""], [])
53AC_SUBST(UDEV_MODE)
54
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070055# Optionally enable and check for doxygen
56AC_ARG_ENABLE([doxygen],
Jan Beich9ebd2f02014-08-29 20:25:09 +040057 AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=auto]]),
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070058 [ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto])
Jan Beich9ebd2f02014-08-29 20:25:09 +040059if test "x$ac_enable_doxygen" != "xno"; then
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070060 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])
63 fi
Jan Beich9ebd2f02014-08-29 20:25:09 +040064 if test "x$HAVE_DOXYGEN" = "xtrue"; then
65 AC_MSG_NOTICE([API documentation will be generated using Doxygen])
66 fi
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070067else
68 HAVE_DOXYGEN=false
69 AC_MSG_NOTICE([API documentation will not be generated])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000070fi
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070071AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000072
73# Check for Darwin
74AC_MSG_CHECKING([if the host operating system is Darwin])
75case "$host" in
76 *-darwin*)
77 AC_MSG_RESULT([yes])
78 CFLAGS="$CFLAGS -DUSE_DARWIN"
79 OSFLAGS="-framework IOKit"
80 ;;
81 *) AC_MSG_RESULT([no]) ;;
82esac
83AC_SUBST(OSFLAGS)
84
Linus Walleij9e44f182010-12-07 20:33:13 +000085AC_MSG_CHECKING([if the host operating system is Linux])
86AC_TRY_COMPILE([#ifndef __linux__
87 #error "FAIL"
88 #endif
89 ],
90 [int test;],
91 [ AC_MSG_RESULT(yes)
92 AM_CONDITIONAL(USE_LINUX, true)
93 ],
94 [ AC_MSG_RESULT(no)
95 AM_CONDITIONAL(USE_LINUX, false)
96 ])
97
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000098# Check for mingw compiler platform
99AC_MSG_CHECKING([For MinGW32])
100case "$host" in
101 *-*-mingw*)
102 AC_MSG_RESULT([yes])
103 mingw_compiler=yes
104 ;;
105 *) AC_MSG_RESULT([no]) ;;
106esac
107AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"])
108
Linus Walleij6f050022009-05-06 21:14:41 +0000109# Check if Microsoft LIB.EXE is available
110if test "$mingw_compiler" = "yes"; then
111 AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no)
112fi
113AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000114
Linus Walleijfbbef8b2011-11-17 19:19:51 +0100115# Check for libusb-1.0
Marcus Meissnercd8aa4d2012-04-13 19:23:39 +0200116PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= 1.0.0,[
Marcus Meissner6fea1d92017-05-09 08:35:11 +0200117 LIBUSB_VER=`$PKG_CONFIG --modversion libusb-1.0`
Alessio Tregliaf6a57b32012-04-03 01:56:21 +0200118 LIBUSB_REQUIRES='libusb-1.0'
Linus Walleijfbbef8b2011-11-17 19:19:51 +0100119 AC_DEFINE(HAVE_LIBUSB1, [], [Have libusb 1.0])
Marcus Meissnercd8aa4d2012-04-13 19:23:39 +0200120 found_libusb1_pkg=yes
121],[
122 # Check for libopenusb second
123 AC_CHECK_LIB([openusb], [openusb_init],[
124 AC_DEFINE(HAVE_OPENUSB, [], [Have libopenusb 1.0])
125 LIBUSB_VER=1.0
126 ],[
127 PKG_CHECK_MODULES(LIBUSB, libusb >= 0.1.8, [
Marcus Meissner6fea1d92017-05-09 08:35:11 +0200128 LIBUSB_VER=`$PKG_CONFIG --modversion libusb`
Alessio Tregliaf6a57b32012-04-03 01:56:21 +0200129 LIBUSB_REQUIRES='libusb'
Darran Kartaschew11082d32011-12-13 00:42:01 +0100130 AC_DEFINE(HAVE_LIBUSB0, [], [Have libusb 0.x])
Marcus Meissnercd8aa4d2012-04-13 19:23:39 +0200131 found_libusb0_pkg=yes
132 ],[
Darran Kartaschew11082d32011-12-13 00:42:01 +0100133 # Some systems don't use pkg-config for libusb, so double check.
Marcus Meissnercd8aa4d2012-04-13 19:23:39 +0200134 AC_CHECK_LIB([usb], [usb_open],[
Darran Kartaschew11082d32011-12-13 00:42:01 +0100135 LIBUSB_VER=0.1
136 AC_DEFINE(HAVE_LIBUSB0, [], [Have libusb 0.x])
Marcus Meissnercd8aa4d2012-04-13 19:23:39 +0200137 found_libusb0_pkg=yes
138 ],[
Darran Kartaschew11082d32011-12-13 00:42:01 +0100139 AC_MSG_ERROR([*** libusb not found! (missing -dev/-devel package?) ***\n*** prefer to install libusb-1 if you can! ***])
Marcus Meissnercd8aa4d2012-04-13 19:23:39 +0200140 ])
141 ])
142 ])
143])
Linus Walleij8e498d42012-03-22 22:58:14 +0100144
Sajid Anwar1badf4e2012-02-18 21:40:16 +0100145# Optionally disable MTPZ functionality.
146AC_ARG_ENABLE([mtpz],
147 AC_HELP_STRING([--disable-mtpz], [Disable functionality to connect to MTPZ devices (e.g. Zune)]),
148 [use_mtpz=$enableval],
149 [use_mtpz="yes"])
150
151# Include MTPZ if not disabled.
152if test x"$use_mtpz" = "xyes" ; then
153 # Check for libgcrypt.
154 AC_MSG_CHECKING([for libgcrypt])
155 AC_CHECK_LIB([gcrypt], [gcry_check_version], , [AC_MSG_NOTICE([*** libgcrypt not found - disabling MTPZ support ***]) ; use_mtpz="no"])
156fi
157
158if test x"$use_mtpz" = "xyes" ; then
159 AC_DEFINE(USE_MTPZ, [], [Enable MTPZ functionality])
160 AC_MSG_NOTICE([MTPZ functionality enabled]);
161else
162 AC_MSG_NOTICE([MTPZ functionality disable]);
163fi
164
Darran Kartaschew11082d32011-12-13 00:42:01 +0100165
Linus Walleijfbbef8b2011-11-17 19:19:51 +0100166AC_SUBST(LIBUSB_CFLAGS)
167AC_SUBST(LIBUSB_LIBS)
Alessio Tregliaf6a57b32012-04-03 01:56:21 +0200168AC_SUBST(LIBUSB_REQUIRES)
Sajid Anwar8dca41d2012-08-18 20:36:13 +0200169AM_CONDITIONAL(MTPZ_COMPILE, test x"$use_mtpz" = "xyes")
Linus Walleijfbbef8b2011-11-17 19:19:51 +0100170AM_CONDITIONAL(LIBUSB1_COMPILE, test x"$found_libusb1_pkg" = "xyes")
171AM_CONDITIONAL(LIBUSB0_COMPILE, test x"$found_libusb0_pkg" = "xyes")
Darran Kartaschew11082d32011-12-13 00:42:01 +0100172AM_CONDITIONAL(LIBOPENUSB_COMPILE, test x"$ac_cv_lib_openusb_openusb_init" = "xyes")
Linus Walleijfbbef8b2011-11-17 19:19:51 +0100173AC_MSG_NOTICE([*** using libusb $LIBUSB_VER ***])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000174
175# Checks for header files.
176AC_HEADER_STDC
177AC_HEADER_TIME
178# zlib.h the day we need to decompress firmware
179AC_CHECK_HEADERS([ctype.h errno.h fcntl.h getopt.h libgen.h \
Linus Walleij56c63952008-06-08 21:55:58 +0000180 limits.h stdio.h string.h sys/stat.h sys/time.h unistd.h \
Linus Walleij8e499142011-02-10 16:28:02 +0100181 langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000182
183# Checks for typedefs, structures, and compiler characteristics.
184AC_C_CONST
185AC_TYPE_OFF_T
186AC_TYPE_SIGNAL
187AC_TYPE_SIZE_T
188AC_STRUCT_ST_BLKSIZE
189
190# Checks for library functions.
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000191AC_FUNC_MEMCMP
192AC_FUNC_STAT
Richard Low8d97bad2010-09-12 17:31:12 +0000193AC_CHECK_FUNCS(basename memset select strdup strerror strndup strrchr strtoul usleep mkstemp)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000194
195# Switches.
Linus Walleij05358382007-08-06 20:46:35 +0000196# Enable LFS (Large File Support)
Linus Walleij2f1b6402009-06-15 19:49:33 +0000197AC_SYS_LARGEFILE
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000198# Stick in "-Werror" if you want to be more aggressive.
199# (No need to use AC_SUBST on this default substituted environment variable.)
Linus Walleij5fba3332011-12-13 00:37:08 +0100200# Only add these additional CFLAGS if we are using GCC. Other C compilers may
201# not support them.
202if test x"$GCC" == "xyes" ; then
203 CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
204fi
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000205
206# Output files
Linus Walleije8c54642006-03-28 09:45:00 +0000207
208# Create a stdint.h-like file containing size-specific integer definitions
209# that will always be available. The <stdint.h> file is required by the
210# library, but we provide this anyway because the libptp2 stuff wants this
211# file.
Linus Walleij2a84ca42008-12-14 00:00:23 +0000212AX_NEED_STDINT_H([src/_stdint.h])
Linus Walleij6fd2f082006-03-28 07:19:22 +0000213
Linus Walleije8c54642006-03-28 09:45:00 +0000214# Create a header file containing NetBSD-style byte swapping macros.
Linus Walleijd5ab76b2011-10-22 15:04:02 +0200215# This m4 macros has caused severe pain, I am considering creating a
Linus Walleije8c54642006-03-28 09:45:00 +0000216# hard-coded byte swapper that will be eternally portable.
Linus Walleijb02a0662006-04-25 08:05:09 +0000217AC_NEED_BYTEORDER_H(src/gphoto2-endian.h)
Linus Walleij6fd2f082006-03-28 07:19:22 +0000218
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000219AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile
Linus Walleij6d3c2222010-11-30 23:42:32 +0000220 examples/Makefile util/Makefile libmtp.sh hotplug.sh libmtp.pc])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000221AC_OUTPUT
Linus Walleij0f2e7732006-08-17 20:48:32 +0000222chmod +x hotplug.sh