Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 1 | # Process this file with autoconf to produce a configure script. |
| 2 | AC_PREREQ(2.52) |
Marcus Meissner | 0ccd406 | 2015-04-13 20:43:28 +0200 | [diff] [blame] | 3 | AC_INIT([libmtp], [1.1.9], [libmtp-discuss@lists.sourceforge.net]) |
Linus Walleij | d463750 | 2009-06-14 23:03:33 +0000 | [diff] [blame] | 4 | AC_CONFIG_MACRO_DIR([m4]) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 5 | AM_INIT_AUTOMAKE([foreign]) |
| 6 | AC_CONFIG_SRCDIR([src/libmtp.c]) |
Linus Walleij | 8609af3 | 2006-12-28 21:25:17 +0000 | [diff] [blame] | 7 | AM_CONFIG_HEADER(config.h) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 8 | |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 9 | # Checks for programs. |
| 10 | AC_PROG_CC |
| 11 | AC_PROG_INSTALL |
| 12 | AC_PROG_LN_S |
| 13 | AC_LIBTOOL_WIN32_DLL |
| 14 | AC_PROG_LIBTOOL |
Linus Walleij | d463750 | 2009-06-14 23:03:33 +0000 | [diff] [blame] | 15 | AM_ICONV |
| 16 | |
Denis Dupeyron | b9eed54 | 2011-01-26 22:31:16 -0700 | [diff] [blame] | 17 | # Optionally set install location of udev |
Marcus Meissner | 4b1b2c7 | 2015-03-22 18:37:30 +0100 | [diff] [blame] | 18 | UDEV=/usr/lib/udev |
Denis Dupeyron | b9eed54 | 2011-01-26 22:31:16 -0700 | [diff] [blame] | 19 | AC_ARG_WITH(udev, |
| 20 | AC_HELP_STRING([--with-udev=DIR], |
Marcus Meissner | b0c0b0d | 2015-03-29 15:16:39 +0200 | [diff] [blame] | 21 | [directory where udev is installed [default=/usr/lib/udev]]), |
Denis Dupeyron | b9eed54 | 2011-01-26 22:31:16 -0700 | [diff] [blame] | 22 | [UDEV="${withval}"], []) |
| 23 | AC_SUBST(UDEV) |
Linus Walleij | 925cd45 | 2010-12-05 21:26:48 +0000 | [diff] [blame] | 24 | |
Linus Walleij | d5ab76b | 2011-10-22 15:04:02 +0200 | [diff] [blame] | 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. |
| 30 | # |
Linus Walleij | 6a81a34 | 2011-02-16 16:39:26 +0100 | [diff] [blame] | 31 | # Later rules can then use the identifiers for its processing. |
Linus Walleij | d5ab76b | 2011-10-22 15:04:02 +0200 | [diff] [blame] | 32 | UDEV_RULES=69-libmtp.rules |
Denis Dupeyron | b9eed54 | 2011-01-26 22:31:16 -0700 | [diff] [blame] | 33 | AC_ARG_WITH(udev-rules, |
| 34 | AC_HELP_STRING([--with-udev-rules=NAME], |
Linus Walleij | d5ab76b | 2011-10-22 15:04:02 +0200 | [diff] [blame] | 35 | [file name for udev rules [default=69-libmtp.rules]]), |
Denis Dupeyron | b9eed54 | 2011-01-26 22:31:16 -0700 | [diff] [blame] | 36 | [UDEV_RULES="${withval}"], []) |
| 37 | AC_SUBST(UDEV_RULES) |
Linus Walleij | 5cf12e7 | 2011-01-18 15:33:09 +0100 | [diff] [blame] | 38 | |
Denis Dupeyron | 83e79a2 | 2011-02-07 22:40:45 -0700 | [diff] [blame] | 39 | # Optionally set group for device nodes |
| 40 | UDEV_GROUP= |
| 41 | AC_ARG_WITH(udev-group, |
| 42 | AC_HELP_STRING([--with-udev-group=GROUP], |
Linus Walleij | b708792 | 2011-12-13 00:36:23 +0100 | [diff] [blame] | 43 | [file group for device nodes [default: none specified]]), |
Denis Dupeyron | 83e79a2 | 2011-02-07 22:40:45 -0700 | [diff] [blame] | 44 | [UDEV_GROUP="-g\"${withval}\""], []) |
| 45 | AC_SUBST(UDEV_GROUP) |
| 46 | |
| 47 | # Optionally set mode for device nodes |
| 48 | UDEV_MODE= |
| 49 | AC_ARG_WITH(udev-mode, |
| 50 | AC_HELP_STRING([--with-udev-mode=GROUP], |
Linus Walleij | b708792 | 2011-12-13 00:36:23 +0100 | [diff] [blame] | 51 | [file mode for device nodes [default: none specified]]), |
Denis Dupeyron | 83e79a2 | 2011-02-07 22:40:45 -0700 | [diff] [blame] | 52 | [UDEV_MODE="-m\"${withval}\""], []) |
| 53 | AC_SUBST(UDEV_MODE) |
| 54 | |
Denis Dupeyron | bc442cd | 2011-01-16 21:57:39 -0700 | [diff] [blame] | 55 | # Optionally enable and check for doxygen |
| 56 | AC_ARG_ENABLE([doxygen], |
Jan Beich | 9ebd2f0 | 2014-08-29 20:25:09 +0400 | [diff] [blame] | 57 | AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=auto]]), |
Denis Dupeyron | bc442cd | 2011-01-16 21:57:39 -0700 | [diff] [blame] | 58 | [ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto]) |
Jan Beich | 9ebd2f0 | 2014-08-29 20:25:09 +0400 | [diff] [blame] | 59 | if test "x$ac_enable_doxygen" != "xno"; then |
Denis Dupeyron | bc442cd | 2011-01-16 21:57:39 -0700 | [diff] [blame] | 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]) |
| 63 | fi |
Jan Beich | 9ebd2f0 | 2014-08-29 20:25:09 +0400 | [diff] [blame] | 64 | if test "x$HAVE_DOXYGEN" = "xtrue"; then |
| 65 | AC_MSG_NOTICE([API documentation will be generated using Doxygen]) |
| 66 | fi |
Denis Dupeyron | bc442cd | 2011-01-16 21:57:39 -0700 | [diff] [blame] | 67 | else |
| 68 | HAVE_DOXYGEN=false |
| 69 | AC_MSG_NOTICE([API documentation will not be generated]) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 70 | fi |
Denis Dupeyron | bc442cd | 2011-01-16 21:57:39 -0700 | [diff] [blame] | 71 | AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 72 | |
| 73 | # Check for Darwin |
| 74 | AC_MSG_CHECKING([if the host operating system is Darwin]) |
| 75 | case "$host" in |
| 76 | *-darwin*) |
| 77 | AC_MSG_RESULT([yes]) |
| 78 | CFLAGS="$CFLAGS -DUSE_DARWIN" |
| 79 | OSFLAGS="-framework IOKit" |
| 80 | ;; |
| 81 | *) AC_MSG_RESULT([no]) ;; |
| 82 | esac |
| 83 | AC_SUBST(OSFLAGS) |
| 84 | |
Linus Walleij | 9e44f18 | 2010-12-07 20:33:13 +0000 | [diff] [blame] | 85 | AC_MSG_CHECKING([if the host operating system is Linux]) |
| 86 | AC_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 Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 98 | # Check for mingw compiler platform |
| 99 | AC_MSG_CHECKING([For MinGW32]) |
| 100 | case "$host" in |
| 101 | *-*-mingw*) |
| 102 | AC_MSG_RESULT([yes]) |
| 103 | mingw_compiler=yes |
| 104 | ;; |
| 105 | *) AC_MSG_RESULT([no]) ;; |
| 106 | esac |
| 107 | AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"]) |
| 108 | |
Linus Walleij | 6f05002 | 2009-05-06 21:14:41 +0000 | [diff] [blame] | 109 | # Check if Microsoft LIB.EXE is available |
| 110 | if test "$mingw_compiler" = "yes"; then |
| 111 | AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no) |
| 112 | fi |
| 113 | AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 114 | |
Linus Walleij | fbbef8b | 2011-11-17 19:19:51 +0100 | [diff] [blame] | 115 | # Check for libusb-1.0 |
Marcus Meissner | cd8aa4d | 2012-04-13 19:23:39 +0200 | [diff] [blame] | 116 | PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= 1.0.0,[ |
Linus Walleij | fbbef8b | 2011-11-17 19:19:51 +0100 | [diff] [blame] | 117 | LIBUSB_VER=`pkg-config --modversion libusb-1.0` |
Alessio Treglia | f6a57b3 | 2012-04-03 01:56:21 +0200 | [diff] [blame] | 118 | LIBUSB_REQUIRES='libusb-1.0' |
Linus Walleij | fbbef8b | 2011-11-17 19:19:51 +0100 | [diff] [blame] | 119 | AC_DEFINE(HAVE_LIBUSB1, [], [Have libusb 1.0]) |
Marcus Meissner | cd8aa4d | 2012-04-13 19:23:39 +0200 | [diff] [blame] | 120 | 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, [ |
Darran Kartaschew | 11082d3 | 2011-12-13 00:42:01 +0100 | [diff] [blame] | 128 | LIBUSB_VER=`pkg-config --modversion libusb` |
Alessio Treglia | f6a57b3 | 2012-04-03 01:56:21 +0200 | [diff] [blame] | 129 | LIBUSB_REQUIRES='libusb' |
Darran Kartaschew | 11082d3 | 2011-12-13 00:42:01 +0100 | [diff] [blame] | 130 | AC_DEFINE(HAVE_LIBUSB0, [], [Have libusb 0.x]) |
Marcus Meissner | cd8aa4d | 2012-04-13 19:23:39 +0200 | [diff] [blame] | 131 | found_libusb0_pkg=yes |
| 132 | ],[ |
Darran Kartaschew | 11082d3 | 2011-12-13 00:42:01 +0100 | [diff] [blame] | 133 | # Some systems don't use pkg-config for libusb, so double check. |
Marcus Meissner | cd8aa4d | 2012-04-13 19:23:39 +0200 | [diff] [blame] | 134 | AC_CHECK_LIB([usb], [usb_open],[ |
Darran Kartaschew | 11082d3 | 2011-12-13 00:42:01 +0100 | [diff] [blame] | 135 | LIBUSB_VER=0.1 |
| 136 | AC_DEFINE(HAVE_LIBUSB0, [], [Have libusb 0.x]) |
Marcus Meissner | cd8aa4d | 2012-04-13 19:23:39 +0200 | [diff] [blame] | 137 | found_libusb0_pkg=yes |
| 138 | ],[ |
Darran Kartaschew | 11082d3 | 2011-12-13 00:42:01 +0100 | [diff] [blame] | 139 | AC_MSG_ERROR([*** libusb not found! (missing -dev/-devel package?) ***\n*** prefer to install libusb-1 if you can! ***]) |
Marcus Meissner | cd8aa4d | 2012-04-13 19:23:39 +0200 | [diff] [blame] | 140 | ]) |
| 141 | ]) |
| 142 | ]) |
| 143 | ]) |
Linus Walleij | 8e498d4 | 2012-03-22 22:58:14 +0100 | [diff] [blame] | 144 | |
Sajid Anwar | 1badf4e | 2012-02-18 21:40:16 +0100 | [diff] [blame] | 145 | # Optionally disable MTPZ functionality. |
| 146 | AC_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. |
| 152 | if 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"]) |
| 156 | fi |
| 157 | |
| 158 | if test x"$use_mtpz" = "xyes" ; then |
| 159 | AC_DEFINE(USE_MTPZ, [], [Enable MTPZ functionality]) |
| 160 | AC_MSG_NOTICE([MTPZ functionality enabled]); |
| 161 | else |
| 162 | AC_MSG_NOTICE([MTPZ functionality disable]); |
| 163 | fi |
| 164 | |
Darran Kartaschew | 11082d3 | 2011-12-13 00:42:01 +0100 | [diff] [blame] | 165 | |
Linus Walleij | fbbef8b | 2011-11-17 19:19:51 +0100 | [diff] [blame] | 166 | AC_SUBST(LIBUSB_CFLAGS) |
| 167 | AC_SUBST(LIBUSB_LIBS) |
Alessio Treglia | f6a57b3 | 2012-04-03 01:56:21 +0200 | [diff] [blame] | 168 | AC_SUBST(LIBUSB_REQUIRES) |
Sajid Anwar | 8dca41d | 2012-08-18 20:36:13 +0200 | [diff] [blame] | 169 | AM_CONDITIONAL(MTPZ_COMPILE, test x"$use_mtpz" = "xyes") |
Linus Walleij | fbbef8b | 2011-11-17 19:19:51 +0100 | [diff] [blame] | 170 | AM_CONDITIONAL(LIBUSB1_COMPILE, test x"$found_libusb1_pkg" = "xyes") |
| 171 | AM_CONDITIONAL(LIBUSB0_COMPILE, test x"$found_libusb0_pkg" = "xyes") |
Darran Kartaschew | 11082d3 | 2011-12-13 00:42:01 +0100 | [diff] [blame] | 172 | AM_CONDITIONAL(LIBOPENUSB_COMPILE, test x"$ac_cv_lib_openusb_openusb_init" = "xyes") |
Linus Walleij | fbbef8b | 2011-11-17 19:19:51 +0100 | [diff] [blame] | 173 | AC_MSG_NOTICE([*** using libusb $LIBUSB_VER ***]) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 174 | |
| 175 | # Checks for header files. |
| 176 | AC_HEADER_STDC |
| 177 | AC_HEADER_TIME |
| 178 | # zlib.h the day we need to decompress firmware |
| 179 | AC_CHECK_HEADERS([ctype.h errno.h fcntl.h getopt.h libgen.h \ |
Linus Walleij | 56c6395 | 2008-06-08 21:55:58 +0000 | [diff] [blame] | 180 | limits.h stdio.h string.h sys/stat.h sys/time.h unistd.h \ |
Linus Walleij | 8e49914 | 2011-02-10 16:28:02 +0100 | [diff] [blame] | 181 | langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h]) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 182 | |
| 183 | # Checks for typedefs, structures, and compiler characteristics. |
| 184 | AC_C_CONST |
| 185 | AC_TYPE_OFF_T |
| 186 | AC_TYPE_SIGNAL |
| 187 | AC_TYPE_SIZE_T |
| 188 | AC_STRUCT_ST_BLKSIZE |
| 189 | |
| 190 | # Checks for library functions. |
| 191 | AC_FUNC_MALLOC |
| 192 | AC_FUNC_MEMCMP |
| 193 | AC_FUNC_STAT |
Richard Low | 8d97bad | 2010-09-12 17:31:12 +0000 | [diff] [blame] | 194 | AC_CHECK_FUNCS(basename memset select strdup strerror strndup strrchr strtoul usleep mkstemp) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 195 | |
| 196 | # Switches. |
Linus Walleij | 0535838 | 2007-08-06 20:46:35 +0000 | [diff] [blame] | 197 | # Enable LFS (Large File Support) |
Linus Walleij | 2f1b640 | 2009-06-15 19:49:33 +0000 | [diff] [blame] | 198 | AC_SYS_LARGEFILE |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 199 | # Stick in "-Werror" if you want to be more aggressive. |
| 200 | # (No need to use AC_SUBST on this default substituted environment variable.) |
Linus Walleij | 5fba333 | 2011-12-13 00:37:08 +0100 | [diff] [blame] | 201 | # Only add these additional CFLAGS if we are using GCC. Other C compilers may |
| 202 | # not support them. |
| 203 | if test x"$GCC" == "xyes" ; then |
| 204 | CFLAGS="$CFLAGS -Wall -Wmissing-prototypes" |
| 205 | fi |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 206 | |
| 207 | # Output files |
Linus Walleij | e8c5464 | 2006-03-28 09:45:00 +0000 | [diff] [blame] | 208 | |
| 209 | # Create a stdint.h-like file containing size-specific integer definitions |
| 210 | # that will always be available. The <stdint.h> file is required by the |
| 211 | # library, but we provide this anyway because the libptp2 stuff wants this |
| 212 | # file. |
Linus Walleij | 2a84ca4 | 2008-12-14 00:00:23 +0000 | [diff] [blame] | 213 | AX_NEED_STDINT_H([src/_stdint.h]) |
Linus Walleij | 6fd2f08 | 2006-03-28 07:19:22 +0000 | [diff] [blame] | 214 | |
Linus Walleij | e8c5464 | 2006-03-28 09:45:00 +0000 | [diff] [blame] | 215 | # Create a header file containing NetBSD-style byte swapping macros. |
Linus Walleij | d5ab76b | 2011-10-22 15:04:02 +0200 | [diff] [blame] | 216 | # This m4 macros has caused severe pain, I am considering creating a |
Linus Walleij | e8c5464 | 2006-03-28 09:45:00 +0000 | [diff] [blame] | 217 | # hard-coded byte swapper that will be eternally portable. |
Linus Walleij | b02a066 | 2006-04-25 08:05:09 +0000 | [diff] [blame] | 218 | AC_NEED_BYTEORDER_H(src/gphoto2-endian.h) |
Linus Walleij | 6fd2f08 | 2006-03-28 07:19:22 +0000 | [diff] [blame] | 219 | |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 220 | AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile |
Linus Walleij | 6d3c222 | 2010-11-30 23:42:32 +0000 | [diff] [blame] | 221 | examples/Makefile util/Makefile libmtp.sh hotplug.sh libmtp.pc]) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 222 | AC_OUTPUT |
Linus Walleij | 0f2e773 | 2006-08-17 20:48:32 +0000 | [diff] [blame] | 223 | chmod +x hotplug.sh |