Source code upload
[framework/connectivity/libgphoto2.git] / libgphoto2_port / configure.ac
1 dnl Process this file with autoreconf to produce a configure script.
2 AC_PREREQ(2.59)
3 AC_INIT([libgphoto2 port access library], [0.8.0], [gphoto-devel@lists.sourceforge.net], [libgphoto2_port])
4 AC_CONFIG_SRCDIR([libgphoto2_port/gphoto2-port-version.c])
5 AC_CONFIG_HEADERS([config.h])
6 AC_CONFIG_MACRO_DIR([auto-m4])
7 AC_CONFIG_AUX_DIR([auto-aux])
8 dnl Working around bug in automake <= 1.9.6:
9 dnl  - Please do not add filename-length-max=99 here.
10 dnl  - Otherwise "make distdir" will fail in libgphoto2
11 dnl The generated Makefile rule fails to remove the absolute part at
12 dnl the beginning of the /path/to/buildroot/PACKAGE-VERSION/foo/bar
13 dnl before determining the string length. However, the only relevant
14 dnl string to determine the length of would be PACKAGE-VERSION/foo/bar
15 AM_INIT_AUTOMAKE([-Wall gnu 1.9 dist-bzip2 check-news])
16
17
18 dnl ---------------------------------------------------------------------------
19 dnl Advanced information about versioning:
20 dnl   * "Writing shared libraries" by Mike Hearn
21 dnl         http://navi.cx/~mike/writing-shared-libraries.html
22 dnl   * libtool.info chapter "Versioning"
23 dnl   * libtool.info chapter "Updating library version information"
24 dnl ---------------------------------------------------------------------------
25 dnl Versioning:
26 dnl  - CURRENT (Major):  Increment if the interface has changes. AGE is always
27 dnl                      *changed* at the same time.
28 dnl  - AGE (Micro):      Increment if any interfaces have been added; set to 0
29 dnl                      if any interfaces have been removed. Removal has 
30 dnl                      precedence over adding, so set to 0 if both happened.
31 dnl                      It denotes upward compatibility.
32 dnl  - REVISION (Minor): Increment any time the source changes; set to 
33 dnl                      0 if you incremented CURRENT.
34 dnl
35 dnl  To summarize. Any interface *change* increment CURRENT. If that interface
36 dnl  change does not break upward compatibility (ie it is an addition), 
37 dnl  increment AGE, Otherwise AGE is reset to 0. If CURRENT has changed, 
38 dnl  REVISION is set to 0, otherwise REVISION is incremented.
39 dnl ---------------------------------------------------------------------------
40 dnl A:R:C=6:1:6 libgphoto2_port-0.6.1 libgphoto2-2.2.1
41 dnl A:R:C=7:0:7 libgphoto2_port-0.7.0 libgphoto2-2.3
42 dnl A:R:C=7:1:7 libgphoto2_port-0.7.1 libgphoto2-2.3.x
43 dnl A:R:C=8:0:8 libgphoto2_port-0.8.0 libgphoto2-2.4.x
44 AC_SUBST([LIBGPHOTO2_PORT_AGE],      [8])
45 AC_SUBST([LIBGPHOTO2_PORT_REVISION], [0])
46 AC_SUBST([LIBGPHOTO2_PORT_CURRENT],  [8])
47 AC_SUBST([LIBGPHOTO2_PORT_CURRENT_MIN],
48          [`expr $LIBGPHOTO2_PORT_CURRENT - $LIBGPHOTO2_PORT_AGE`])
49 AC_SUBST([LIBGPHOTO2_PORT_VERSION_INFO],
50          [$LIBGPHOTO2_PORT_CURRENT:$LIBGPHOTO2_PORT_REVISION:$LIBGPHOTO2_PORT_AGE])
51
52
53 dnl ---------------------------------------------------------------------------
54 dnl Checks for programs.
55 dnl ---------------------------------------------------------------------------
56 AC_PROG_CC
57 AC_PROG_CPP
58 AC_PROG_INSTALL
59 AM_PROG_CC_C_O
60
61 dnl Something with the sequences is not quite alright yet.
62 dnl SED is supposed to be set in AC_LIBTOOL_SETUP, but the
63 dnl sequence seems to get mixed up.
64 SED=${SED-sed}
65
66 dnl check for/set up libtool and libltdl
67 dnl AC_DISABLE_STATIC
68 dnl AC_DISABLE_SHARED
69 dnl AC_LIBLTDL_CONVENIENCE([libltdl])
70 dnl AC_WITH_LTDL
71 dnl AC_LIB_LTDL
72 AC_DISABLE_STATIC
73 AC_LIBTOOL_WIN32_DLL
74 AC_LIBTOOL_DLOPEN
75 AC_PROG_LIBTOOL
76
77 dnl We are using our own libltdl checks instead of AC_WITH_LTDL
78 dnl because we do not want to ship our own copy of libltdl any more.
79 dnl Not shipping libltdl makes it possible to ditch our own autogen.sh
80 dnl and relying on standard autoconf's "autoreconf".
81 #GP_LIB_LTDL
82
83 # report on compiler/libtool setup
84 GP_CONFIG_MSG([Build])
85 GP_CONFIG_MSG([Source directory],[${srcdir}])
86 GP_CONFIG_MSG([Compiler],[${CC}])
87 #GP_CONFIG_MSG([libltdl includes],[$LTDLINCL])
88 #GP_CONFIG_MSG([libltdl library],[$LIBLTDL])
89
90 AC_DEFINE_UNQUOTED(HAVE_CC,"$CC",[The C compiler we're using])
91
92 AM_CPPFLAGS="$CPPFLAGS"
93 AM_CPPFLAGS="$AM_CPPFLAGS -I\$(top_srcdir)"
94
95 # ----------------------------------------------------------------------
96 # References to external resources (web sites, mailing listes, etc.)
97 # ----------------------------------------------------------------------
98
99 GP_REFERENCES()dnl
100
101
102 dnl ---------------------------------------------------------------------------
103 dnl i18n support
104 dnl ---------------------------------------------------------------------------
105
106 dnl The following is a hack to get gphoto2 to build on gettext-0.10.35
107 dnl systems - BUILD_INCLUDED_LIBINTL is set only in gettext-0.10.37 which is
108 dnl the gettext version provided with gphoto2.
109 dnl BUILD_INCLUDED_LIBINTL=no
110 dnl AC_SUBST(BUILD_INCLUDED_LIBINTL)
111 dnl USE_INCLUDED_LIBINTL=no
112 dnl AC_SUBST(USE_INCLUDED_LIBINTL)
113
114 GP_GETTEXT_HACK([${PACKAGE}-${LIBGPHOTO2_PORT_CURRENT_MIN}],[Lutz Mueller and others],[${MAIL_GPHOTO_TRANSLATION}])
115 ALL_LINGUAS="cs da de fr es eu it ja nl pl pt_BR ru sk sv uk vi zh_CN zh_TW"
116 AM_GNU_GETTEXT_VERSION([0.14.1])
117 AM_GNU_GETTEXT([external])
118 AM_PO_SUBDIRS()
119 AM_ICONV()
120 GP_GETTEXT_FLAGS()
121
122 AC_SUBST([localedir],["\$(datadir)/locale"])
123 AM_CPPFLAGS="$AM_CPPFLAGS -DLOCALEDIR=\\\"${localedir}\\\""
124
125 AC_CHECK_FUNC(gettext, gettext_without_libintl=true)
126 # same trick as with libdl in libgphoto2:
127 # if gettext() doesn't require linking against libintl,
128 # we don't have to check for gettext in libintl. Otherwise
129 # we may even require libintl.
130 dnl AC_CHECK_LIB(intl, gettext, [LIBS="$LIBS -lintl"])
131 if test "$gettext_without_libintl" != "true" -a "$USE_NLS" = "yes"; then
132         AC_CHECK_LIB(intl, gettext, [INTLLIBS="$INTLLIBS -lintl"])
133 fi
134
135
136 dnl ---------------------------------------------------------------------------
137 dnl Checks for header files.
138 dnl ---------------------------------------------------------------------------
139 AC_HEADER_DIRENT
140 AC_HEADER_STDC
141
142 AC_C_INLINE([])
143 AC_C_CONST([])
144
145 AC_CHECK_HEADERS(stdlib.h unistd.h stdio.h fcntl.h errno.h sys/time.h   \
146         sys/param.h sys/select.h termios.h sgetty.h ttold.h ioctl-types.h       \
147         fcntl.h sgtty.h sys/ioctl.h sys/time.h termio.h unistd.h        \
148         endian.h byteswap.h asm/io.h mntent.h sys/mntent.h sys/mnttab.h \
149         scsi/sg.h limits.h)
150         
151 dnl FIXME: Provide regex.h with the corresponding object code for 
152 dnl        platforms which do not have it, e.g. Windows.
153 AC_CHECK_HEADER([regex.h],
154                 [AC_DEFINE([HAVE_REGEX],1,[whether we have regex.h])],
155                 [AC_MSG_ERROR([
156 *** We need regex.h and its object code to compile
157 *** But we could not find it.
158 ])
159 ])
160
161 dnl ---------------------------------------------------------------------------
162 dnl Apple Bonjour / mDNSResponder multicast DNS queries.
163 dnl ---------------------------------------------------------------------------
164 with_bonjour=no
165 AC_ARG_WITH([bonjour],
166         AS_HELP_STRING([--without-bonjour], [whether to exclude Bonjour PTP/IP autodetection]),
167         ,
168         with_bonjour=yes
169 )
170
171 MDNS_LIBS=
172 if test "x$with_bonjour" = "xyes"; then
173         AC_CHECK_HEADER([dns_sd.h],[
174                 AC_CHECK_LIB(dns_sd,DNSServiceResolve,[
175                         MDNS_LIBS="-ldns_sd"
176                         AC_DEFINE(HAVE_MDNS_BONJOUR,1,[Define if you have Bonjour/mDNSResponder.])
177                 ])
178         ])
179 fi
180 AC_SUBST(MDNS_LIBS)
181
182 dnl Check for mnt_mountp in struct mnttab
183 AC_MSG_CHECKING([for mnt_mountp in struct mnttab])
184 AC_COMPILE_IFELSE([dnl
185 AC_LANG_PROGRAM([[
186 #if defined(HAVE_SYS_MNTENT_H) && defined(HAVE_SYS_MNTTAB_H)
187 # include <sys/mntent.h>
188 # include <sys/mnttab.h>
189 #endif
190 ]], [[
191 struct mnttab mt;
192 mt.mnt_mountp;
193 ]])dnl
194 ],[
195 AC_DEFINE(HAVE_MNTTAB,1,whether struct mnttag has mnt_mountp field)
196 AC_MSG_RESULT(yes)
197 ],[
198 AC_MSG_RESULT(no)
199 ])
200
201
202 AC_SUBST(MDNS_LIBS)
203
204 dnl Checks for library functions.
205 AC_CHECK_FUNCS(setmntent endmntent strerror snprintf vsnprintf)
206
207 dnl Check if TIOCM_RTS is included in one of several possible files
208 AC_TRY_COMPILE([#include <termios.h>], [int foo = TIOCM_RTS;],
209                         AC_DEFINE(HAVE_RTS_IOCTL,1,[Define if you have TIOCM_RTS.]))
210 AC_TRY_COMPILE([#include <termio.h>], [int foo = TIOCM_RTS;],
211                         AC_DEFINE(HAVE_RTS_IOCTL,1,[Define if you have TIOCM_RTS.]))
212 AC_TRY_COMPILE([#include <ioctl-types.h>], [int foo = TIOCM_RTS;],
213                         AC_DEFINE(HAVE_RTS_IOCTL,1,[Define if you have TIOCM_TRS.]))
214 AC_TRY_COMPILE([#include <sys/ioctl.h>], [int foo = TIOCM_RTS;],
215                         AC_DEFINE(HAVE_RTS_IOCTL,1,[Define if you have TIOCM_TRS.]))
216
217 # Check for va_copy()
218 GP_VA_COPY
219
220
221 dnl ---------------------------------------------------------------------------
222 dnl serial
223 dnl ---------------------------------------------------------------------------
224 serial_msg=yes
225 have_serial=true
226 try_baudboy_msg=true
227 try_ttylock=true
228 try_lockdev=true
229 try_resmgr=true
230 AC_ARG_ENABLE([serial],
231         [AS_HELP_STRING([--disable-serial],
232                         [do not compile in SERIAL support])],
233 [
234         if test x$enableval = xno; then
235                 have_serial=false
236                 serial_msg=no
237                 try_baudboy=false
238                 try_ttylock=false
239                 try_lockdev=false
240                 try_resmgr=false
241         fi
242 ])
243 if $have_serial; then
244         IOLIB_SUBDIRS="$IOLIB_SUBDIRS serial"
245         AC_DEFINE([HAVE_SERIAL],1,[Whether you have serial support enabled])
246 fi
247 GP_CONFIG_MSG([Serial ports])
248 GP_CONFIG_MSG([Serial support],[$serial_msg])
249
250 SERIAL_LIBS=""
251 if $have_serial; then
252
253 dnl -----------------------------------------
254 dnl Serial port locking: We try to use either
255 dnl  (1) resmgr support
256 dnl  (2) baudboy.h
257 dnl  (3) ttylock.h
258 dnl  (4) lockdev.h
259 dnl -----------------------------------------
260 AC_DEFUN([GP_SERLOCK],[dnl
261 # $0([$1])
262 AC_ARG_ENABLE([$1],
263 [AS_HELP_STRING([--disable-][$1],
264                 [do not use ][$1][ library])
265 ],[
266         if test x$enableval = xno; then
267                 try_[$1]=false
268         fi
269 ])
270 ])dnl
271 GP_SERLOCK([baudboy])dnl
272 GP_SERLOCK([ttylock])dnl
273 GP_SERLOCK([lockdev])dnl
274 GP_SERLOCK([resmgr])dnl
275
276 resmgr_msg=no
277 if $try_resmgr; then
278         AC_CHECK_HEADER(resmgr.h,[
279                 AC_CHECK_LIB(resmgr, rsm_lock_device,[
280                         resmgr_msg=yes
281                         SERIAL_LIBS="-lresmgr"
282                         AC_DEFINE(HAVE_RESMGR,1,[Define if we have the resmgr library.])
283                 ])
284         ])
285 fi
286 GP_CONFIG_MSG([resmgr locking],[${resmgr_msg}])
287
288 baudboy_msg=no
289 if $try_baudboy; then
290         AC_CHECK_HEADER(baudboy.h,[
291                 baudboy_msg=yes
292                 try_ttylock=false
293                 try_lockdev=false
294                 AC_DEFINE(HAVE_BAUDBOY,1,[Define if you have Baudboy serial locking.])
295         ])
296 fi
297 GP_CONFIG_MSG([baudboy locking],[${baudboy_msg}])
298
299 ttylock_msg=no
300 if $try_ttylock; then
301         AC_CHECK_HEADER([lockdev.h])
302         AC_CHECK_HEADER([ttylock.h],[
303                 lockdev_result="no"
304                 AC_TRY_LINK([#include <ttylock.h>],[ttylocked ("/dev/foo");],[
305                         lockdev_result="no"
306                         AC_DEFINE(HAVE_TTYLOCK,1,[Define if you have ttylock based tty locking.])
307                         ttylock_msg=yes
308                         try_lockdev=false,
309                         LDFLAGS="$LDFLAGS -llockdev"
310                         AC_TRY_LINK([#include <ttylock.h>],[ttylocked ("/dev/foo");],[
311                                 lockdev_result="yes"
312                                 AC_DEFINE(HAVE_TTYLOCK,1,[Define if you have ttylock based tty locking.])
313                                 ttylock_msg=yes
314                                 try_lockdev=false
315                                 SERIAL_LIBS=-llockdev
316                         ])
317                 ])
318                 AC_MSG_CHECKING([if ttylock needs lockdev])
319                 AC_MSG_RESULT([${lockdev_result}])
320         ],[],[#ifdef HAVE_LOCKDEV_H
321 # include <lockdev.h>
322 #endif
323         ])
324 fi
325 GP_CONFIG_MSG([ttylock locking],[${ttylock_msg}])
326
327 lockdev_msg=no
328 if $try_lockdev; then
329         AC_CHECK_LIB(lockdev, dev_lock,[
330                 AC_CHECK_HEADER(lockdev.h,[
331                         AC_DEFINE(HAVE_LOCKDEV,1,[Define if you have dev_lock/lockdev based locking.])
332                         lockdev_msg=yes
333                         SERIAL_LIBS=-llockdev
334                 ])
335         ])
336 fi
337 GP_CONFIG_MSG([lockdev locking],[${lockdev_msg}])
338
339 fi # have_serial
340
341 AC_SUBST([SERIAL_LIBS])
342
343
344 dnl ---------------------------------------------------------------------------
345 dnl libusb
346 dnl ---------------------------------------------------------------------------
347
348 dnl libusb 1 links against libpthread, but is loaded too late.
349 dnl we need to load libpthread directly.
350 AC_CHECK_LIB(pthread, pthread_create)
351
352 GP_CONFIG_MSG([USB ports])
353 GP_CHECK_LIBRARY([LIBUSB],[libusb],[>= 0.1.4],
354                 [usb.h],[usb_open],[
355         IOLIB_SUBDIRS="$IOLIB_SUBDIRS usb usbdiskdirect usbscsi"
356 ],[],
357                 [disable-explicitly],
358                 [http://libusb.sourceforge.net/]
359 )
360
361 dnl depends on libusb's availability
362 GP_UDEV([test "x$have_LIBUSB" = xyes])
363
364 dnl ---------------------------------------------------------------------------
365 dnl disk - hal and various stuff
366 dnl ---------------------------------------------------------------------------
367 AC_ARG_WITH([hal],
368         AS_HELP_STRING([--with-hal], [whether to enable HAL disk autodetection [default=yes]]),
369         ,with_hal=yes)
370
371 if test "x$with_hal" = "xyes"; then
372         have_hal=true
373         PKG_CHECK_MODULES(HAL, [dbus-1 >= 0.31 hal >= 0.5.0], 
374                                [have_hal=true], 
375                                [have_hal=false])
376         if test "x$have_hal" = "xtrue"; then
377            AC_SUBST(HAL_CFLAGS)
378            AC_SUBST(HAL_LIBS)
379            AC_DEFINE(HAVE_HAL,1,[defined if HAL is available])
380         fi
381 fi
382
383 AC_ARG_ENABLE([disk],
384         AS_HELP_STRING([--disable-disk], [enable the 'disk' port driver]),
385         ,enable_disk=yes)
386
387 dnl ---------------------------------------------------------------------------
388 dnl disk port also work everywhere, but its not really necessary
389 dnl ---------------------------------------------------------------------------
390 if test "x$enable_disk" = "xyes"; then
391         IOLIB_SUBDIRS="$IOLIB_SUBDIRS disk"
392 fi
393
394 dnl ---------------------------------------------------------------------------
395 dnl ptpip - works 'everywhere' with TCP/IP stack.
396 dnl number of supported cameras is however very small.
397 dnl ---------------------------------------------------------------------------
398 AC_ARG_ENABLE([ptpip],
399         AS_HELP_STRING([--disable-ptpip], [enable the 'ptpip' port driver for TCP/IP connected PTP cameras]),
400         ,enable_ptpip=yes)
401 if test "x$enable_ptpip" = "xyes"; then
402         IOLIB_SUBDIRS="$IOLIB_SUBDIRS ptpip"
403 fi
404
405
406 # ----------------------------------------------------------------------
407 # Define IOLIB stuff
408 # ----------------------------------------------------------------------
409
410 AC_SUBST(IOLIB_SUBDIRS)
411 AC_SUBST([iolibdir],["\$(libdir)/\$(PACKAGE_TARNAME)/\$(VERSION)"])
412 AM_CPPFLAGS="$AM_CPPFLAGS -DIOLIBS=\\\"${iolibdir}\\\""
413
414
415 dnl --------------------------------------------------------------------
416 dnl guess directory to install *.pc into
417 dnl --------------------------------------------------------------------
418 pkgconfigdir='${libdir}/pkgconfig'
419 AC_SUBST([pkgconfigdir])
420
421
422 dnl ----------------------------------------------------------------------
423 dnl GNU regex?
424 dnl ----------------------------------------------------------------------
425 AC_CHECK_FUNC(re_compile_pattern,
426               AC_DEFINE(HAVE_GNU_REGEX,1,[Define if you have GNU regex.])
427 )
428
429
430 dnl ----------------------------------------------------------------------
431 dnl disable debugging if requested
432 dnl ----------------------------------------------------------------------
433 AC_ARG_ENABLE([debug],
434   AS_HELP_STRING([--disable-debug],[do not include debugging code]),
435 [
436   if test "$enableval" = "no"; then
437     AC_DEFINE(DISABLE_DEBUGGING,1,[Define if you want to disabled debugging.])
438   fi
439 ])
440
441
442 # ----------------------------------------------------------------------
443 # gtk-doc?
444 # ----------------------------------------------------------------------
445 GP_CONFIG_MSG([Documentation])
446 GP_CHECK_DOC_DIR()dnl
447 GP_BUILD_GTK_DOCS()dnl
448
449
450 # Make sure that the *FLAGS given at ./configure time will be active by
451 # default in AM_*FLAGS
452 AM_CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
453 AM_CFLAGS="$AM_CFLAGS $CFLAGS"
454 AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
455 AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS"
456
457 dnl ---------------------------------------------------------------------------
458 dnl Turn on all warnings when using gcc
459 dnl ---------------------------------------------------------------------------
460 if test "$GCC" = "yes"; then
461         AM_CPPFLAGS="$AM_CPPFLAGS -Wall"
462         AM_CPPFLAGS="$AM_CPPFLAGS -Wmissing-declarations -Wmissing-prototypes"
463         AM_LDFLAGS="$AM_LDFLAGS -Wall"
464         # FIXME: Check for --enable-debug here
465         AM_CPPFLAGS="$AM_CPPFLAGS -g"
466         AM_LDFLAGS="$AM_LDFLAGS -g"
467 fi
468
469 # Activate internal code
470 AM_CPPFLAGS="$AM_CPPFLAGS -D_GPHOTO2_INTERNAL_CODE"
471
472 # Activate Samsung patch
473 AM_CPPFLAGS="$AM_CPPFLAGS -D_GPHOTO2_SAMSUNG_PATCH_"
474
475 # CPPFLAGS: C PreProcessor flags
476 AC_SUBST([AM_CPPFLAGS])
477 # CFLAGS: C compiler flags
478 AC_SUBST([AM_CFLAGS])
479 # CXXFLAGS: C++ compiler flags
480 AC_SUBST([AM_CXXFLAGS])
481 # LDFLAGS: Linker flags
482 AC_SUBST([AM_LDFLAGS])
483
484
485 # ---------------------------------------------------------------------------
486 # Create output files
487 # ---------------------------------------------------------------------------
488 AC_CONFIG_FILES([
489 Makefile
490 po/Makefile.in
491 libgphoto2_port/Makefile
492 libgphoto2_port.pc
493 libgphoto2_port-uninstalled.pc
494 serial/Makefile
495 usb/Makefile
496 usbdiskdirect/Makefile
497 usbscsi/Makefile
498 disk/Makefile
499 ptpip/Makefile
500 gphoto2-port-config
501 test/Makefile
502 doc/Makefile
503 m4/Makefile
504 ])
505 AC_OUTPUT
506
507 GP_CONFIG_OUTPUT
508
509 # End of file.