Imported Upstream version 1.1.11
[platform/upstream/libmtp.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.52)
3 AC_INIT([libmtp], [1.1.11], [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 # Checks for programs.
10 AC_PROG_CC
11 AC_PROG_INSTALL
12 AC_PROG_LN_S
13 AC_LIBTOOL_WIN32_DLL
14 AC_PROG_LIBTOOL
15 AM_ICONV
16
17 # Optionally set install location of udev
18 UDEV=/usr/lib/udev
19 AC_ARG_WITH(udev,
20     AC_HELP_STRING([--with-udev=DIR],
21     [directory where udev is installed [default=/usr/lib/udev]]),
22     [UDEV="${withval}"], [])
23 AC_SUBST(UDEV)
24
25 # 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 #
31 # Later rules can then use the identifiers for its processing.
32 UDEV_RULES=69-libmtp.rules
33 AC_ARG_WITH(udev-rules,
34     AC_HELP_STRING([--with-udev-rules=NAME],
35     [file name for udev rules [default=69-libmtp.rules]]),
36     [UDEV_RULES="${withval}"], [])
37 AC_SUBST(UDEV_RULES)
38
39 # Optionally set group for device nodes
40 UDEV_GROUP=
41 AC_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}\""], [])
45 AC_SUBST(UDEV_GROUP)
46
47 # Optionally set mode for device nodes
48 UDEV_MODE=
49 AC_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}\""], [])
53 AC_SUBST(UDEV_MODE)
54
55 # Optionally enable and check for doxygen
56 AC_ARG_ENABLE([doxygen],
57     AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=auto]]),
58     [ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto])
59 if test "x$ac_enable_doxygen" != "xno"; then
60     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     if test "x$HAVE_DOXYGEN" = "xtrue"; then
65         AC_MSG_NOTICE([API documentation will be generated using Doxygen])
66     fi
67 else
68     HAVE_DOXYGEN=false
69     AC_MSG_NOTICE([API documentation will not be generated])
70 fi
71 AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
72
73 # Check for Darwin
74 AC_MSG_CHECKING([if the host operating system is Darwin])
75 case "$host" in
76   *-darwin*)
77     AC_MSG_RESULT([yes])
78     CFLAGS="$CFLAGS -DUSE_DARWIN"
79     OSFLAGS="-framework IOKit"
80     ;;
81   *) AC_MSG_RESULT([no]) ;;
82 esac
83 AC_SUBST(OSFLAGS)
84
85 AC_MSG_CHECKING([if the host operating system is Linux])
86 AC_TRY_COMPILE([#ifndef __linux__
87                 #error "FAIL"
88                 #endif
89                 ],
90                 [int test;],
91                 [ AC_MSG_RESULT(yes)
92                   AM_CONDITIONAL(USE_LINUX, true)
93                 ],
94                 [ AC_MSG_RESULT(no)
95                   AM_CONDITIONAL(USE_LINUX, false)
96                 ])
97
98 # Check for mingw compiler platform
99 AC_MSG_CHECKING([For MinGW32])
100 case "$host" in
101   *-*-mingw*)
102     AC_MSG_RESULT([yes])
103     mingw_compiler=yes
104     ;;
105   *) AC_MSG_RESULT([no]) ;;
106 esac
107 AM_CONDITIONAL(COMPILE_MINGW32, [test "$mingw_compiler" = "yes"])
108
109 # Check if Microsoft LIB.EXE is available
110 if test "$mingw_compiler" = "yes"; then
111   AC_CHECK_PROG(ms_lib_exe, lib.exe, yes, no)
112 fi
113 AM_CONDITIONAL(MS_LIB_EXE, test x$ms_lib_exe = xyes)
114
115 # Check for libusb-1.0
116 PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= 1.0.0,[
117    LIBUSB_VER=`pkg-config --modversion libusb-1.0`
118    LIBUSB_REQUIRES='libusb-1.0'
119    AC_DEFINE(HAVE_LIBUSB1, [], [Have libusb 1.0])
120    found_libusb1_pkg=yes
121 ],[
122    # Check for libopenusb second
123    AC_CHECK_LIB([openusb], [openusb_init],[
124         AC_DEFINE(HAVE_OPENUSB, [], [Have libopenusb 1.0])
125         LIBUSB_VER=1.0
126    ],[
127       PKG_CHECK_MODULES(LIBUSB, libusb >= 0.1.8, [
128          LIBUSB_VER=`pkg-config --modversion libusb`
129          LIBUSB_REQUIRES='libusb'
130          AC_DEFINE(HAVE_LIBUSB0, [], [Have libusb 0.x])
131          found_libusb0_pkg=yes
132       ],[
133          # Some systems don't use pkg-config for libusb, so double check.
134          AC_CHECK_LIB([usb], [usb_open],[
135             LIBUSB_VER=0.1
136             AC_DEFINE(HAVE_LIBUSB0, [], [Have libusb 0.x])
137             found_libusb0_pkg=yes
138          ],[
139             AC_MSG_ERROR([*** libusb not found! (missing -dev/-devel package?) ***\n*** prefer to install libusb-1 if you can! ***])
140          ])
141       ])
142    ])
143 ])
144
145 # Optionally disable MTPZ functionality.
146 AC_ARG_ENABLE([mtpz],
147         AC_HELP_STRING([--disable-mtpz], [Disable functionality to connect to MTPZ devices (e.g. Zune)]),
148         [use_mtpz=$enableval],
149         [use_mtpz="yes"])
150
151 # Include MTPZ if not disabled.
152 if test x"$use_mtpz" = "xyes" ; then
153         # Check for libgcrypt.
154         AC_MSG_CHECKING([for libgcrypt])
155         AC_CHECK_LIB([gcrypt], [gcry_check_version], , [AC_MSG_NOTICE([*** libgcrypt not found - disabling MTPZ support ***]) ; use_mtpz="no"])
156 fi
157
158 if test x"$use_mtpz" = "xyes" ; then
159         AC_DEFINE(USE_MTPZ, [], [Enable MTPZ functionality])
160         AC_MSG_NOTICE([MTPZ functionality enabled]);
161 else
162         AC_MSG_NOTICE([MTPZ functionality disable]);
163 fi
164
165
166 AC_SUBST(LIBUSB_CFLAGS)
167 AC_SUBST(LIBUSB_LIBS)
168 AC_SUBST(LIBUSB_REQUIRES)
169 AM_CONDITIONAL(MTPZ_COMPILE, test x"$use_mtpz" = "xyes")
170 AM_CONDITIONAL(LIBUSB1_COMPILE, test x"$found_libusb1_pkg" = "xyes")
171 AM_CONDITIONAL(LIBUSB0_COMPILE, test x"$found_libusb0_pkg" = "xyes")
172 AM_CONDITIONAL(LIBOPENUSB_COMPILE, test x"$ac_cv_lib_openusb_openusb_init" = "xyes")
173 AC_MSG_NOTICE([*** using libusb $LIBUSB_VER ***])
174
175 # Checks for header files.
176 AC_HEADER_STDC
177 AC_HEADER_TIME
178 # zlib.h the day we need to decompress firmware
179 AC_CHECK_HEADERS([ctype.h errno.h fcntl.h getopt.h libgen.h \
180         limits.h stdio.h string.h sys/stat.h sys/time.h unistd.h \
181         langinfo.h locale.h arpa/inet.h byteswap.h sys/uio.h])
182
183 # Checks for typedefs, structures, and compiler characteristics.
184 AC_C_CONST
185 AC_TYPE_OFF_T
186 AC_TYPE_SIGNAL
187 AC_TYPE_SIZE_T
188 AC_STRUCT_ST_BLKSIZE
189
190 # Checks for library functions.
191 AC_FUNC_MEMCMP
192 AC_FUNC_STAT
193 AC_CHECK_FUNCS(basename memset select strdup strerror strndup strrchr strtoul usleep mkstemp)
194
195 # Switches.
196 # Enable LFS (Large File Support)
197 AC_SYS_LARGEFILE
198 # Stick in "-Werror" if you want to be more aggressive.
199 # (No need to use AC_SUBST on this default substituted environment variable.)
200 # Only add these additional CFLAGS if we are using GCC. Other C compilers may
201 # not support them.
202 if test x"$GCC" == "xyes" ; then
203         CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
204 fi
205
206 # Output files
207
208 # Create a stdint.h-like file containing size-specific integer definitions
209 # that will always be available. The <stdint.h> file is required by the
210 # library, but we provide this anyway because the libptp2 stuff wants this
211 # file.
212 AX_NEED_STDINT_H([src/_stdint.h])
213
214 # Create a header file containing NetBSD-style byte swapping macros.
215 # This m4 macros has caused severe pain, I am considering creating a
216 # hard-coded byte swapper that will be eternally portable.
217 AC_NEED_BYTEORDER_H(src/gphoto2-endian.h)
218
219 AC_CONFIG_FILES([src/libmtp.h doc/Doxyfile Makefile doc/Makefile src/Makefile
220         examples/Makefile util/Makefile libmtp.sh hotplug.sh libmtp.pc])
221 AC_OUTPUT
222 chmod +x hotplug.sh