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