Yavor Goulishev | 3aa430d | 2011-05-23 11:54:45 -0700 | [diff] [blame] | 1 | # Process this file with autoconf to produce a configure script. |
| 2 | AC_PREREQ(2.52) |
| 3 | AC_INIT([libmtp], [1.0.1], [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) |
| 8 | |
| 9 | # This can be overridden by the command line switch |
| 10 | if test "$program_prefix" = NONE; then |
| 11 | program_prefix=mtp- |
| 12 | program_transform_name="s,^,$program_prefix,;$program_transform_name" |
| 13 | fi |
| 14 | |
| 15 | # Checks for programs. |
| 16 | AC_PROG_CC |
| 17 | AC_PROG_INSTALL |
| 18 | AC_PROG_LN_S |
| 19 | AC_LIBTOOL_WIN32_DLL |
| 20 | AC_PROG_LIBTOOL |
| 21 | AM_ICONV |
| 22 | |
| 23 | # Check for doxygen |
| 24 | AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false) |
| 25 | AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN) |
| 26 | if test $HAVE_DOXYGEN = "false"; then |
| 27 | AC_MSG_WARN([*** doxygen not found, docs will not be built]) |
| 28 | fi |
| 29 | |
| 30 | # Check for Darwin |
| 31 | AC_MSG_CHECKING([if the host operating system is Darwin]) |
| 32 | case "$host" in |
| 33 | *-darwin*) |
| 34 | AC_MSG_RESULT([yes]) |
| 35 | CFLAGS="$CFLAGS -DUSE_DARWIN" |
| 36 | OSFLAGS="-framework IOKit" |
| 37 | ;; |
| 38 | *) AC_MSG_RESULT([no]) ;; |
| 39 | esac |
| 40 | AC_SUBST(OSFLAGS) |
| 41 | |
| 42 | # Check for mingw compiler platform |
| 43 | AC_MSG_CHECKING([For MinGW32]) |
| 44 | case "$host" in |
| 45 | *-*-mingw*) |
| 46 | AC_MSG_RESULT([yes]) |
| 47 | mingw_compiler=yes |
| 48 | ;; |
| 49 | *) AC_MSG_RESULT([no]) ;; |
| 50 | esac |
| 51 | AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"]) |
| 52 | |
| 53 | # Check if Microsoft LIB.EXE is available |
| 54 | if test "$mingw_compiler" = "yes"; then |
| 55 | AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no) |
| 56 | fi |
| 57 | AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes) |
| 58 | |
| 59 | # Checks for libraries. |
| 60 | AC_CHECK_LIB([usb], [usb_control_msg],, |
| 61 | AC_MSG_ERROR([I can't find the libusb libraries on your system. You |
| 62 | may need to set the LDFLAGS environment variable to include the |
| 63 | search path where you have libusb installed before running |
| 64 | configure (e.g. setenv LDFLAGS=-L/usr/local/lib)]), "$OSFLAGS") |
| 65 | |
| 66 | # Checks for header files. |
| 67 | AC_HEADER_STDC |
| 68 | AC_HEADER_TIME |
| 69 | # zlib.h the day we need to decompress firmware |
| 70 | AC_CHECK_HEADERS([ctype.h errno.h fcntl.h getopt.h libgen.h \ |
| 71 | limits.h stdio.h string.h sys/stat.h sys/time.h unistd.h \ |
| 72 | iconv.h langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h]) |
| 73 | AC_CHECK_HEADER([usb.h],, |
| 74 | AC_MSG_ERROR([I can't find the libusb header file on your system. |
| 75 | You may need to set the CPPFLAGS environment variable to include |
| 76 | the search path where you have libusb installed before running |
| 77 | configure (e.g. setenv CPPFLAGS=-I/usr/local/include)])) |
| 78 | |
| 79 | # Checks for typedefs, structures, and compiler characteristics. |
| 80 | AC_C_CONST |
| 81 | AC_TYPE_OFF_T |
| 82 | AC_TYPE_SIGNAL |
| 83 | AC_TYPE_SIZE_T |
| 84 | AC_STRUCT_ST_BLKSIZE |
| 85 | |
| 86 | # Checks for library functions. |
| 87 | AC_FUNC_MALLOC |
| 88 | AC_FUNC_MEMCMP |
| 89 | AC_FUNC_STAT |
| 90 | AC_CHECK_FUNCS(basename memset select strdup strerror strrchr strtoul usleep mkstemp) |
| 91 | |
| 92 | # Switches. |
| 93 | # Enable LFS (Large File Support) |
| 94 | AC_SYS_LARGEFILE |
| 95 | # Stick in "-Werror" if you want to be more aggressive. |
| 96 | # (No need to use AC_SUBST on this default substituted environment variable.) |
| 97 | CFLAGS="$CFLAGS -Wall -Wmissing-prototypes" |
| 98 | |
| 99 | # Output files |
| 100 | |
| 101 | # Create a stdint.h-like file containing size-specific integer definitions |
| 102 | # that will always be available. The <stdint.h> file is required by the |
| 103 | # library, but we provide this anyway because the libptp2 stuff wants this |
| 104 | # file. |
| 105 | AX_NEED_STDINT_H([src/_stdint.h]) |
| 106 | |
| 107 | # Create a header file containing NetBSD-style byte swapping macros. |
| 108 | # This m4 macros has caused severe pain, I am considering creating a |
| 109 | # hard-coded byte swapper that will be eternally portable. |
| 110 | AC_NEED_BYTEORDER_H(src/gphoto2-endian.h) |
| 111 | |
| 112 | AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile |
| 113 | examples/Makefile libmtp.sh hotplug.sh libmtp.pc]) |
| 114 | AC_OUTPUT |
| 115 | chmod +x hotplug.sh |