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) |
Linus Walleij | 1aec6fd | 2011-06-08 09:08:33 +0200 | [diff] [blame] | 3 | AC_INIT([libmtp], [1.1.0], [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 |
| 18 | UDEV=/lib/udev |
| 19 | AC_ARG_WITH(udev, |
| 20 | AC_HELP_STRING([--with-udev=DIR], |
| 21 | [directory where udev is installed [default=/lib/udev]]), |
| 22 | [UDEV="${withval}"], []) |
| 23 | AC_SUBST(UDEV) |
Linus Walleij | 925cd45 | 2010-12-05 21:26:48 +0000 | [diff] [blame] | 24 | |
Denis Dupeyron | b9eed54 | 2011-01-26 22:31:16 -0700 | [diff] [blame] | 25 | # Optionally set name of udev rules file |
Linus Walleij | 2d19535 | 2011-10-22 14:34:32 +0200 | [diff] [blame] | 26 | # priority is 60, to appear before 70-acl.rules which handles |
| 27 | # access control to the devices. |
Linus Walleij | 6a81a34 | 2011-02-16 16:39:26 +0100 | [diff] [blame] | 28 | # Later rules can then use the identifiers for its processing. |
Linus Walleij | 2d19535 | 2011-10-22 14:34:32 +0200 | [diff] [blame] | 29 | UDEV_RULES=60-libmtp.rules |
Denis Dupeyron | b9eed54 | 2011-01-26 22:31:16 -0700 | [diff] [blame] | 30 | AC_ARG_WITH(udev-rules, |
| 31 | AC_HELP_STRING([--with-udev-rules=NAME], |
Linus Walleij | 2d19535 | 2011-10-22 14:34:32 +0200 | [diff] [blame] | 32 | [file name for udev rules [default=60-libmtp.rules]]), |
Denis Dupeyron | b9eed54 | 2011-01-26 22:31:16 -0700 | [diff] [blame] | 33 | [UDEV_RULES="${withval}"], []) |
| 34 | AC_SUBST(UDEV_RULES) |
Linus Walleij | 5cf12e7 | 2011-01-18 15:33:09 +0100 | [diff] [blame] | 35 | |
Denis Dupeyron | 83e79a2 | 2011-02-07 22:40:45 -0700 | [diff] [blame] | 36 | # Optionally set group for device nodes |
| 37 | UDEV_GROUP= |
| 38 | AC_ARG_WITH(udev-group, |
| 39 | AC_HELP_STRING([--with-udev-group=GROUP], |
| 40 | [file group for device nodes [default: none specified]]]), |
| 41 | [UDEV_GROUP="-g\"${withval}\""], []) |
| 42 | AC_SUBST(UDEV_GROUP) |
| 43 | |
| 44 | # Optionally set mode for device nodes |
| 45 | UDEV_MODE= |
| 46 | AC_ARG_WITH(udev-mode, |
| 47 | AC_HELP_STRING([--with-udev-mode=GROUP], |
| 48 | [file mode for device nodes [default: none specified]]]), |
| 49 | [UDEV_MODE="-m\"${withval}\""], []) |
| 50 | AC_SUBST(UDEV_MODE) |
| 51 | |
Denis Dupeyron | bc442cd | 2011-01-16 21:57:39 -0700 | [diff] [blame] | 52 | # Optionally enable and check for doxygen |
| 53 | AC_ARG_ENABLE([doxygen], |
Denis Dupeyron | 339b394 | 2011-01-20 23:17:23 -0700 | [diff] [blame] | 54 | AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=no]]), |
Denis Dupeyron | bc442cd | 2011-01-16 21:57:39 -0700 | [diff] [blame] | 55 | [ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto]) |
Denis Dupeyron | 339b394 | 2011-01-20 23:17:23 -0700 | [diff] [blame] | 56 | if test "x$ac_enable_doxygen" == "xyes"; then |
Denis Dupeyron | bc442cd | 2011-01-16 21:57:39 -0700 | [diff] [blame] | 57 | AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false) |
| 58 | if test "x$HAVE_DOXYGEN" = "xfalse" -a "x$ac_enable_doxygen" = "xyes"; then |
| 59 | AC_MSG_ERROR([*** API documentation explicitly requested but Doxygen not found]) |
| 60 | fi |
| 61 | AC_MSG_NOTICE([API documentation will be generated using Doxygen]) |
| 62 | else |
| 63 | HAVE_DOXYGEN=false |
| 64 | AC_MSG_NOTICE([API documentation will not be generated]) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 65 | fi |
Denis Dupeyron | bc442cd | 2011-01-16 21:57:39 -0700 | [diff] [blame] | 66 | AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 67 | |
| 68 | # Check for Darwin |
| 69 | AC_MSG_CHECKING([if the host operating system is Darwin]) |
| 70 | case "$host" in |
| 71 | *-darwin*) |
| 72 | AC_MSG_RESULT([yes]) |
| 73 | CFLAGS="$CFLAGS -DUSE_DARWIN" |
| 74 | OSFLAGS="-framework IOKit" |
| 75 | ;; |
| 76 | *) AC_MSG_RESULT([no]) ;; |
| 77 | esac |
| 78 | AC_SUBST(OSFLAGS) |
| 79 | |
Linus Walleij | 9e44f18 | 2010-12-07 20:33:13 +0000 | [diff] [blame] | 80 | AC_MSG_CHECKING([if the host operating system is Linux]) |
| 81 | AC_TRY_COMPILE([#ifndef __linux__ |
| 82 | #error "FAIL" |
| 83 | #endif |
| 84 | ], |
| 85 | [int test;], |
| 86 | [ AC_MSG_RESULT(yes) |
| 87 | AM_CONDITIONAL(USE_LINUX, true) |
| 88 | ], |
| 89 | [ AC_MSG_RESULT(no) |
| 90 | AM_CONDITIONAL(USE_LINUX, false) |
| 91 | ]) |
| 92 | |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 93 | # Check for mingw compiler platform |
| 94 | AC_MSG_CHECKING([For MinGW32]) |
| 95 | case "$host" in |
| 96 | *-*-mingw*) |
| 97 | AC_MSG_RESULT([yes]) |
| 98 | mingw_compiler=yes |
| 99 | ;; |
| 100 | *) AC_MSG_RESULT([no]) ;; |
| 101 | esac |
| 102 | AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"]) |
| 103 | |
Linus Walleij | 6f05002 | 2009-05-06 21:14:41 +0000 | [diff] [blame] | 104 | # Check if Microsoft LIB.EXE is available |
| 105 | if test "$mingw_compiler" = "yes"; then |
| 106 | AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no) |
| 107 | fi |
| 108 | AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 109 | |
| 110 | # Checks for libraries. |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 111 | AC_CHECK_LIB([usb], [usb_control_msg],, |
| 112 | AC_MSG_ERROR([I can't find the libusb libraries on your system. You |
| 113 | may need to set the LDFLAGS environment variable to include the |
| 114 | search path where you have libusb installed before running |
| 115 | configure (e.g. setenv LDFLAGS=-L/usr/local/lib)]), "$OSFLAGS") |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 116 | |
| 117 | # Checks for header files. |
| 118 | AC_HEADER_STDC |
| 119 | AC_HEADER_TIME |
| 120 | # zlib.h the day we need to decompress firmware |
| 121 | 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] | 122 | 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] | 123 | langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h]) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 124 | AC_CHECK_HEADER([usb.h],, |
| 125 | AC_MSG_ERROR([I can't find the libusb header file on your system. |
| 126 | You may need to set the CPPFLAGS environment variable to include |
| 127 | the search path where you have libusb installed before running |
| 128 | configure (e.g. setenv CPPFLAGS=-I/usr/local/include)])) |
| 129 | |
| 130 | # Checks for typedefs, structures, and compiler characteristics. |
| 131 | AC_C_CONST |
| 132 | AC_TYPE_OFF_T |
| 133 | AC_TYPE_SIGNAL |
| 134 | AC_TYPE_SIZE_T |
| 135 | AC_STRUCT_ST_BLKSIZE |
| 136 | |
| 137 | # Checks for library functions. |
| 138 | AC_FUNC_MALLOC |
| 139 | AC_FUNC_MEMCMP |
| 140 | AC_FUNC_STAT |
Richard Low | 8d97bad | 2010-09-12 17:31:12 +0000 | [diff] [blame] | 141 | 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] | 142 | |
| 143 | # Switches. |
Linus Walleij | 0535838 | 2007-08-06 20:46:35 +0000 | [diff] [blame] | 144 | # Enable LFS (Large File Support) |
Linus Walleij | 2f1b640 | 2009-06-15 19:49:33 +0000 | [diff] [blame] | 145 | AC_SYS_LARGEFILE |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 146 | # Stick in "-Werror" if you want to be more aggressive. |
| 147 | # (No need to use AC_SUBST on this default substituted environment variable.) |
| 148 | CFLAGS="$CFLAGS -Wall -Wmissing-prototypes" |
| 149 | |
| 150 | # Output files |
Linus Walleij | e8c5464 | 2006-03-28 09:45:00 +0000 | [diff] [blame] | 151 | |
| 152 | # Create a stdint.h-like file containing size-specific integer definitions |
| 153 | # that will always be available. The <stdint.h> file is required by the |
| 154 | # library, but we provide this anyway because the libptp2 stuff wants this |
| 155 | # file. |
Linus Walleij | 2a84ca4 | 2008-12-14 00:00:23 +0000 | [diff] [blame] | 156 | AX_NEED_STDINT_H([src/_stdint.h]) |
Linus Walleij | 6fd2f08 | 2006-03-28 07:19:22 +0000 | [diff] [blame] | 157 | |
Linus Walleij | e8c5464 | 2006-03-28 09:45:00 +0000 | [diff] [blame] | 158 | # Create a header file containing NetBSD-style byte swapping macros. |
| 159 | # This m4 macros has caused severe pain, I am considering creating a |
| 160 | # hard-coded byte swapper that will be eternally portable. |
Linus Walleij | b02a066 | 2006-04-25 08:05:09 +0000 | [diff] [blame] | 161 | AC_NEED_BYTEORDER_H(src/gphoto2-endian.h) |
Linus Walleij | 6fd2f08 | 2006-03-28 07:19:22 +0000 | [diff] [blame] | 162 | |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 163 | 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] | 164 | examples/Makefile util/Makefile libmtp.sh hotplug.sh libmtp.pc]) |
Linus Walleij | eb8c6fe | 2006-02-03 09:46:22 +0000 | [diff] [blame] | 165 | AC_OUTPUT |
Linus Walleij | 0f2e773 | 2006-08-17 20:48:32 +0000 | [diff] [blame] | 166 | chmod +x hotplug.sh |