blob: e0eb607726b2c8d22cbf61995881b7323d89f4df [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 Walleijd5ab76b2011-10-22 15:04:02 +02003AC_INIT([libmtp], [1.1.1], [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
18UDEV=/lib/udev
19AC_ARG_WITH(udev,
20 AC_HELP_STRING([--with-udev=DIR],
21 [directory where udev is installed [default=/lib/udev]]),
22 [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],
43 [file group for device nodes [default: none specified]]]),
44 [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],
51 [file mode for device nodes [default: none specified]]]),
52 [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],
Denis Dupeyron339b3942011-01-20 23:17:23 -070057 AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=no]]),
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070058 [ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto])
Denis Dupeyron339b3942011-01-20 23:17:23 -070059if test "x$ac_enable_doxygen" == "xyes"; 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
64 AC_MSG_NOTICE([API documentation will be generated using Doxygen])
65else
66 HAVE_DOXYGEN=false
67 AC_MSG_NOTICE([API documentation will not be generated])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000068fi
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070069AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000070
71# Check for Darwin
72AC_MSG_CHECKING([if the host operating system is Darwin])
73case "$host" in
74 *-darwin*)
75 AC_MSG_RESULT([yes])
76 CFLAGS="$CFLAGS -DUSE_DARWIN"
77 OSFLAGS="-framework IOKit"
78 ;;
79 *) AC_MSG_RESULT([no]) ;;
80esac
81AC_SUBST(OSFLAGS)
82
Linus Walleij9e44f182010-12-07 20:33:13 +000083AC_MSG_CHECKING([if the host operating system is Linux])
84AC_TRY_COMPILE([#ifndef __linux__
85 #error "FAIL"
86 #endif
87 ],
88 [int test;],
89 [ AC_MSG_RESULT(yes)
90 AM_CONDITIONAL(USE_LINUX, true)
91 ],
92 [ AC_MSG_RESULT(no)
93 AM_CONDITIONAL(USE_LINUX, false)
94 ])
95
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000096# Check for mingw compiler platform
97AC_MSG_CHECKING([For MinGW32])
98case "$host" in
99 *-*-mingw*)
100 AC_MSG_RESULT([yes])
101 mingw_compiler=yes
102 ;;
103 *) AC_MSG_RESULT([no]) ;;
104esac
105AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"])
106
Linus Walleij6f050022009-05-06 21:14:41 +0000107# Check if Microsoft LIB.EXE is available
108if test "$mingw_compiler" = "yes"; then
109 AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no)
110fi
111AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000112
113# Checks for libraries.
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000114AC_CHECK_LIB([usb], [usb_control_msg],,
115 AC_MSG_ERROR([I can't find the libusb libraries on your system. You
116 may need to set the LDFLAGS environment variable to include the
117 search path where you have libusb installed before running
118 configure (e.g. setenv LDFLAGS=-L/usr/local/lib)]), "$OSFLAGS")
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000119
120# Checks for header files.
121AC_HEADER_STDC
122AC_HEADER_TIME
123# zlib.h the day we need to decompress firmware
124AC_CHECK_HEADERS([ctype.h errno.h fcntl.h getopt.h libgen.h \
Linus Walleij56c63952008-06-08 21:55:58 +0000125 limits.h stdio.h string.h sys/stat.h sys/time.h unistd.h \
Linus Walleij8e499142011-02-10 16:28:02 +0100126 langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000127AC_CHECK_HEADER([usb.h],,
128 AC_MSG_ERROR([I can't find the libusb header file on your system.
129 You may need to set the CPPFLAGS environment variable to include
130 the search path where you have libusb installed before running
131 configure (e.g. setenv CPPFLAGS=-I/usr/local/include)]))
132
133# Checks for typedefs, structures, and compiler characteristics.
134AC_C_CONST
135AC_TYPE_OFF_T
136AC_TYPE_SIGNAL
137AC_TYPE_SIZE_T
138AC_STRUCT_ST_BLKSIZE
139
140# Checks for library functions.
141AC_FUNC_MALLOC
142AC_FUNC_MEMCMP
143AC_FUNC_STAT
Richard Low8d97bad2010-09-12 17:31:12 +0000144AC_CHECK_FUNCS(basename memset select strdup strerror strndup strrchr strtoul usleep mkstemp)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000145
146# Switches.
Linus Walleij05358382007-08-06 20:46:35 +0000147# Enable LFS (Large File Support)
Linus Walleij2f1b6402009-06-15 19:49:33 +0000148AC_SYS_LARGEFILE
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000149# Stick in "-Werror" if you want to be more aggressive.
150# (No need to use AC_SUBST on this default substituted environment variable.)
151CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
152
153# Output files
Linus Walleije8c54642006-03-28 09:45:00 +0000154
155# Create a stdint.h-like file containing size-specific integer definitions
156# that will always be available. The <stdint.h> file is required by the
157# library, but we provide this anyway because the libptp2 stuff wants this
158# file.
Linus Walleij2a84ca42008-12-14 00:00:23 +0000159AX_NEED_STDINT_H([src/_stdint.h])
Linus Walleij6fd2f082006-03-28 07:19:22 +0000160
Linus Walleije8c54642006-03-28 09:45:00 +0000161# Create a header file containing NetBSD-style byte swapping macros.
Linus Walleijd5ab76b2011-10-22 15:04:02 +0200162# This m4 macros has caused severe pain, I am considering creating a
Linus Walleije8c54642006-03-28 09:45:00 +0000163# hard-coded byte swapper that will be eternally portable.
Linus Walleijb02a0662006-04-25 08:05:09 +0000164AC_NEED_BYTEORDER_H(src/gphoto2-endian.h)
Linus Walleij6fd2f082006-03-28 07:19:22 +0000165
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000166AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile
Linus Walleij6d3c2222010-11-30 23:42:32 +0000167 examples/Makefile util/Makefile libmtp.sh hotplug.sh libmtp.pc])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000168AC_OUTPUT
Linus Walleij0f2e7732006-08-17 20:48:32 +0000169chmod +x hotplug.sh