blob: 0263d8a75572b842bcfc949e3d3936d33dcbf368 [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
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 Dupeyronbc442cd2011-01-16 21:57:39 -070033# Optionally enable and check for doxygen
34AC_ARG_ENABLE([doxygen],
Denis Dupeyron339b3942011-01-20 23:17:23 -070035 AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=no]]),
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070036 [ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto])
Denis Dupeyron339b3942011-01-20 23:17:23 -070037if test "x$ac_enable_doxygen" == "xyes"; then
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070038 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
39 if test "x$HAVE_DOXYGEN" = "xfalse" -a "x$ac_enable_doxygen" = "xyes"; then
40 AC_MSG_ERROR([*** API documentation explicitly requested but Doxygen not found])
41 fi
42 AC_MSG_NOTICE([API documentation will be generated using Doxygen])
43else
44 HAVE_DOXYGEN=false
45 AC_MSG_NOTICE([API documentation will not be generated])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000046fi
Denis Dupeyronbc442cd2011-01-16 21:57:39 -070047AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000048
49# Check for Darwin
50AC_MSG_CHECKING([if the host operating system is Darwin])
51case "$host" in
52 *-darwin*)
53 AC_MSG_RESULT([yes])
54 CFLAGS="$CFLAGS -DUSE_DARWIN"
55 OSFLAGS="-framework IOKit"
56 ;;
57 *) AC_MSG_RESULT([no]) ;;
58esac
59AC_SUBST(OSFLAGS)
60
Linus Walleij9e44f182010-12-07 20:33:13 +000061AC_MSG_CHECKING([if the host operating system is Linux])
62AC_TRY_COMPILE([#ifndef __linux__
63 #error "FAIL"
64 #endif
65 ],
66 [int test;],
67 [ AC_MSG_RESULT(yes)
68 AM_CONDITIONAL(USE_LINUX, true)
69 ],
70 [ AC_MSG_RESULT(no)
71 AM_CONDITIONAL(USE_LINUX, false)
72 ])
73
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000074# Check for mingw compiler platform
75AC_MSG_CHECKING([For MinGW32])
76case "$host" in
77 *-*-mingw*)
78 AC_MSG_RESULT([yes])
79 mingw_compiler=yes
80 ;;
81 *) AC_MSG_RESULT([no]) ;;
82esac
83AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"])
84
Linus Walleij6f050022009-05-06 21:14:41 +000085# Check if Microsoft LIB.EXE is available
86if test "$mingw_compiler" = "yes"; then
87 AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no)
88fi
89AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000090
91# Checks for libraries.
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000092AC_CHECK_LIB([usb], [usb_control_msg],,
93 AC_MSG_ERROR([I can't find the libusb libraries on your system. You
94 may need to set the LDFLAGS environment variable to include the
95 search path where you have libusb installed before running
96 configure (e.g. setenv LDFLAGS=-L/usr/local/lib)]), "$OSFLAGS")
Linus Walleijeb8c6fe2006-02-03 09:46:22 +000097
98# Checks for header files.
99AC_HEADER_STDC
100AC_HEADER_TIME
101# zlib.h the day we need to decompress firmware
102AC_CHECK_HEADERS([ctype.h errno.h fcntl.h getopt.h libgen.h \
Linus Walleij56c63952008-06-08 21:55:58 +0000103 limits.h stdio.h string.h sys/stat.h sys/time.h unistd.h \
Linus Walleij6f050022009-05-06 21:14:41 +0000104 iconv.h langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000105AC_CHECK_HEADER([usb.h],,
106 AC_MSG_ERROR([I can't find the libusb header file on your system.
107 You may need to set the CPPFLAGS environment variable to include
108 the search path where you have libusb installed before running
109 configure (e.g. setenv CPPFLAGS=-I/usr/local/include)]))
110
111# Checks for typedefs, structures, and compiler characteristics.
112AC_C_CONST
113AC_TYPE_OFF_T
114AC_TYPE_SIGNAL
115AC_TYPE_SIZE_T
116AC_STRUCT_ST_BLKSIZE
117
118# Checks for library functions.
119AC_FUNC_MALLOC
120AC_FUNC_MEMCMP
121AC_FUNC_STAT
Richard Low8d97bad2010-09-12 17:31:12 +0000122AC_CHECK_FUNCS(basename memset select strdup strerror strndup strrchr strtoul usleep mkstemp)
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000123
124# Switches.
Linus Walleij05358382007-08-06 20:46:35 +0000125# Enable LFS (Large File Support)
Linus Walleij2f1b6402009-06-15 19:49:33 +0000126AC_SYS_LARGEFILE
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000127# Stick in "-Werror" if you want to be more aggressive.
128# (No need to use AC_SUBST on this default substituted environment variable.)
129CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
130
131# Output files
Linus Walleije8c54642006-03-28 09:45:00 +0000132
133# Create a stdint.h-like file containing size-specific integer definitions
134# that will always be available. The <stdint.h> file is required by the
135# library, but we provide this anyway because the libptp2 stuff wants this
136# file.
Linus Walleij2a84ca42008-12-14 00:00:23 +0000137AX_NEED_STDINT_H([src/_stdint.h])
Linus Walleij6fd2f082006-03-28 07:19:22 +0000138
Linus Walleije8c54642006-03-28 09:45:00 +0000139# Create a header file containing NetBSD-style byte swapping macros.
140# This m4 macros has caused severe pain, I am considering creating a
141# hard-coded byte swapper that will be eternally portable.
Linus Walleijb02a0662006-04-25 08:05:09 +0000142AC_NEED_BYTEORDER_H(src/gphoto2-endian.h)
Linus Walleij6fd2f082006-03-28 07:19:22 +0000143
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000144AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile
Linus Walleij6d3c2222010-11-30 23:42:32 +0000145 examples/Makefile util/Makefile libmtp.sh hotplug.sh libmtp.pc])
Linus Walleijeb8c6fe2006-02-03 09:46:22 +0000146AC_OUTPUT
Linus Walleij0f2e7732006-08-17 20:48:32 +0000147chmod +x hotplug.sh