blob: 5a541e309a5be79cfd20b2bee6e17a645101dc1f [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)
Linus Walleij677e6652011-01-08 23:11:59 +00003AC_INIT([libmtp], [1.0.4], [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
Linus Walleij925cd452010-12-05 21:26:48 +000017# For this library the default libexecdir is the udev
18# dir, because it's only used for the udev probe program
19# nothing else makes sense for this.
Linus Walleij1130ab52011-01-18 13:14:15 +010020libexecdir=/lib/udev
Linus Walleij925cd452010-12-05 21:26:48 +000021
Linus Walleij5cf12e72011-01-18 15:33:09 +010022# Optionally set udev rules file name
23UDEV_RULES_FILE=libmtp.rules
24AC_ARG_WITH(udev-rules-file,
25 AC_HELP_STRING([--with-udev-rules-file=NAME],
26 [udev rules file name [default=libmtp.rules]]), [UDEV_RULES_FILE="$withval"], [])
27AC_SUBST(UDEV_RULES_FILE)
28
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070029# Optionally enable and check for doxygen
30AC_ARG_ENABLE([doxygen],
31 AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen]),
32 [ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto])
33if test "x$ac_enable_doxygen" != "xno"; then
34 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
35 if test "x$HAVE_DOXYGEN" = "xfalse" -a "x$ac_enable_doxygen" = "xyes"; then
36 AC_MSG_ERROR([*** API documentation explicitly requested but Doxygen not found])
37 fi
38 AC_MSG_NOTICE([API documentation will be generated using Doxygen])
39else
40 HAVE_DOXYGEN=false
41 AC_MSG_NOTICE([API documentation will not be generated])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000042fi
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070043AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000044
45# Check for Darwin
46AC_MSG_CHECKING([if the host operating system is Darwin])
47case "$host" in
48 *-darwin*)
49 AC_MSG_RESULT([yes])
50 CFLAGS="$CFLAGS -DUSE_DARWIN"
51 OSFLAGS="-framework IOKit"
52 ;;
53 *) AC_MSG_RESULT([no]) ;;
54esac
55AC_SUBST(OSFLAGS)
56
Linus Walleij9e44f182010-12-07 20:33:13 +000057AC_MSG_CHECKING([if the host operating system is Linux])
58AC_TRY_COMPILE([#ifndef __linux__
59 #error "FAIL"
60 #endif
61 ],
62 [int test;],
63 [ AC_MSG_RESULT(yes)
64 AM_CONDITIONAL(USE_LINUX, true)
65 ],
66 [ AC_MSG_RESULT(no)
67 AM_CONDITIONAL(USE_LINUX, false)
68 ])
69
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000070# Check for mingw compiler platform
71AC_MSG_CHECKING([For MinGW32])
72case "$host" in
73 *-*-mingw*)
74 AC_MSG_RESULT([yes])
75 mingw_compiler=yes
76 ;;
77 *) AC_MSG_RESULT([no]) ;;
78esac
79AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"])
80
Linus Walleij6f050022009-05-06 21:14:41 +000081# Check if Microsoft LIB.EXE is available
82if test "$mingw_compiler" = "yes"; then
83 AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no)
84fi
85AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000086
87# Checks for libraries.
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000088AC_CHECK_LIB([usb], [usb_control_msg],,
89 AC_MSG_ERROR([I can't find the libusb libraries on your system. You
90 may need to set the LDFLAGS environment variable to include the
91 search path where you have libusb installed before running
92 configure (e.g. setenv LDFLAGS=-L/usr/local/lib)]), "$OSFLAGS")
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000093
94# Checks for header files.
95AC_HEADER_STDC
96AC_HEADER_TIME
97# zlib.h the day we need to decompress firmware
98AC_CHECK_HEADERS([ctype.h errno.h fcntl.h getopt.h libgen.h \
Linus Walleij56c63952008-06-08 21:55:58 +000099 limits.h stdio.h string.h sys/stat.h sys/time.h unistd.h \
Linus Walleij6f050022009-05-06 21:14:41 +0000100 iconv.h langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000101AC_CHECK_HEADER([usb.h],,
102 AC_MSG_ERROR([I can't find the libusb header file on your system.
103 You may need to set the CPPFLAGS environment variable to include
104 the search path where you have libusb installed before running
105 configure (e.g. setenv CPPFLAGS=-I/usr/local/include)]))
106
107# Checks for typedefs, structures, and compiler characteristics.
108AC_C_CONST
109AC_TYPE_OFF_T
110AC_TYPE_SIGNAL
111AC_TYPE_SIZE_T
112AC_STRUCT_ST_BLKSIZE
113
114# Checks for library functions.
115AC_FUNC_MALLOC
116AC_FUNC_MEMCMP
117AC_FUNC_STAT
Richard Low8d97bad2010-09-12 17:31:12 +0000118AC_CHECK_FUNCS(basename memset select strdup strerror strndup strrchr strtoul usleep mkstemp)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000119
120# Switches.
Linus Walleij05358382007-08-06 20:46:35 +0000121# Enable LFS (Large File Support)
Linus Walleij2f1b6402009-06-15 19:49:33 +0000122AC_SYS_LARGEFILE
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000123# Stick in "-Werror" if you want to be more aggressive.
124# (No need to use AC_SUBST on this default substituted environment variable.)
125CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
126
127# Output files
Linus Walleije8c54642006-03-28 09:45:00 +0000128
129# Create a stdint.h-like file containing size-specific integer definitions
130# that will always be available. The <stdint.h> file is required by the
131# library, but we provide this anyway because the libptp2 stuff wants this
132# file.
Linus Walleij2a84ca42008-12-14 00:00:23 +0000133AX_NEED_STDINT_H([src/_stdint.h])
Linus Walleij6fd2f082006-03-28 07:19:22 +0000134
Linus Walleije8c54642006-03-28 09:45:00 +0000135# Create a header file containing NetBSD-style byte swapping macros.
136# This m4 macros has caused severe pain, I am considering creating a
137# hard-coded byte swapper that will be eternally portable.
Linus Walleijb02a0662006-04-25 08:05:09 +0000138AC_NEED_BYTEORDER_H(src/gphoto2-endian.h)
Linus Walleij6fd2f082006-03-28 07:19:22 +0000139
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000140AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile
Linus Walleij6d3c2222010-11-30 23:42:32 +0000141 examples/Makefile util/Makefile libmtp.sh hotplug.sh libmtp.pc])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000142AC_OUTPUT
Linus Walleij0f2e7732006-08-17 20:48:32 +0000143chmod +x hotplug.sh