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