blob: e72eb3814c759aec439d8138e12b72367d5100d5 [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 Walleijfe77f1b2011-02-04 23:57:52 +01003AC_INIT([libmtp], [1.0.5], [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
Denis Dupeyronb9eed542011-01-26 22:31:16 -070025# Optionally set name of udev rules file
26UDEV_RULES=libmtp.rules
27AC_ARG_WITH(udev-rules,
28 AC_HELP_STRING([--with-udev-rules=NAME],
29 [file name for udev rules [default=libmtp.rules]]),
30 [UDEV_RULES="${withval}"], [])
31AC_SUBST(UDEV_RULES)
Linus Walleij5cf12e72011-01-18 15:33:09 +010032
Denis Dupeyron83e79a22011-02-07 22:40:45 -070033# Optionally set group for device nodes
34UDEV_GROUP=
35AC_ARG_WITH(udev-group,
36 AC_HELP_STRING([--with-udev-group=GROUP],
37 [file group for device nodes [default: none specified]]]),
38 [UDEV_GROUP="-g\"${withval}\""], [])
39AC_SUBST(UDEV_GROUP)
40
41# Optionally set mode for device nodes
42UDEV_MODE=
43AC_ARG_WITH(udev-mode,
44 AC_HELP_STRING([--with-udev-mode=GROUP],
45 [file mode for device nodes [default: none specified]]]),
46 [UDEV_MODE="-m\"${withval}\""], [])
47AC_SUBST(UDEV_MODE)
48
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070049# Optionally enable and check for doxygen
50AC_ARG_ENABLE([doxygen],
Denis Dupeyron339b3942011-01-20 23:17:23 -070051 AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=no]]),
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070052 [ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto])
Denis Dupeyron339b3942011-01-20 23:17:23 -070053if test "x$ac_enable_doxygen" == "xyes"; then
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070054 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
55 if test "x$HAVE_DOXYGEN" = "xfalse" -a "x$ac_enable_doxygen" = "xyes"; then
56 AC_MSG_ERROR([*** API documentation explicitly requested but Doxygen not found])
57 fi
58 AC_MSG_NOTICE([API documentation will be generated using Doxygen])
59else
60 HAVE_DOXYGEN=false
61 AC_MSG_NOTICE([API documentation will not be generated])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000062fi
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070063AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000064
65# Check for Darwin
66AC_MSG_CHECKING([if the host operating system is Darwin])
67case "$host" in
68 *-darwin*)
69 AC_MSG_RESULT([yes])
70 CFLAGS="$CFLAGS -DUSE_DARWIN"
71 OSFLAGS="-framework IOKit"
72 ;;
73 *) AC_MSG_RESULT([no]) ;;
74esac
75AC_SUBST(OSFLAGS)
76
Linus Walleij9e44f182010-12-07 20:33:13 +000077AC_MSG_CHECKING([if the host operating system is Linux])
78AC_TRY_COMPILE([#ifndef __linux__
79 #error "FAIL"
80 #endif
81 ],
82 [int test;],
83 [ AC_MSG_RESULT(yes)
84 AM_CONDITIONAL(USE_LINUX, true)
85 ],
86 [ AC_MSG_RESULT(no)
87 AM_CONDITIONAL(USE_LINUX, false)
88 ])
89
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000090# Check for mingw compiler platform
91AC_MSG_CHECKING([For MinGW32])
92case "$host" in
93 *-*-mingw*)
94 AC_MSG_RESULT([yes])
95 mingw_compiler=yes
96 ;;
97 *) AC_MSG_RESULT([no]) ;;
98esac
99AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"])
100
Linus Walleij6f050022009-05-06 21:14:41 +0000101# Check if Microsoft LIB.EXE is available
102if test "$mingw_compiler" = "yes"; then
103 AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no)
104fi
105AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000106
107# Checks for libraries.
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000108AC_CHECK_LIB([usb], [usb_control_msg],,
109 AC_MSG_ERROR([I can't find the libusb libraries on your system. You
110 may need to set the LDFLAGS environment variable to include the
111 search path where you have libusb installed before running
112 configure (e.g. setenv LDFLAGS=-L/usr/local/lib)]), "$OSFLAGS")
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000113
114# Checks for header files.
115AC_HEADER_STDC
116AC_HEADER_TIME
117# zlib.h the day we need to decompress firmware
118AC_CHECK_HEADERS([ctype.h errno.h fcntl.h getopt.h libgen.h \
Linus Walleij56c63952008-06-08 21:55:58 +0000119 limits.h stdio.h string.h sys/stat.h sys/time.h unistd.h \
Linus Walleij6f050022009-05-06 21:14:41 +0000120 iconv.h langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000121AC_CHECK_HEADER([usb.h],,
122 AC_MSG_ERROR([I can't find the libusb header file on your system.
123 You may need to set the CPPFLAGS environment variable to include
124 the search path where you have libusb installed before running
125 configure (e.g. setenv CPPFLAGS=-I/usr/local/include)]))
126
127# Checks for typedefs, structures, and compiler characteristics.
128AC_C_CONST
129AC_TYPE_OFF_T
130AC_TYPE_SIGNAL
131AC_TYPE_SIZE_T
132AC_STRUCT_ST_BLKSIZE
133
134# Checks for library functions.
135AC_FUNC_MALLOC
136AC_FUNC_MEMCMP
137AC_FUNC_STAT
Richard Low8d97bad2010-09-12 17:31:12 +0000138AC_CHECK_FUNCS(basename memset select strdup strerror strndup strrchr strtoul usleep mkstemp)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000139
140# Switches.
Linus Walleij05358382007-08-06 20:46:35 +0000141# Enable LFS (Large File Support)
Linus Walleij2f1b6402009-06-15 19:49:33 +0000142AC_SYS_LARGEFILE
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000143# Stick in "-Werror" if you want to be more aggressive.
144# (No need to use AC_SUBST on this default substituted environment variable.)
145CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
146
147# Output files
Linus Walleije8c54642006-03-28 09:45:00 +0000148
149# Create a stdint.h-like file containing size-specific integer definitions
150# that will always be available. The <stdint.h> file is required by the
151# library, but we provide this anyway because the libptp2 stuff wants this
152# file.
Linus Walleij2a84ca42008-12-14 00:00:23 +0000153AX_NEED_STDINT_H([src/_stdint.h])
Linus Walleij6fd2f082006-03-28 07:19:22 +0000154
Linus Walleije8c54642006-03-28 09:45:00 +0000155# Create a header file containing NetBSD-style byte swapping macros.
156# This m4 macros has caused severe pain, I am considering creating a
157# hard-coded byte swapper that will be eternally portable.
Linus Walleijb02a0662006-04-25 08:05:09 +0000158AC_NEED_BYTEORDER_H(src/gphoto2-endian.h)
Linus Walleij6fd2f082006-03-28 07:19:22 +0000159
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000160AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile
Linus Walleij6d3c2222010-11-30 23:42:32 +0000161 examples/Makefile util/Makefile libmtp.sh hotplug.sh libmtp.pc])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000162AC_OUTPUT
Linus Walleij0f2e7732006-08-17 20:48:32 +0000163chmod +x hotplug.sh