diff --git a/camlibs/Makefile.am b/camlibs/Makefile.am index 01a289cfa0..dcb27f2e08 100644 --- a/camlibs/Makefile.am +++ b/camlibs/Makefile.am @@ -73,8 +73,8 @@ camlib_ldflags += -export-symbols '$(top_srcdir)/camlibs/camlib.sym' camlib_ldflags += -rpath '$(camlibdir)' camlib_libadd = -camlib_libadd += $(top_builddir)/libgphoto2/libgphoto2.la -camlib_libadd += $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la +camlib_libadd += $(libgphoto2_la) +camlib_libadd += $(libgphoto2_port_la) camlib_cflags = diff --git a/configure.ac b/configure.ac index 090b754851..121e4e17d2 100644 --- a/configure.ac +++ b/configure.ac @@ -50,14 +50,15 @@ dnl libtool 2011-10-18 2.4.2 AM_SILENT_RULES([no]) +dnl Every compile example will be using the C language unless +dnl something else is said explicitly. +AC_LANG([C]) + + dnl Flag all GP_ strings in result as error unless specifically allowed. m4_pattern_forbid([^_?GP_])dnl -GP_CHECK_SHELL_ENVIRONMENT -GP_CONFIG_MSG([Build]) -GP_CONFIG_MSG([Source code location],[${srcdir}]) - dnl --------------------------------------------------------------------------- dnl Advanced information about versioning: dnl * "Writing shared libraries" by Mike Hearn @@ -100,6 +101,11 @@ AC_SUBST([LIBGPHOTO2_VERSION_INFO], [$LIBGPHOTO2_CURRENT:$LIBGPHOTO2_REVISION:$LIBGPHOTO2_AGE]) +GP_CHECK_SHELL_ENVIRONMENT +GP_CONFIG_MSG([Build]) +GP_CONFIG_MSG([Source code location], [${srcdir}]) + + dnl --------------------------------------------------------------------------- dnl Checks for programs. dnl --------------------------------------------------------------------------- @@ -211,17 +217,14 @@ dnl GP_CONDITIONAL_COMPILE_FLAGS([CFLAGS], [-Wno-stringop-truncation]) ])dnl GP_WITH_EMPTY_CONFDEFS_H -dnl Every compile example after here will be using the C language -AC_LANG([C]) - dnl --------------------------------------------------------------------------- dnl Turn on (almost) all warnings when using gcc dnl --------------------------------------------------------------------------- -if test "x$GCC" = "xyes"; then +AS_VAR_IF([GCC], [yes], [dnl AC_SUBST([NO_UNUSED_CFLAGS], [-Wno-unused]) -fi -AM_CONDITIONAL([HAVE_GCC], [test "x$GCC" = "xyes"]) +]) +AM_CONDITIONAL([HAVE_GCC], [test "x$GCC" = xyes]) # Activate internal code AM_CPPFLAGS="$AM_CPPFLAGS -D_GPHOTO2_INTERNAL_CODE" @@ -263,9 +266,9 @@ GP_LIBLTDL # report on compiler/libtool setup -GP_CONFIG_MSG([Compiler],[${CC}]) -GP_CONFIG_MSG([libltdl includes],[$LTDLINCL]) -GP_CONFIG_MSG([libltdl library],[$LIBLTDL]) +GP_CONFIG_MSG([Compiler], [${CC}]) +GP_CONFIG_MSG([libltdl includes], [$LTDLINCL]) +GP_CONFIG_MSG([libltdl library], [$LIBLTDL]) AC_DEFINE_UNQUOTED([HAVE_CC], ["$CC"], [The C compiler we are using]) @@ -344,7 +347,7 @@ AC_SUBST([LIBWS232_LIBS]) AC_ARG_WITH([ws232], [AS_HELP_STRING([--without-ws232], [Build without ws2_32 library (default: no)])]) -AS_IF([test "x$with_ws232" != "xno"], [dnl +AS_VAR_IF([with_ws232], [no], [], [dnl AC_CHECK_LIB([ws2_32], [WSAStartup], [dnl AC_CHECK_HEADER([winsock.h], [dnl AC_DEFINE([HAVE_LIBWS232], [1], @@ -354,42 +357,51 @@ AS_IF([test "x$with_ws232" != "xno"], [dnl ]) ]) ]) -GP_CONFIG_MSG([Winsocket support (for PTP/IP)],[${libws232_msg}]) +GP_CONFIG_MSG([Winsocket support (for PTP/IP)], [${libws232_msg}]) dnl --------------------------------------------------------------------------- dnl check for libxml2 dnl --------------------------------------------------------------------------- -GP_CHECK_LIBRARY([LIBXML2],[libxml-2.0],[>= 2.0], - [libxml/parser.h],[xmlFirstElementChild],[],[], - [default-on], - [http://xmlsoft.org] -) -GP_CONFIG_MSG([XML support for Olympus E series],[${have_LIBXML2}]) +GP_CHECK_LIBRARY([LIBXML2], [libxml-2.0], [>= 2.0], + [libxml/parser.h], [xmlFirstElementChild], [], [], + [default-on], + [http://xmlsoft.org]) +GP_CONFIG_MSG([XML support for Olympus E series], [${have_LIBXML2}]) -GP_CHECK_LIBRARY([LIBCURL],[libcurl],[>= 7.1], - [curl/curl.h],[curl_easy_init],[],[], - [default-on], - [https://www.curl.org] -) -GP_CONFIG_MSG([CURL support for Lumix Wifi],[${have_LIBCURL}]) +GP_CHECK_LIBRARY([LIBCURL], [libcurl], [>= 7.1], + [curl/curl.h], [curl_easy_init], [], [], + [default-on], + [https://www.curl.org]) +GP_CONFIG_MSG([CURL support for Lumix Wifi], [${have_LIBCURL}]) dnl --------------------------------------------------------------------------- dnl check for libgd dnl they call it "gdlib" ... confusing. dnl --------------------------------------------------------------------------- -GP_CHECK_LIBRARY([LIBGD],[gdlib],[>= 2.0],[gd.h],[gdImageCreateTrueColor],[ +GP_CHECK_LIBRARY([LIBGD], [gdlib], [>= 2.0], [gd.h], [gdImageCreateTrueColor], [dnl # gdlib-config --libs upstream does not include -lgd, but only the dependencies LIBGD_LIBS="-lgd $LIBGD_LIBS" - -],[],[default-on],[http://www.libgd.org/]) -GP_CONFIG_MSG([libGD conversion support],[${have_LIBGD}]) +], [], [default-on], [http://www.libgd.org/]) +GP_CONFIG_MSG([libGD conversion support], [${have_LIBGD}]) dnl --------------------------------------------------------------------------- dnl Checks for header files. dnl --------------------------------------------------------------------------- AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS([sys/param.h sys/mman.h sys/select.h locale.h memory.h getopt.h unistd.h mcheck.h limits.h sys/time.h langinfo.h]) +AC_CHECK_HEADERS([m4_normalize([ + getopt.h + langinfo.h + limits.h + locale.h + mcheck.h + memory.h + sys/mman.h + sys/param.h + sys/select.h + sys/time.h + unistd.h +])]) dnl If sys/mman.h is present, check whether mmap requires the mman dnl library (see camlibs/st2205/st2205.c st2205_malloc_page_aligned()). @@ -416,7 +428,25 @@ dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T dnl Checks for library functions. -AC_CHECK_FUNCS([getenv getopt getopt_long mkdir setenv strdup strncpy strcpy snprintf sprintf vsnprintf gmtime_r statvfs localtime_r lstat inet_aton rand_r]) +AC_CHECK_FUNCS([m4_normalize([ + getenv + getopt + getopt_long + gmtime_r + inet_aton + localtime_r + lstat + mkdir + rand_r + setenv + snprintf + sprintf + statvfs + strcpy + strdup + strncpy + vsnprintf +])]) dnl Find out how to get struct tm AC_STRUCT_TM @@ -439,7 +469,12 @@ tm.tm_gmtoff; AC_MSG_RESULT([no]) ]) -AC_CHECK_HEADERS([sys/mount.h sys/statvfs.h sys/user.h sys/vfs.h], [], [], [ +AC_CHECK_HEADERS([m4_normalize([ + sys/mount.h + sys/statvfs.h + sys/user.h + sys/vfs.h +])], [], [], [dnl #include #if HAVE_SYS_PARAM_H # include @@ -478,9 +513,11 @@ dnl --------------------------------------------------------------------------- AC_SUBST([PACKAGE_TARNAME]) -if test "x${utilsdir}" = "x"; then utilsdir="\${libdir}/\${PACKAGE_TARNAME}"; fi -AC_ARG_VAR([utilsdir],[Directory where utilities like print-camera-list will be installed]) -AC_SUBST([utilsdir]) +AC_ARG_VAR([utilsdir], + [Directory where utilities like print-camera-list will be installed]) +AS_VAR_IF([utilsdir], [], [dnl + utilsdir="\${libdir}/\${PACKAGE_TARNAME}" +]) GP_UDEV([true]) @@ -600,19 +637,22 @@ GPKG_CHECK_LINUX()dnl Check whether to package for a linux system dnl -------------------------------------------------------------------- dnl guess directory to install *.pc into dnl -------------------------------------------------------------------- -pkgconfigdir='${libdir}/pkgconfig' -AC_SUBST([pkgconfigdir]) +AC_ARG_VAR([pkgconfigdir], + [where to install pkg-config *.pc files to]) +AS_VAR_IF([pkgconfigdir], [], [dnl + pkgconfigdir='${libdir}/pkgconfig' +]) dnl --------------------------------------------------------------------------- dnl libexif: The CameraFilesystem can use libexif for extracting thumbnails dnl out of EXIF data. Similarly, it can extract the mtime of -dnl a file. +dnl a file. dnl libexif is available from dnl http://www.sourceforge.net/projects/libexif dnl --------------------------------------------------------------------------- -GP_CHECK_LIBRARY([LIBEXIF],[libexif],[>= 0.6.13], - [libexif/exif-data.h],[exif_data_new],[ +GP_CHECK_LIBRARY([LIBEXIF], [libexif], [>= 0.6.13], + [libexif/exif-data.h], [exif_data_new], [dnl AC_MSG_CHECKING([whether we use a version of libexif with ExifData.ifd[[]]]) # Check for libexif version dnl FIXME: Use AC_CHECK_MEMBER? @@ -637,22 +677,32 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ AC_MSG_RESULT([no]) ]) CPPFLAGS="$CPPFLAGS_save" -],[],[default-on],[http://www.sourceforge.net/projects/libexif])dnl +], [], [default-on], [https://github.com/libexif/libexif])dnl + + +dnl --------------------------------------------------------------------------- +dnl Make it easier to possibly move the libraries around +dnl --------------------------------------------------------------------------- + +AC_SUBST([libgphoto2_port_la], + ['${top_builddir}/libgphoto2_port/libgphoto2_port/libgphoto2_port.la']) +AC_SUBST([libgphoto2_la], + ['${top_builddir}/libgphoto2/libgphoto2.la']) dnl --------------------------------------------------------------------------- dnl Configure subprojects dnl --------------------------------------------------------------------------- -if test -d "$srcdir/libgphoto2_port"; then +AS_IF([test -d "$srcdir/libgphoto2_port"], [dnl AC_CONFIG_SUBDIRS([libgphoto2_port]) -else +], [dnl AC_MSG_ERROR([ ****************************************************** *** Hey, where have you hidden my libgphoto2_port? *** *** I needed that! *** ****************************************************** ]) -fi +]) # --------------------------------------------------------------------------- @@ -684,7 +734,7 @@ AC_CONFIG_FILES([ ]) AC_OUTPUT -AS_IF([test "x$CDPATH" != "x"], [dnl +AS_VAR_IF([CDPATH], [], [], [dnl AC_MSG_WARN([ #=========================================================# diff --git a/examples/Makefile.am b/examples/Makefile.am index 43a4f49cf8..0b0a0bcb13 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -35,8 +35,9 @@ best_iso_SOURCES = best-iso.c sample_justfocus_SOURCES = samples.h sample-justfocus.c context.c focus.c # sample_libfuzz_SOURCES = samples.h sample-libfuzz.c context.c autodetect.c -LDADD = $(top_builddir)/libgphoto2/libgphoto2.la \ - $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la \ +LDADD = \ + $(libgphoto2_la) \ + $(libgphoto2_port_la) \ $(LIBLTDL) \ $(LIBEXIF_LIBS) \ $(INTLLIBS) diff --git a/libgphoto2/Makefile.am b/libgphoto2/Makefile.am index a3328d56d8..2836e05274 100644 --- a/libgphoto2/Makefile.am +++ b/libgphoto2/Makefile.am @@ -53,7 +53,7 @@ libgphoto2_la_LDFLAGS += -export-symbols $(srcdir)/libgphoto2.sym libgphoto2_la_LDFLAGS += -version-info @LIBGPHOTO2_VERSION_INFO@ -libgphoto2_la_LIBADD += $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la +libgphoto2_la_LIBADD += $(libgphoto2_port_la) # The libtool docs describe these params, but they don't build. # "-dlopen" self \ diff --git a/libgphoto2_port/Makefile.am b/libgphoto2_port/Makefile.am index 8f783057fb..ecc531e728 100644 --- a/libgphoto2_port/Makefile.am +++ b/libgphoto2_port/Makefile.am @@ -52,12 +52,12 @@ iolib_LTLIBRARIES = $(IOLIB_LTLIST) ######################################################################## # Define the compile/link/etc. flags common to all iolibs in one place, # i.e. here. -iolib_dependencies = $(top_srcdir)/iolib.sym +iolib_dependencies = $(top_srcdir)/iolib.sym $(libgphoto2_port_la) iolib_ldflags = -module -no-undefined -avoid-version \ -export-dynamic \ -export-symbols $(top_srcdir)/iolib.sym \ -rpath '$(iolibdir)' -iolib_libadd = $(top_builddir)/libgphoto2_port/libgphoto2_port.la +iolib_libadd = $(libgphoto2_port_la) AM_CPPFLAGS += -I$(top_srcdir) diff --git a/libgphoto2_port/configure.ac b/libgphoto2_port/configure.ac index 9dd7fcbaac..9867432bc7 100644 --- a/libgphoto2_port/configure.ac +++ b/libgphoto2_port/configure.ac @@ -23,6 +23,8 @@ AM_INIT_AUTOMAKE([ AM_SILENT_RULES([no]) +dnl Every compile example will be using the C language unless +dnl something else is said explicitly. AC_LANG([C]) @@ -102,10 +104,10 @@ GP_LIBLTDL # report on compiler/libtool setup GP_CONFIG_MSG([Build]) -GP_CONFIG_MSG([Source directory],[${srcdir}]) -GP_CONFIG_MSG([Compiler],[${CC}]) -GP_CONFIG_MSG([libltdl includes],[$LTDLINCL]) -GP_CONFIG_MSG([libltdl library],[$LIBLTDL]) +GP_CONFIG_MSG([Source directory], [${srcdir}]) +GP_CONFIG_MSG([Compiler], [${CC}]) +GP_CONFIG_MSG([libltdl includes], [$LTDLINCL]) +GP_CONFIG_MSG([libltdl library], [$LIBLTDL]) AC_DEFINE_UNQUOTED([HAVE_CC], ["$CC"], [The C compiler we're using]) @@ -140,9 +142,9 @@ AC_CHECK_FUNC([gettext], [gettext_without_libintl=true]) # we don't have to check for gettext in libintl. Otherwise # we may even require libintl. dnl AC_CHECK_LIB(intl, gettext, [LIBS="$LIBS -lintl"]) -if test "x$gettext_without_libintl" != xtrue && test "x$USE_NLS" = xyes; then +AS_IF([test "x$gettext_without_libintl" != xtrue && test "x$USE_NLS" = xyes], [dnl AC_CHECK_LIB([intl], [gettext], [INTLLIBS="$INTLLIBS -lintl"]) -fi +]) dnl --------------------------------------------------------------------------- @@ -154,11 +156,32 @@ AC_HEADER_STDC AC_C_INLINE([]) AC_C_CONST([]) -AC_CHECK_HEADERS([stdlib.h unistd.h stdio.h fcntl.h errno.h sys/time.h \ - sys/param.h sys/select.h termios.h sgetty.h ttold.h ioctl-types.h \ - fcntl.h sgtty.h sys/ioctl.h sys/time.h termio.h unistd.h \ - endian.h byteswap.h asm/io.h mntent.h sys/mntent.h sys/mnttab.h \ - scsi/sg.h limits.h sys/file.h]) +AC_CHECK_HEADERS([m4_normalize([ + asm/io.h + byteswap.h + endian.h + errno.h + fcntl.h + ioctl-types.h + limits.h + mntent.h + scsi/sg.h + sgetty.h + sgtty.h + stdio.h + stdlib.h + sys/file.h + sys/ioctl.h + sys/mntent.h + sys/mnttab.h + sys/param.h + sys/select.h + sys/time.h + termio.h + termios.h + ttold.h + unistd.h +])]) dnl FIXME: Provide regex.h with the corresponding object code for dnl platforms which do not have it, e.g. Windows. @@ -191,19 +214,37 @@ mt.mnt_mountp; ]) - dnl Checks for library functions. -AC_CHECK_FUNCS([setmntent endmntent strerror snprintf vsnprintf flock]) +AC_CHECK_FUNCS([m4_normalize([ + endmntent + flock + setmntent + snprintf + strerror + vsnprintf +])]) dnl Check if TIOCM_RTS is included in one of several possible files -AC_TRY_COMPILE([#include ], [int foo = TIOCM_RTS;], - AC_DEFINE([HAVE_RTS_IOCTL], [1], [Define if you have TIOCM_RTS.])) -AC_TRY_COMPILE([#include ], [int foo = TIOCM_RTS;], - AC_DEFINE([HAVE_RTS_IOCTL], [1], [Define if you have TIOCM_RTS.])) -AC_TRY_COMPILE([#include ], [int foo = TIOCM_RTS;], - AC_DEFINE([HAVE_RTS_IOCTL], [1], [Define if you have TIOCM_TRS.])) -AC_TRY_COMPILE([#include ], [int foo = TIOCM_RTS;], - AC_DEFINE([HAVE_RTS_IOCTL], [1], [Define if you have TIOCM_TRS.])) +gp_found_tiocm_rts=no +AC_DEFUN([GP_TRY_TIOCM_RTS], [dnl + AS_VAR_IF([gp_found_tiocm_rts], [no], [dnl + AC_COMPILE_IFELSE([dnl + AC_LANG_PROGRAM([[#include <$1>]], [[ + int foo = TIOCM_RTS; + ]]) + ], [dnl + gp_found_tiocm_rts=yes + ]) + ]) +])dnl +GP_TRY_TIOCM_RTS([termios.h]) +GP_TRY_TIOCM_RTS([termio.h]) +GP_TRY_TIOCM_RTS([ioctl-types.h]) +GP_TRY_TIOCM_RTS([sys/ioctl.h]) +AS_VAR_IF([gp_found_tiocm_rts], [yes], [dnl + AC_DEFINE([HAVE_RTS_IOCTL], [1], + [Define if you have TIOCM_TRS.]) +]) # Check for va_copy() GP_VA_COPY @@ -211,12 +252,12 @@ GP_VA_COPY dnl --------------------------------------------------------------------------- dnl libexif: The virtual usb camera driver can use libexif for extracting thumbnails dnl out of EXIF data. Similarly, it can extract the mtime of -dnl a file. +dnl a file. dnl libexif is available from dnl http://www.sourceforge.net/projects/libexif dnl --------------------------------------------------------------------------- -GP_CHECK_LIBRARY([LIBEXIF],[libexif],[>= 0.6.13], - [libexif/exif-data.h],[exif_data_new],[ +GP_CHECK_LIBRARY([LIBEXIF], [libexif], [>= 0.6.13], + [libexif/exif-data.h], [exif_data_new], [dnl AC_MSG_CHECKING([whether we use a version of libexif with ExifData.ifd[[]]]) # Check for libexif version dnl FIXME: Use AC_CHECK_MEMBER? @@ -241,7 +282,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ AC_MSG_RESULT([no]) ]) CPPFLAGS="$CPPFLAGS_save" -],[],[default-on],[http://www.sourceforge.net/projects/libexif])dnl +], [], [default-on], [https://github.com/libexif/libexif])dnl @@ -254,34 +295,30 @@ try_ttylock=true try_lockdev=true try_resmgr=true -if test "$ac_cv_header_sgtty_h" = "no" -then +AS_VAR_IF([ac_cv_header_sgtty_h], [no], [dnl have_serial=false serial_msg=no -fi +]) AC_ARG_ENABLE([serial], [AS_HELP_STRING([--disable-serial], [do not compile in SERIAL support])], [dnl - if test x$enableval = xno; then + AS_VAR_IF([enableval], [no], [dnl have_serial=false serial_msg=no try_ttylock=false try_lockdev=false try_resmgr=false - fi + ]) ]) -if $have_serial; then +AS_IF([$have_serial], [dnl IOLIB_LIST="$IOLIB_LIST serial" AC_DEFINE([HAVE_SERIAL], [1], [Whether you have serial support enabled]) -fi +]) GP_CONFIG_MSG([Serial ports]) -GP_CONFIG_MSG([Serial support],[$serial_msg]) - -SERIAL_LIBS="" -if $have_serial; then +GP_CONFIG_MSG([Serial support], [$serial_msg]) dnl ----------------------------------------- dnl Serial port locking: We try to use either @@ -294,20 +331,27 @@ AC_ARG_ENABLE([$1], [AS_HELP_STRING([--disable-][$1], [do not use ][$1][ library])dnl ], [dnl - if test x$enableval = xno; then - try_[$1]=false - fi + AS_VAR_IF([enableval], [no], [dnl + try_[$1]=false + ]) ]) ])dnl + +SERIAL_LIBS="" +AS_IF([$have_serial], [dnl + GP_SERLOCK([ttylock])dnl GP_SERLOCK([lockdev])dnl ttylock_msg=no -if $try_ttylock; then +AS_IF([$try_ttylock], [dnl AC_CHECK_HEADER([lockdev.h]) AC_CHECK_HEADER([ttylock.h], [dnl lockdev_result="no" - AC_TRY_LINK([#include ],[ttylocked ("/dev/foo");],[ + AC_LINK_IFELSE([dnl + AC_LANG_PROGRAM([[#include + ]], [[ttylocked("/dev/foo");]]) + ], [dnl lockdev_result="no" AC_DEFINE([HAVE_TTYLOCK], [1], [Define if you have ttylock based tty locking.]) @@ -315,7 +359,10 @@ if $try_ttylock; then try_lockdev=false, save_LIBS="$LIBS" LIBS="$LIBS -llockdev" - AC_TRY_LINK([#include ],[ttylocked ("/dev/foo");],[ + AC_LINK_IFELSE([dnl + AC_LANG_PROGRAM([[#include + ]], [[ttylocked ("/dev/foo");]]) + ], [dnl lockdev_result="yes" AC_DEFINE([HAVE_TTYLOCK], [1], [Define if you have ttylock based tty locking.]) @@ -331,11 +378,11 @@ if $try_ttylock; then # include #endif ]) -fi -GP_CONFIG_MSG([ttylock locking],[${ttylock_msg}]) +]) +GP_CONFIG_MSG([ttylock locking], [${ttylock_msg}]) lockdev_msg=no -if $try_lockdev; then +AS_IF([$try_lockdev], [dnl AC_CHECK_LIB([lockdev], [dev_lock], [dnl AC_CHECK_HEADER([lockdev.h], [dnl AC_DEFINE([HAVE_LOCKDEV], [1], @@ -344,10 +391,10 @@ if $try_lockdev; then SERIAL_LIBS=-llockdev ]) ]) -fi -GP_CONFIG_MSG([lockdev locking],[${lockdev_msg}]) +]) +GP_CONFIG_MSG([lockdev locking], [${lockdev_msg}]) -fi # have_serial +])dnl $have_serial AC_SUBST([SERIAL_LIBS]) @@ -365,8 +412,8 @@ dnl --------------------------------------------------------------------------- dnl libusb1 dnl --------------------------------------------------------------------------- GP_CONFIG_MSG([USB ports]) -GP_CHECK_LIBRARY([LIBUSB1],[libusb-1.0],[>= 1.0.0], - [libusb.h],[libusb_init],[ +GP_CHECK_LIBRARY([LIBUSB1], [libusb-1.0], [>= 1.0.0], + [libusb.h], [libusb_init], [dnl case "$host" in *-linux*) IOLIB_LIST="$IOLIB_LIST usb1 usbdiskdirect usbscsi" @@ -412,27 +459,30 @@ GP_CHECK_LIBRARY([LIBUSB1],[libusb-1.0],[>= 1.0.0], [default-on], [http://libusb.sourceforge.net/] ) + # We select the old libusb 0 only if we are not doing libusb1 -GP_CHECK_LIBRARY([LIBUSB],[libusb],[>= 0.1.5], - [usb.h],[usb_open],[ +GP_CHECK_LIBRARY([LIBUSB], [libusb], [>= 0.1.5], + [usb.h], [usb_open], [dnl case "$host" in *-*-mingw* | *-*-cygwin* | *-*-msvc* ) dnl Windows itself has usb.h we mis-detect, in that case remove access to the other usb.h IOLIB_LIST="$IOLIB_LIST usb" ;; *-linux*) - if test "x$have_LIBUSB1" != xyes; then + AS_VAR_IF([have_LIBUSB1], [yes], [dnl + GP_CONFIG_MSG([libusb0 support], + [detected, but disabled (libusb1 support is enabled)]) + ], [dnl IOLIB_LIST="$IOLIB_LIST usb usbdiskdirect usbscsi" - else - GP_CONFIG_MSG([libusb0 support],[detected, but disabled (libusb1 support is enabled)]) - fi + ]) ;; *) - if test "x$have_LIBUSB1" != xyes; then + AS_VAR_IF([have_LIBUSB1], [yes], [dnl + GP_CONFIG_MSG([libusb0 support], + [detected, but disabled (libusb1 support is enabled)]) + ], [dnl IOLIB_LIST="$IOLIB_LIST usb" - else - GP_CONFIG_MSG([libusb0 support],[detected, but disabled (libusb1 support is enabled)]) - fi + ]) ;; esac ], [], @@ -450,23 +500,24 @@ AC_ARG_ENABLE([disk], [enable_disk=yes]) dnl disk port also works everywhere, but it's not really necessary -if test "x$enable_disk" = "xyes"; then +AS_VAR_IF([enable_disk], [yes], [dnl IOLIB_LIST="$IOLIB_LIST disk" -fi +]) AC_ARG_ENABLE([vusb], [AS_HELP_STRING([--enable-vusb], [enable the 'vusb' virtual USB port driver])], [], [dnl enable_vusb=no - GP_CONFIG_MSG([virtual USB support],[disabled, no virtual PTP test camera]) + GP_CONFIG_MSG([virtual USB support], + [disabled, no virtual PTP test camera]) ] ) dnl disk port also works everywhere, but it's not really necessary -if test "x$enable_vusb" = "xyes"; then +AS_VAR_IF([enable_vusb], [yes], [dnl IOLIB_LIST="$IOLIB_LIST vusb" -fi +]) AC_ARG_ENABLE([ptpip], [AS_HELP_STRING([--disable-ptpip], @@ -546,10 +597,10 @@ GP_BUILD_GTK_DOCS()dnl dnl --------------------------------------------------------------------------- dnl Turn on all warnings when using gcc dnl --------------------------------------------------------------------------- -if test "$GCC" = "yes"; then +AS_VAR_IF([GCC], [yes], [dnl CFLAGS="$CFLAGS -Wall" CFLAGS="$CFLAGS -Wmissing-declarations -Wmissing-prototypes" -fi +]) # Activate internal code AM_CPPFLAGS="$AM_CPPFLAGS -D_GPHOTO2_INTERNAL_CODE" @@ -564,6 +615,14 @@ AC_SUBST([AM_CXXFLAGS]) AC_SUBST([AM_LDFLAGS]) +dnl --------------------------------------------------------------------------- +dnl Make it easier to possibly move the libraries around +dnl --------------------------------------------------------------------------- + +AC_SUBST([libgphoto2_port_la], + ['${top_builddir}/libgphoto2_port/libgphoto2_port.la']) + + # --------------------------------------------------------------------------- # Create output files # --------------------------------------------------------------------------- diff --git a/libgphoto2_port/gphoto-m4/gp-byteorder.m4 b/libgphoto2_port/gphoto-m4/gp-byteorder.m4 index d7810d68b7..630df655c8 100644 --- a/libgphoto2_port/gphoto-m4/gp-byteorder.m4 +++ b/libgphoto2_port/gphoto-m4/gp-byteorder.m4 @@ -46,9 +46,9 @@ fi # We're only interested in the target CPU, but it's not always set effective_target="$target" -if test "x$effective_target" = xNONE || test "x$effective_target" = x ; then +AS_IF([test "x$effective_target" = xNONE || test "x$effective_target" = x], [dnl effective_target="$host" -fi +]) AC_SUBST(effective_target) m4_pattern_allow([GP_BYTEORDER_H])dnl diff --git a/libgphoto2_port/gphoto-m4/gp-check-library.m4 b/libgphoto2_port/gphoto-m4/gp-check-library.m4 index 9232bc4829..161342ac1b 100644 --- a/libgphoto2_port/gphoto-m4/gp-check-library.m4 +++ b/libgphoto2_port/gphoto-m4/gp-check-library.m4 @@ -1,13 +1,13 @@ # gp-check-library.m4 - generic library check -*- Autoconf -*- -# serial 14 +# serial 15 dnl | Increment the above serial number every time you edit this file. dnl | When it finds multiple m4 files with the same name, dnl | aclocal will use the one with the highest serial. dnl -dnl @synopsis GP_CHECK_LIBRARY([VARNAMEPART],[libname],[VERSION-REQUIREMENT], -dnl [headername],[functionname], -dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], -dnl [OPTIONAL-REQUIRED-ETC],[WHERE-TO-GET-IT]) +dnl @synopsis GP_CHECK_LIBRARY([VARNAMEPART], [libname], [VERSION-REQUIREMENT], +dnl [headername], [functionname], +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +dnl [OPTIONAL-REQUIRED-ETC], [WHERE-TO-GET-IT]) dnl dnl Checks for the presence of a certain library. dnl @@ -346,7 +346,8 @@ if test "x${[userdef_][$1]}" = "xno" && test "x${[have_][$1]}" = "xyes"; then AC_MSG_CHECKING([for function ][$5][ in ][$2]) LIBS_save="$LIBS" LIBS="${[$1]_LIBS}" - AC_TRY_LINK_FUNC([$5],[],[have_][$1][=no]) + AC_LINK_IFELSE([AC_LANG_CALL([], [$5])], + [], [have_][$1][=no]) LIBS="$LIBS_save" AC_MSG_RESULT([${[have_][$1]}]) fi @@ -404,14 +405,14 @@ fi AM_CONDITIONAL([HAVE_][$1], [test "x$have_[$1]" = "xyes"]) if test "x$have_[$1]" = "xyes"; then AC_DEFINE([HAVE_][$1], 1, [whether we compile with ][$2][ support]) - GP_CONFIG_MSG([$2],[yes])dnl + GP_CONFIG_MSG([$2], [yes])dnl AC_MSG_CHECKING([$2][ library flags]) AC_MSG_RESULT(["${[$1][_LIBS]}"]) AC_MSG_CHECKING([$2][ cpp flags]) AC_MSG_RESULT(["${[$1][_CFLAGS]}"]) else [REQUIREMENTS_FOR_][$1][=] - GP_CONFIG_MSG([$2],[no])dnl + GP_CONFIG_MSG([$2], [no])dnl fi dnl AC_SUBST is done implicitly by AC_ARG_VAR above. dnl AC_SUBST([$1][_LIBS]) diff --git a/libgphoto2_port/gphoto-m4/gp-check-popt.m4 b/libgphoto2_port/gphoto-m4/gp-check-popt.m4 index a8b3718f28..5ae1a68877 100644 --- a/libgphoto2_port/gphoto-m4/gp-check-popt.m4 +++ b/libgphoto2_port/gphoto-m4/gp-check-popt.m4 @@ -231,8 +231,8 @@ AC_MSG_RESULT([${have_popt}]) GP_CONFIG_MSG([use popt library], [${have_popt}]) if test "$have_popt" = "yes"; then AC_DEFINE([HAVE_POPT],[1],[whether the popt library is available]) - GP_CONFIG_MSG([popt libs],[${POPT_LIBS}]) - GP_CONFIG_MSG([popt cppflags],[${POPT_CFLAGS}]) + GP_CONFIG_MSG([popt libs], [${POPT_LIBS}]) + GP_CONFIG_MSG([popt cppflags], [${POPT_CFLAGS}]) fi AM_CONDITIONAL([HAVE_POPT],[test "$have_popt" = "yes"]) ])dnl diff --git a/libgphoto2_port/gphoto-m4/gp-config-msg.m4 b/libgphoto2_port/gphoto-m4/gp-config-msg.m4 index c81d88af49..612adbfaac 100644 --- a/libgphoto2_port/gphoto-m4/gp-config-msg.m4 +++ b/libgphoto2_port/gphoto-m4/gp-config-msg.m4 @@ -12,7 +12,7 @@ dnl explicitly set the LHS width to the given value dnl dnl GP_CONFIG_MSG dnl empty output line -dnl GP_CONFIG_MSG([LHS],[RHS]) +dnl GP_CONFIG_MSG([LHS], [RHS]) dnl formatted output line "LHS: RHS" dnl dnl GP_CONFIG_OUTPUT @@ -23,11 +23,11 @@ dnl dnl Example usage: dnl dnl GP_CONFIG_INIT -dnl GP_CONFIG_MSG([Source code location],[${srcdir}]) -dnl GP_CONFIG_MSG([Compiler],[${CC}]) +dnl GP_CONFIG_MSG([Source code location], [${srcdir}]) +dnl GP_CONFIG_MSG([Compiler], [${CC}]) dnl GP_CONFIG_MSG -dnl GP_CONFIG_MSG([Feature foo],[${foo}]) -dnl GP_CONFIG_MSG([Location of bar],[${bar}]) +dnl GP_CONFIG_MSG([Feature foo], [${foo}]) +dnl GP_CONFIG_MSG([Location of bar], [${bar}]) dnl [...] dnl AC_OUTPUT dnl GP_CONFIG_OUTPUT @@ -86,7 +86,7 @@ if test "x$subdirs" != "x"; then _subdirs="$_subdirs $ssd" fi done - GP_CONFIG_MSG([Subprojects],[${_subdirs}])dnl + GP_CONFIG_MSG([Subprojects], [${_subdirs}])dnl fi ])dnl dnl diff --git a/libgphoto2_port/gphoto-m4/gp-documentation.m4 b/libgphoto2_port/gphoto-m4/gp-documentation.m4 index 45f44b344f..8177670d47 100644 --- a/libgphoto2_port/gphoto-m4/gp-documentation.m4 +++ b/libgphoto2_port/gphoto-m4/gp-documentation.m4 @@ -36,7 +36,7 @@ if $try_gtkdoc; then fi fi AM_CONDITIONAL([ENABLE_GTK_DOC], [$have_gtkdoc]) -GP_CONFIG_MSG([build API docs with gtk-doc],[$gtkdoc_msg]) +GP_CONFIG_MSG([build API docs with gtk-doc], [$gtkdoc_msg]) apidocdir="${htmldir}/api" AC_SUBST([apidocdir]) diff --git a/libgphoto2_port/gphoto-m4/gp-va-copy.m4 b/libgphoto2_port/gphoto-m4/gp-va-copy.m4 index 0ae17f39a0..2a7714ddab 100644 --- a/libgphoto2_port/gphoto-m4/gp-va-copy.m4 +++ b/libgphoto2_port/gphoto-m4/gp-va-copy.m4 @@ -23,38 +23,43 @@ dnl #endif dnl AC_DEFUN([GP_VA_COPY],[dnl dnl -AC_CHECK_HEADER([stdarg.h],[],[ +AC_CHECK_HEADER([stdarg.h], [], [dnl AC_MSG_ERROR([ Building $PACKAGE_NAME requires . ]) ]) dnl have_va_copy=no -AC_TRY_LINK([ - #include -],[ - va_list a,b; - va_copy(a,b); -],[ - have_va_copy="va_copy" -],[ - AC_TRY_LINK([ - #include - ],[ - va_list a,b; - __va_copy(a,b); - ],[ - have_va_copy="__va_copy" - AC_DEFINE([va_copy],[__va_copy],[__va_copy() was the originally proposed name]) - ]) +AS_VAR_IF([have_va_copy], [no], [dnl + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[#include ]], [[ + va_list a,b; + va_copy(a,b); + ]]) + ], [dnl + have_va_copy="va_copy" + ]) +]) +AS_VAR_IF([have_va_copy], [no], [dnl + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[#include ]], [[ + va_list a,b; + __va_copy(a,b); + ]]) + ], [dnl + have_va_copy="__va_copy" + AC_DEFINE([va_copy], [__va_copy], + [__va_copy() was the originally proposed name]) + ]) ]) dnl AC_MSG_CHECKING([for va_copy() or replacement]) AC_MSG_RESULT([$have_va_copy]) dnl -if test "x$have_va_copy" != "xno"; then - AC_DEFINE([HAVE_VA_COPY],1,[Whether we have the va_copy() function]) -fi +AS_VAR_IF([have_va_copy], [no], [], [dnl + AC_DEFINE([HAVE_VA_COPY], [1], + [Whether we have the va_copy() function]) +]) ])dnl dnl dnl diff --git a/libgphoto2_port/tests/Makefile.am b/libgphoto2_port/tests/Makefile.am index 7b89036453..a682e24b0a 100644 --- a/libgphoto2_port/tests/Makefile.am +++ b/libgphoto2_port/tests/Makefile.am @@ -18,7 +18,7 @@ AM_CPPFLAGS += -I$(top_srcdir) noinst_PROGRAMS += test-gp-port test_gp_port_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL) $(CPPFLAGS) test_gp_port_SOURCES = test-gp-port.c -test_gp_port_LDADD = $(top_builddir)/libgphoto2_port/libgphoto2_port.la +test_gp_port_LDADD = $(libgphoto2_port_la) test_gp_port_LDADD += $(LIBLTDL) $(INTLLIBS) TESTS += test-port-list @@ -27,7 +27,7 @@ check_PROGRAMS += test-port-list noinst_PROGRAMS += test-port-list test_port_list_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL) $(CPPFLAGS) test_port_list_SOURCES = test-port-list.c -test_port_list_LDADD = $(top_builddir)/libgphoto2_port/libgphoto2_port.la +test_port_list_LDADD = $(libgphoto2_port_la) test_port_list_LDADD += $(LIBLTDL) $(INTLLIBS) include $(top_srcdir)/installcheck.mk diff --git a/packaging/generic/Makefile.am b/packaging/generic/Makefile.am index 0b547a23be..2e9482d98c 100644 --- a/packaging/generic/Makefile.am +++ b/packaging/generic/Makefile.am @@ -8,7 +8,7 @@ AM_CPPFLAGS += -I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/libgphoto2_por print_camera_list_SOURCES = print-camera-list.c print_camera_list_LDADD = \ - $(top_builddir)/libgphoto2/libgphoto2.la \ - $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la \ + $(libgphoto2_la) \ + $(libgphoto2_port_la) \ $(LIBLTDL) \ $(LIBEXIF_LIBS) diff --git a/tests/Makefile.am b/tests/Makefile.am index d87bc3d61e..5e5a51c291 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -46,8 +46,8 @@ TESTS += test-endian check_PROGRAMS += test-endian test_endian_SOURCES = test-endian.c test_endian_LDADD = \ - $(top_builddir)/libgphoto2/libgphoto2.la \ - $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la \ + $(libgphoto2_la) \ + $(libgphoto2_port_la) \ $(LIBLTDL) \ $(LIBEXIF_LIBS) \ $(INTLLIBS) @@ -57,8 +57,8 @@ test_endian_LDADD = \ noinst_PROGRAMS += print-libgphoto2-version print_libgphoto2_version_SOURCES = print-libgphoto2-version.c print_libgphoto2_version_LDADD = -print_libgphoto2_version_LDADD += $(top_builddir)/libgphoto2/libgphoto2.la -print_libgphoto2_version_LDADD += $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la +print_libgphoto2_version_LDADD += $(libgphoto2_la) +print_libgphoto2_version_LDADD += $(libgphoto2_port_la) print_libgphoto2_version_LDADD += $(LIBLTDL) print_libgphoto2_version_LDADD += $(LIBEXIF_LIBS) print_libgphoto2_version_LDADD += $(INTLLIBS) @@ -68,8 +68,8 @@ print_libgphoto2_version_LDADD += $(INTLLIBS) noinst_PROGRAMS += test-gphoto2 test_gphoto2_SOURCES = test-gphoto2.c test_gphoto2_LDADD = \ - $(top_builddir)/libgphoto2/libgphoto2.la \ - $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la \ + $(libgphoto2_la) \ + $(libgphoto2_port_la) \ $(LIBLTDL) \ $(LIBEXIF_LIBS) \ $(INTLLIBS) @@ -79,8 +79,8 @@ test_gphoto2_LDADD = \ noinst_PROGRAMS += test-filesys test_filesys_SOURCES = test-filesys.c test_filesys_LDADD = \ - $(top_builddir)/libgphoto2/libgphoto2.la \ - $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la \ + $(libgphoto2_la) \ + $(libgphoto2_port_la) \ $(LIBLTDL) \ $(LIBEXIF_LIBS) \ $(INTLLIBS) @@ -92,8 +92,8 @@ INSTALL_TESTS += test-camera-list check_PROGRAMS += test-camera-list test_camera_list_SOURCES = test-camera-list.c test_camera_list_LDADD = \ - $(top_builddir)/libgphoto2/libgphoto2.la \ - $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la \ + $(libgphoto2_la) \ + $(libgphoto2_port_la) \ $(LIBLTDL) \ $(LIBEXIF_LIBS) \ $(INTLLIBS) @@ -102,8 +102,8 @@ test_camera_list_LDADD = \ TESTS += test-init-localedir check_PROGRAMS += test-init-localedir test_init_localedir_LDADD = -test_init_localedir_LDADD += $(top_builddir)/libgphoto2/libgphoto2.la -test_init_localedir_LDADD += $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la +test_init_localedir_LDADD += $(libgphoto2_la) +test_init_localedir_LDADD += $(libgphoto2_port_la) test_init_localedir_LDADD += $(LIBLTDL) test_init_localedir_LDADD += $(LIBEXIF_LIBS) test_init_localedir_LDADD += $(INTLLIBS)