summaryrefslogtreecommitdiff
path: root/gphoto-m4
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2015-08-01 13:04:09 +0200
committerMarcus Meissner <marcus@jet.franken.de>2015-08-01 13:04:09 +0200
commit12db94ab3c8feb7ad3c9eef9818e689a2edcfd0c (patch)
tree7ce7caa33a060e50825d8f246f565fe70ec21afe /gphoto-m4
parent5f0ec7086a3bfaf5641cdb007736e939f07f0b70 (diff)
downloadlibgphoto2-12db94ab3c8feb7ad3c9eef9818e689a2edcfd0c.tar.gz
imported the libgphoto m4 tree
Diffstat (limited to 'gphoto-m4')
-rw-r--r--gphoto-m4/Makefile.am1
-rw-r--r--gphoto-m4/README.m49
-rw-r--r--gphoto-m4/gp-byteorder.m4446
-rw-r--r--gphoto-m4/gp-camlibs.m4170
-rw-r--r--gphoto-m4/gp-check-doxygen.m421
-rw-r--r--gphoto-m4/gp-check-library.m4456
-rw-r--r--gphoto-m4/gp-check-popt.m4180
-rw-r--r--gphoto-m4/gp-check-shell-environment.m448
-rw-r--r--gphoto-m4/gp-config-msg.m4102
-rw-r--r--gphoto-m4/gp-documentation.m4113
-rw-r--r--gphoto-m4/gp-dynamic-libraries.m460
-rw-r--r--gphoto-m4/gp-gettext-hack.m478
-rw-r--r--gphoto-m4/gp-internal-docs.m429
-rw-r--r--gphoto-m4/gp-libltdl.m459
-rw-r--r--gphoto-m4/gp-manual-docbook-xml.m446
-rw-r--r--gphoto-m4/gp-manual-documentation.m4329
-rw-r--r--gphoto-m4/gp-manual-fig2dev.m440
-rw-r--r--gphoto-m4/gp-manual-graphviz.m449
-rw-r--r--gphoto-m4/gp-manual-gtk-doc.m424
-rw-r--r--gphoto-m4/gp-manual-pstoimg.m436
-rw-r--r--gphoto-m4/gp-manual-w3m.m445
-rw-r--r--gphoto-m4/gp-packaging.m481
-rw-r--r--gphoto-m4/gp-pkg-config.m442
-rw-r--r--gphoto-m4/gp-references.m448
-rw-r--r--gphoto-m4/gp-stdint.m4732
-rw-r--r--gphoto-m4/gp-subpackage.m45
-rw-r--r--gphoto-m4/gp-udev.m49
-rw-r--r--gphoto-m4/gp-va-copy.m457
28 files changed, 3315 insertions, 0 deletions
diff --git a/gphoto-m4/Makefile.am b/gphoto-m4/Makefile.am
new file mode 100644
index 000000000..4997e15e8
--- /dev/null
+++ b/gphoto-m4/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = gp-byteorder.m4 gp-camlibs.m4 gp-check-doxygen.m4 gp-check-library.m4 gp-check-popt.m4 gp-check-shell-environment.m4 gp-config-msg.m4 gp-documentation.m4 gp-dynamic-libraries.m4 gp-gettext-hack.m4 gp-internal-docs.m4 gp-libltdl.m4 gp-manual-docbook-xml.m4 gp-manual-documentation.m4 gp-manual-fig2dev.m4 gp-manual-graphviz.m4 gp-manual-gtk-doc.m4 gp-manual-pstoimg.m4 gp-manual-w3m.m4 gp-packaging.m4 gp-pkg-config.m4 gp-references.m4 gp-stdint.m4 gp-udev.m4 gp-va-copy.m4 README.m4
diff --git a/gphoto-m4/README.m4 b/gphoto-m4/README.m4
new file mode 100644
index 000000000..57b89fca0
--- /dev/null
+++ b/gphoto-m4/README.m4
@@ -0,0 +1,9 @@
+This is the gPhoto projects' collection of autoconf/automake m4 macros.
+
+It has been designed to be used in
+ - gphoto2
+ - libgphoto2
+ - libgphoto2_port (located in libgphoto2/)
+ - gtkam
+
+Some macros are re-used ones from libexif.
diff --git a/gphoto-m4/gp-byteorder.m4 b/gphoto-m4/gp-byteorder.m4
new file mode 100644
index 000000000..cd4ed0d39
--- /dev/null
+++ b/gphoto-m4/gp-byteorder.m4
@@ -0,0 +1,446 @@
+dnl AC_NEED_BYTEORDER_H ( HEADER-TO-GENERATE )
+dnl Originally written by Dan Fandrich <dan@coneharvesters.com>
+dnl My contribution is hereby placed into the public domain.
+dnl No warranty is expressed or implied.
+dnl
+dnl Create a header file that guarantees that byte swapping macros of the
+dnl ntohl variety as well as the extended types included in OpenBSD and
+dnl NetBSD such as le32toh are defined. If possible, the standard ntohl
+dnl are overloaded as they are optimized for the given platform, but when
+dnl this is not possible (e.g. on a big-endian machine) they are defined
+dnl in this file.
+
+dnl Look for a symbol in a header file
+dnl AC_HAVE_SYMBOL ( IDENTIFIER, HEADER-FILE, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND )
+AC_DEFUN([AC_HAVE_SYMBOL],
+[
+AC_MSG_CHECKING(for $1 in $2)
+AC_EGREP_CPP([symbol is present|\<$1\>],[
+#include <$2>
+#ifdef $1
+ symbol is present
+#endif
+ ],
+[AC_MSG_RESULT(yes)
+$3
+],
+[AC_MSG_RESULT(no)
+$4
+])])
+
+
+dnl Create a header file that defines extended byte swapping macros
+AC_DEFUN([AC_NEED_BYTEORDER_H],
+[
+ac_dir=`AS_DIRNAME(["$1"])`
+if test "$ac_dir" != "$1" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && AS_MKDIR_P(["$ac_dir"])
+fi
+
+# We're only interested in the target CPU, but it's not always set
+effective_target="$target"
+if test "x$effective_target" = xNONE -o "x$effective_target" = x ; then
+ effective_target="$host"
+fi
+AC_SUBST(effective_target)
+
+cat > "$1" << EOF
+/* This file is generated automatically by configure */
+/* It is valid only for the system type ${effective_target} */
+
+#ifndef __BYTEORDER_H
+#define __BYTEORDER_H
+
+EOF
+
+dnl First, do an endian check
+AC_C_BIGENDIAN
+
+dnl Look for NetBSD-style extended byte swapping macros
+AC_HAVE_SYMBOL(le32toh,machine/endian.h,
+ [HAVE_LE32TOH=1
+ cat >> "$1" << EOF
+/* extended byte swapping macros are already available */
+#include <machine/endian.h>
+
+EOF],
+
+[
+
+dnl Look for standard byte swapping macros
+AC_HAVE_SYMBOL(ntohl,arpa/inet.h,
+ [cat >> "$1" << EOF
+/* ntohl and relatives live here */
+#include <arpa/inet.h>
+#define __HAVE_NTOHL
+
+EOF],
+
+ [AC_HAVE_SYMBOL(ntohl,netinet/in.h,
+ [cat >> "$1" << EOF
+/* ntohl and relatives live here */
+#include <netinet/in.h>
+#define __HAVE_NTOHL
+
+EOF],true)])
+])
+
+dnl Look for generic byte swapping macros
+
+dnl OpenBSD
+AC_HAVE_SYMBOL(swap32,machine/endian.h,
+ [cat >> "$1" << EOF
+/* swap32 and swap16 are defined in machine/endian.h */
+
+EOF],
+
+ [
+dnl Linux GLIBC
+ AC_HAVE_SYMBOL(bswap_32,byteswap.h,
+ [cat >> "$1" << EOF
+/* Define generic byte swapping functions */
+#include <byteswap.h>
+#define swap16(x) bswap_16(x)
+#define swap32(x) bswap_32(x)
+#define swap64(x) bswap_64(x)
+
+EOF],
+
+ [
+dnl NetBSD
+ AC_HAVE_SYMBOL(bswap32,machine/endian.h,
+ dnl We're already including machine/endian.h if this test succeeds
+ [cat >> "$1" << EOF
+/* Define generic byte swapping functions */
+EOF
+ if test "$HAVE_LE32TOH" != "1"; then
+ echo '#include <machine/endian.h>'>> "$1"
+ fi
+cat >> "$1" << EOF
+#define swap16(x) bswap16(x)
+#define swap32(x) bswap32(x)
+#define swap64(x) bswap64(x)
+
+EOF],
+
+ [
+dnl FreeBSD
+ AC_HAVE_SYMBOL(__byte_swap_long,sys/types.h,
+ [cat >> "$1" << EOF
+/* Define generic byte swapping functions */
+#include <sys/types.h>
+#define swap16(x) __byte_swap_word(x)
+#define swap32(x) __byte_swap_long(x)
+/* No optimized 64 bit byte swapping macro is available */
+#define swap64(x) ((uint64_t)(((uint64_t)(x) << 56) & 0xff00000000000000ULL | \\
+ ((uint64_t)(x) << 40) & 0x00ff000000000000ULL | \\
+ ((uint64_t)(x) << 24) & 0x0000ff0000000000ULL | \\
+ ((uint64_t)(x) << 8) & 0x000000ff00000000ULL | \\
+ ((x) >> 8) & 0x00000000ff000000ULL | \\
+ ((x) >> 24) & 0x0000000000ff0000ULL | \\
+ ((x) >> 40) & 0x000000000000ff00ULL | \\
+ ((x) >> 56) & 0x00000000000000ffULL))
+
+EOF],
+
+ [
+dnl OS X
+ AC_HAVE_SYMBOL(NXSwapLong,machine/byte_order.h,
+ [cat >> "$1" << EOF
+/* Define generic byte swapping functions */
+#include <machine/byte_order.h>
+#define swap16(x) NXSwapShort(x)
+#define swap32(x) NXSwapLong(x)
+#define swap64(x) NXSwapLongLong(x)
+
+EOF],
+ [
+ if test $ac_cv_c_bigendian = yes; then
+ cat >> "$1" << EOF
+/* No other byte swapping functions are available on this big-endian system */
+#define swap16(x) ((uint16_t)(((x) << 8) | ((uint16_t)(x) >> 8)))
+#define swap32(x) ((uint32_t)(((uint32_t)(x) << 24) & 0xff000000UL | \\
+ ((uint32_t)(x) << 8) & 0x00ff0000UL | \\
+ ((x) >> 8) & 0x0000ff00UL | \\
+ ((x) >> 24) & 0x000000ffUL))
+#define swap64(x) ((uint64_t)(((uint64_t)(x) << 56) & 0xff00000000000000ULL | \\
+ ((uint64_t)(x) << 40) & 0x00ff000000000000ULL | \\
+ ((uint64_t)(x) << 24) & 0x0000ff0000000000ULL | \\
+ ((uint64_t)(x) << 8) & 0x000000ff00000000ULL | \\
+ ((x) >> 8) & 0x00000000ff000000ULL | \\
+ ((x) >> 24) & 0x0000000000ff0000ULL | \\
+ ((x) >> 40) & 0x000000000000ff00ULL | \\
+ ((x) >> 56) & 0x00000000000000ffULL))
+
+EOF
+ else
+ cat >> "$1" << EOF
+/* Use these as generic byteswapping macros on this little endian system */
+/* on windows we might not have ntohs / ntohl without including winsock.dll,
+ * so use generic macros */
+#ifdef __HAVE_NTOHL
+# define swap16(x) htons(x)
+# define swap32(x) htonl(x)
+#else
+# define swap16(x) ((uint16_t)(((x) << 8) | ((uint16_t)(x) >> 8)))
+# define swap32(x) ((uint32_t)((((uint32_t)(x) << 24) & 0xff000000UL) | \\
+ (((uint32_t)(x) << 8) & 0x00ff0000UL) | \\
+ (((x) >> 8) & 0x0000ff00UL) | \\
+ (((x) >> 24) & 0x000000ffUL)))
+#endif
+/* No optimized 64 bit byte swapping macro is available */
+#define swap64(x) ((uint64_t)((((uint64_t)(x) << 56) & 0xff00000000000000ULL) | \\
+ (((uint64_t)(x) << 40) & 0x00ff000000000000ULL) | \\
+ (((uint64_t)(x) << 24) & 0x0000ff0000000000ULL) | \\
+ (((uint64_t)(x) << 8) & 0x000000ff00000000ULL) | \\
+ (((x) >> 8) & 0x00000000ff000000ULL) | \\
+ (((x) >> 24) & 0x0000000000ff0000ULL) | \\
+ (((x) >> 40) & 0x000000000000ff00ULL) | \\
+ (((x) >> 56) & 0x00000000000000ffULL)))
+
+EOF
+ fi
+])
+ ])
+ ])
+ ])
+])
+
+
+[
+if test "$HAVE_LE32TOH" != "1"; then
+ cat >> "$1" << EOF
+/* The byte swapping macros have the form: */
+/* EENN[a]toh or htoEENN[a] where EE is be (big endian) or */
+/* le (little-endian), NN is 16 or 32 (number of bits) and a, */
+/* if present, indicates that the endian side is a pointer to an */
+/* array of uint8_t bytes instead of an integer of the specified length. */
+/* h refers to the host's ordering method. */
+
+/* So, to convert a 32-bit integer stored in a buffer in little-endian */
+/* format into a uint32_t usable on this machine, you could use: */
+/* uint32_t value = le32atoh(&buf[3]); */
+/* To put that value back into the buffer, you could use: */
+/* htole32a(&buf[3], value); */
+
+/* Define aliases for the standard byte swapping macros */
+/* Arguments to these macros must be properly aligned on natural word */
+/* boundaries in order to work properly on all architectures */
+#ifndef htobe16
+# ifdef __HAVE_NTOHL
+# define htobe16(x) htons(x)
+# else
+# ifdef WORDS_BIGENDIAN
+# define htobe16(x) (x)
+# else
+# define htobe16(x) swap16(x)
+# endif
+# endif
+#endif
+#ifndef htobe32
+# ifdef __HAVE_NTOHL
+# define htobe32(x) htonl(x)
+# else
+# ifdef WORDS_BIGENDIAN
+# define htobe32(x) (x)
+# else
+# define htobe32(x) swap32(x)
+# endif
+# endif
+#endif
+#ifndef be16toh
+# define be16toh(x) htobe16(x)
+#endif
+#ifndef be32toh
+# define be32toh(x) htobe32(x)
+#endif
+
+#define HTOBE16(x) (x) = htobe16(x)
+#define HTOBE32(x) (x) = htobe32(x)
+#define BE32TOH(x) (x) = be32toh(x)
+#define BE16TOH(x) (x) = be16toh(x)
+
+EOF
+
+ if test $ac_cv_c_bigendian = yes; then
+ cat >> "$1" << EOF
+/* Define our own extended byte swapping macros for big-endian machines */
+#ifndef htole16
+# define htole16(x) swap16(x)
+#endif
+#ifndef htole32
+# define htole32(x) swap32(x)
+#endif
+#ifndef le16toh
+# define le16toh(x) swap16(x)
+#endif
+#ifndef le32toh
+# define le32toh(x) swap32(x)
+#endif
+#ifndef le64toh
+# define le64toh(x) swap64(x)
+#endif
+
+#ifndef htobe64
+# define htobe64(x) (x)
+#endif
+#ifndef be64toh
+# define be64toh(x) (x)
+#endif
+
+#define HTOLE16(x) (x) = htole16(x)
+#define HTOLE32(x) (x) = htole32(x)
+#define LE16TOH(x) (x) = le16toh(x)
+#define LE32TOH(x) (x) = le32toh(x)
+#define LE64TOH(x) (x) = le64toh(x)
+
+#define HTOBE64(x) (void) (x)
+#define BE64TOH(x) (void) (x)
+
+EOF
+ else
+ cat >> "$1" << EOF
+/* On little endian machines, these macros are null */
+#ifndef htole16
+# define htole16(x) (x)
+#endif
+#ifndef htole32
+# define htole32(x) (x)
+#endif
+#ifndef htole64
+# define htole64(x) (x)
+#endif
+#ifndef le16toh
+# define le16toh(x) (x)
+#endif
+#ifndef le32toh
+# define le32toh(x) (x)
+#endif
+#ifndef le64toh
+# define le64toh(x) (x)
+#endif
+
+#define HTOLE16(x) (void) (x)
+#define HTOLE32(x) (void) (x)
+#define HTOLE64(x) (void) (x)
+#define LE16TOH(x) (void) (x)
+#define LE32TOH(x) (void) (x)
+#define LE64TOH(x) (void) (x)
+
+/* These don't have standard aliases */
+#ifndef htobe64
+# define htobe64(x) swap64(x)
+#endif
+#ifndef be64toh
+# define be64toh(x) swap64(x)
+#endif
+
+#define HTOBE64(x) (x) = htobe64(x)
+#define BE64TOH(x) (x) = be64toh(x)
+
+EOF
+ fi
+fi
+
+cat >> "$1" << EOF
+/* Define the C99 standard length-specific integer types */
+#include <_stdint.h>
+
+EOF
+
+case "${effective_target}" in
+ i[3456]86-*)
+ cat >> "$1" << EOF
+/* Here are some macros to create integers from a byte array */
+/* These are used to get and put integers from/into a uint8_t array */
+/* with a specific endianness. This is the most portable way to generate */
+/* and read messages to a network or serial device. Each member of a */
+/* packet structure must be handled separately. */
+
+/* The i386 and compatibles can handle unaligned memory access, */
+/* so use the optimized macros above to do this job */
+#ifndef be16atoh
+# define be16atoh(x) be16toh(*(uint16_t*)(x))
+#endif
+#ifndef be32atoh
+# define be32atoh(x) be32toh(*(uint32_t*)(x))
+#endif
+#ifndef be64atoh
+# define be64atoh(x) be64toh(*(uint64_t*)(x))
+#endif
+#ifndef le16atoh
+# define le16atoh(x) le16toh(*(uint16_t*)(x))
+#endif
+#ifndef le32atoh
+# define le32atoh(x) le32toh(*(uint32_t*)(x))
+#endif
+#ifndef le64atoh
+# define le64atoh(x) le64toh(*(uint64_t*)(x))
+#endif
+
+#ifndef htob16a
+# define htobe16a(a,x) *(uint16_t*)(a) = htobe16(x)
+#endif
+#ifndef htobe32a
+# define htobe32a(a,x) *(uint32_t*)(a) = htobe32(x)
+#endif
+#ifndef htobe64a
+# define htobe64a(a,x) *(uint64_t*)(a) = htobe64(x)
+#endif
+#ifndef htole16a
+# define htole16a(a,x) *(uint16_t*)(a) = htole16(x)
+#endif
+#ifndef htole32a
+# define htole32a(a,x) *(uint32_t*)(a) = htole32(x)
+#endif
+#ifndef htole64a
+# define htole64a(a,x) *(uint64_t*)(a) = htole64(x)
+#endif
+
+EOF
+ ;;
+
+ *)
+ cat >> "$1" << EOF
+/* Here are some macros to create integers from a byte array */
+/* These are used to get and put integers from/into a uint8_t array */
+/* with a specific endianness. This is the most portable way to generate */
+/* and read messages to a network or serial device. Each member of a */
+/* packet structure must be handled separately. */
+
+/* Non-optimized but portable macros */
+#define be16atoh(x) ((uint16_t)(((x)[0]<<8)|(x)[1]))
+#define be32atoh(x) ((uint32_t)(((x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]))
+#define be64atoh_x(x,off,shift) (((uint64_t)((x)[off]))<<shift)
+#define be64atoh(x) ((uint64_t)(be64atoh_x(x,0,56)|be64atoh_x(x,1,48)|be64atoh_x(x,2,40)| \\
+ be64atoh_x(x,3,32)|be64atoh_x(x,4,24)|be64atoh_x(x,5,16)|be64atoh_x(x,6,8)|((x)[7])))
+#define le16atoh(x) ((uint16_t)(((x)[1]<<8)|(x)[0]))
+#define le32atoh(x) ((uint32_t)(((x)[3]<<24)|((x)[2]<<16)|((x)[1]<<8)|(x)[0]))
+#define le64atoh_x(x,off,shift) (((uint64_t)(x)[off])<<shift)
+#define le64atoh(x) ((uint64_t)(le64atoh_x(x,7,56)|le64atoh_x(x,6,48)|le64atoh_x(x,5,40)| \\
+ le64atoh_x(x,4,32)|le64atoh_x(x,3,24)|le64atoh_x(x,2,16)|le64atoh_x(x,1,8)|((x)[0])))
+
+#define htobe16a(a,x) (a)[0]=(uint8_t)((x)>>8), (a)[1]=(uint8_t)(x)
+#define htobe32a(a,x) (a)[0]=(uint8_t)((x)>>24), (a)[1]=(uint8_t)((x)>>16), \\
+ (a)[2]=(uint8_t)((x)>>8), (a)[3]=(uint8_t)(x)
+#define htobe64a(a,x) (a)[0]=(uint8_t)((x)>>56), (a)[1]=(uint8_t)((x)>>48), \\
+ (a)[2]=(uint8_t)((x)>>40), (a)[3]=(uint8_t)((x)>>32), \\
+ (a)[4]=(uint8_t)((x)>>24), (a)[5]=(uint8_t)((x)>>16), \\
+ (a)[6]=(uint8_t)((x)>>8), (a)[7]=(uint8_t)(x)
+#define htole16a(a,x) (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
+#define htole32a(a,x) (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \\
+ (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
+#define htole64a(a,x) (a)[7]=(uint8_t)((x)>>56), (a)[6]=(uint8_t)((x)>>48), \\
+ (a)[5]=(uint8_t)((x)>>40), (a)[4]=(uint8_t)((x)>>32), \\
+ (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \\
+ (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
+
+EOF
+ ;;
+esac
+]
+
+cat >> "$1" << EOF
+#endif /*__BYTEORDER_H*/
+EOF])
diff --git a/gphoto-m4/gp-camlibs.m4 b/gphoto-m4/gp-camlibs.m4
new file mode 100644
index 000000000..3dbb70db3
--- /dev/null
+++ b/gphoto-m4/gp-camlibs.m4
@@ -0,0 +1,170 @@
+dnl GP_CAMLIB & Co.
+dnl
+dnl Redundancy free definition of libgphoto2 camlibs.
+dnl
+dnl Removes the redundany from the camlib lists, and executes
+dnl additional consistency checks, e.g. to ensure that subdirectories
+dnl actually exist.
+dnl
+dnl You can mark camlibs as unlisted, i.e. they won't be listed
+dnl explicitly but still be recognized.
+dnl
+dnl Example usage:
+dnl
+dnl GP_CAMLIB([canon])
+dnl GP_CAMLIB([casio])
+dnl [...]
+dnl GP_CAMLIB([ptp],[unlisted])
+dnl GP_CAMLIB([ptp2])
+dnl [...]
+dnl GP_CAMLIB([toshiba])
+dnl GP_CAMLIBS_DEFINE([camlibs])
+dnl
+dnl The camlibs basedir parameter of GP_CAMLIBS_DEFINE is optional.
+dnl
+dnl ####################################################################
+dnl
+AC_DEFUN([GP_CAMLIBS_INIT],[dnl
+AC_BEFORE([$0],[GP_CAMLIB])dnl
+m4_define_default([gp_camlib_srcdir], [camlibs])dnl
+m4_define_default([gp_camlibs], [])dnl
+m4_define_default([gp_camlibs_unlisted], [])dnl
+])dnl
+dnl
+dnl ####################################################################
+dnl
+AC_DEFUN([GP_CAMLIB],[dnl
+AC_REQUIRE([GP_CAMLIBS_INIT])dnl
+AC_BEFORE([$0],[GP_CAMLIBS_DEFINE])dnl
+m4_if([$2],[unlisted],[dnl
+# $0($1,$2)
+m4_append([gp_camlibs_unlisted], [$1], [ ])dnl
+],[$#],[1],[dnl
+# $0($1)
+m4_append([gp_camlibs], [$1], [ ])dnl
+],[dnl
+m4_errprint(__file__:__line__:[ Error:
+*** Illegal parameter 2 to $0: `$2'
+*** Valid values are: undefined or [unlisted]
+])dnl
+m4_exit(1)dnl
+])dnl
+])dnl
+dnl
+dnl ####################################################################
+dnl
+AC_DEFUN([GP_CAMLIBS_WARNING],[dnl
+AC_MSG_WARN([
+
+# Caution: You have chosen to build a non-standard set of camlibs.
+# You may have disabled the camlib required for your camera, or
+# enabled a camlib that does *not* work, and overrides the camlib
+# that does work. Consequently,
+# YOUR CAMERA MAY NOT WORK!
+#
+# Many cameras of several brands are supported by a camlib with a
+# name different from the name of the camera brand or model. If you
+# are unsure, please
+# * enable at least the "ptp2" camlib
+# * or even better, just build "all" camlibs.
+])
+sleep 2
+])
+dnl
+dnl ####################################################################
+dnl
+AC_DEFUN([GP_CAMLIBS_DEFINE],[dnl
+AC_REQUIRE([GP_CAMLIBS_INIT])dnl
+m4_pattern_allow([m4_strip])dnl
+m4_ifval([$1],[m4_define([gp_camlib_srcdir],[$1])])dnl
+dnl for camlib in m4_strip(gp_camlibs) m4_strip(gp_camlibs_unlisted)
+dnl do
+dnl if test -d "$srcdir/m4_strip(gp_camlib_srcdir)/$camlib"; then :; else
+dnl AC_MSG_ERROR([
+dnl * Fatal:
+dnl * Source subdirectory for camlib \`$camlib' not found in
+dnl * directory \`$srcdir/m4_strip(gp_camlib_srcdir)/'
+dnl ])
+dnl fi
+dnl done
+AC_MSG_CHECKING([which camlibs to compile])
+dnl Yes, that help output won't be all that pretty, but we at least
+dnl do not have to edit it by hand.
+AC_ARG_WITH([camlibs],[AS_HELP_STRING(
+ [--with-camlibs=<list>],
+ [Compile camera drivers (camlibs) in <list>. ]dnl
+ [Drivers may be separated with commas. ]dnl
+ [CAUTION: DRIVER NAMES AND CAMERA NAMES MAY DIFFER. ]dnl
+ ['all' is the default and compiles all camlibs. ]dnl
+ [Possible camlibs are: ]dnl
+ m4_strip(gp_camlibs))],
+ [camlibs="$withval"],
+ [camlibs="all"])dnl
+dnl
+ALL_DEFINED_CAMLIBS="m4_strip(gp_camlibs) m4_strip(gp_camlibs_unlisted)"
+ALL_DEFAULT_CAMLIBS="m4_strip(gp_camlibs)"
+BUILD_THESE_CAMLIBS_BASE=""
+if test "$camlibs" = "all"; then
+ BUILD_THESE_CAMLIBS_BASE="$ALL_DEFAULT_CAMLIBS"
+ AC_MSG_RESULT([all])
+else
+ # If the string starts with "all,", we start with the default list
+ # and add the explicitly defined ones later
+ if echo "$camlibs" | grep "^all," > /dev/null; then
+ BUILD_THESE_CAMLIBS_BASE="$ALL_DEFAULT_CAMLIBS"
+ camlibs="$(echo "$camlibs" | sed 's/^all,//')"
+ fi
+ # camlibs=$(echo $camlibs | sed 's/,/ /g')
+ IFS_save="$IFS"
+ IFS=",$IFS"
+ # Walk through enumeration of camlibs given by user and add them to list
+ # of camlibs to build if we know them.
+ for camlib in ${camlibs}; do
+ IFS="$IFS_save"
+ found=false
+ for from_all_camlib in ${ALL_DEFINED_CAMLIBS}; do
+ if test "$camlib" = "$from_all_camlib"; then
+ if test "x$BUILD_THESE_CAMLIBS_BASE" = "x"; then
+ BUILD_THESE_CAMLIBS_BASE="$camlib"
+ else
+ BUILD_THESE_CAMLIBS_BASE="$BUILD_THESE_CAMLIBS_BASE $camlib"
+ fi
+ found=:
+ break
+ fi
+ done
+ if $found; then :; else
+ AC_MSG_ERROR([Unknown camlib $camlib!])
+ fi
+ done
+ if test "x$BUILD_THESE_CAMLIBS_BASE" = "xcanon" ; then
+ # Gentoo mode... if user just said "canon", add "ptp2" ... should save support requests.
+ BUILD_THESE_CAMLIBS_BASE="$BUILD_THESE_CAMLIBS_BASE ptp2"
+ camlibs="$camlibs ptp2"
+ AC_MSG_WARN([
+ "You have just selected the old canon driver. However most current Canons\n"
+ "are supported by the PTP2 driver.\n"
+ "Autoselecting ptp2 driver too to avoid support requests.\n"
+ ])
+ fi
+ IFS="$IFS_save"
+ AC_MSG_RESULT([$camlibs])
+ GP_CAMLIBS_WARNING
+ AC_DEFINE_UNQUOTED([INCOMPLETE_CAMLIB_SET], ["$BUILD_THESE_CAMLIBS_BASE"],
+ [Whether the set of camlibs built is incomplete])
+fi
+BUILD_THESE_CAMLIBS=""
+for f in $BUILD_THESE_CAMLIBS_BASE
+do
+ BUILD_THESE_CAMLIBS="${BUILD_THESE_CAMLIBS}${BUILD_THESE_CAMLIBS+ }${f}.la"
+done
+AC_SUBST([BUILD_THESE_CAMLIBS])
+AC_SUBST([ALL_DEFINED_CAMLIBS])
+AC_SUBST([ALL_DEFAULT_CAMLIBS])
+])dnl
+dnl
+dnl ####################################################################
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl End:
diff --git a/gphoto-m4/gp-check-doxygen.m4 b/gphoto-m4/gp-check-doxygen.m4
new file mode 100644
index 000000000..482ba1e64
--- /dev/null
+++ b/gphoto-m4/gp-check-doxygen.m4
@@ -0,0 +1,21 @@
+dnl doxygen related stuff
+dnl look for tools
+dnl define substitutions for Doxyfile.in
+AC_DEFUN([GP_CHECK_DOXYGEN],[dnl
+AC_REQUIRE([GP_CHECK_DOC_DIR])dnl
+AC_PATH_PROG([DOT], [dot], [false])
+AC_PATH_PROG([DOXYGEN], [doxygen], [false])
+AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$DOXYGEN" != "xfalse"])
+AM_CONDITIONAL([HAVE_DOT], [test "x$DOT" != "xfalse"])
+if test "x$DOT" != "xfalse"; then
+ AC_SUBST([HAVE_DOT],[YES])
+else
+ AC_SUBST([HAVE_DOT],[NO])
+fi
+AC_SUBST([HTML_APIDOC_DIR], ["${PACKAGE_TARNAME}-api.html"])
+AC_SUBST([DOXYGEN_OUTPUT_DIR], [doxygen-output])
+AC_SUBST([HTML_APIDOC_INTERNALS_DIR], ["${PACKAGE_TARNAME}-internals.html"])
+])dnl
+
+
+
diff --git a/gphoto-m4/gp-check-library.m4 b/gphoto-m4/gp-check-library.m4
new file mode 100644
index 000000000..bc97e19b0
--- /dev/null
+++ b/gphoto-m4/gp-check-library.m4
@@ -0,0 +1,456 @@
+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
+dnl Parameters:
+dnl
+dnl VARNAMEPART partial variable name for variable definitions
+dnl libname name of library
+dnl VERSION-REQUIREMENT check for the version using pkg-config.
+dnl default: []
+dnl headername name of header file
+dnl default: []
+dnl functionname name of function name in library
+dnl default: []
+dnl ACTION-IF-FOUND shell action to execute if found
+dnl default: []
+dnl ACTION-IF-NOT-FOUND shell action to execute if not found
+dnl default: []
+dnl OPTIONAL-REQUIRED-ETC one of "mandatory", "default-on", "default-off"
+dnl "disable-explicitly"
+dnl default: [mandatory]
+dnl WHERE-TO-GET-IT place where to find the library, e.g. a URL
+dnl default: []
+dnl
+dnl What the ACTION-IFs can do:
+dnl
+dnl * change the variable have_[$1] to "yes" or "no" and thus change
+dnl the outcome of the test
+dnl * execute additional checks to define more specific variables, e.g.
+dnl for different API versions
+dnl
+dnl What the OPTIONAL-REQUIRED-ETC options mean:
+dnl
+dnl mandatory Absolute requirement, cannot be disabled.
+dnl default-on If found, it is used. If not found, it is not used.
+dnl default-off In case of --with-libfoo, detect it. Without
+dnl --with-libfoo, do not look for and use it.
+dnl disable-explicitly Required by default, but can be disabled by
+dnl explicitly giving --without-libfoo.
+dnl
+dnl These results have happened after calling GP_CHECK_LIBRARY:
+dnl
+dnl AM_CONDITIONAL([HAVE_VARPREFIX],[ if found ])
+dnl AM_SUBST([have_VARPREFIX], [ "yes" if found, "no" if not found ])
+dnl AM_SUBST([VARPREFIX_CFLAGS],[ -I, -D and stuff ])
+dnl AM_SUBST([VARPREFIX_LIBS], [ /path/to/libname.la -L/path -lfoo ])
+dnl
+dnl Parameters to ./configure which influence the GP_CHECK_LIBRARY results:
+dnl
+dnl * VARNAMEPART_LIBS=/foobar/arm-palmos/lib/libname.la
+dnl VARNAMEPART_CFLAGS=-I/foobar/include
+dnl * --without-libfoo
+dnl * --with-libfoo=/usr/local
+dnl * --with-libfoo-include-dir=/foobar/include
+dnl * --with-libfoo-lib=/foobar/arm-palmos/lib
+dnl * --with-libfoo=autodetect
+dnl
+dnl Examples:
+dnl GP_CHECK_LIBRARY([LIBEXIF], [libexif])dnl
+dnl GP_CHECK_LIBRARY([LIBEXIF], [libexif-gtk], [>= 0.3.3])dnl
+dnl note the space! ^
+dnl
+dnl Possible enhancements:
+dnl
+dnl * Derive VAR_PREFIX directly from libname
+dnl This will change the calling conventions, so be aware of that.
+dnl * Give names of a header file and function name and to a test
+dnl compilation.
+dnl
+AC_DEFUN([_GP_CHECK_LIBRARY_SOEXT],[dnl
+AC_MSG_CHECKING([for dynamic library extension])
+soext=""
+case "$host" in
+ *linux*) soext=".so" ;;
+ *sunos*) soext=".so" ;;
+ *solaris*) soext=".so" ;;
+ *bsd*) soext=".so" ;;
+ *darwin*) soext=".dylib" ;;
+ *w32*) soext=".dll" ;;
+esac
+case "$host_os" in
+ gnu*) soext=".so" ;;
+esac
+if test "x$soext" = "x"; then
+ soext=".so"
+ AC_MSG_RESULT([${soext}])
+ AC_MSG_WARN([
+Host system "${host}" not recognized, defaulting to "${soext}".
+])
+else
+ AC_MSG_RESULT([${soext}])
+fi
+])dnl
+dnl
+AC_DEFUN([_GP_CHECK_LIBRARY],[
+# ----------------------------------------------------------------------
+# [GP_CHECK_LIBRARY]([$1],[$2],[$3],
+# [$4],[$5],
+# [...],[...],[$8])
+m4_ifval([$9],[dnl
+# $9
+])dnl
+# ----------------------------------------------------------------------
+dnl
+AC_REQUIRE([GP_CONFIG_MSG])dnl
+AC_REQUIRE([GP_PKG_CONFIG])dnl
+AC_REQUIRE([_GP_CHECK_LIBRARY_SOEXT])dnl
+# Use _CFLAGS and _LIBS given to configure.
+# This makes it possible to set these vars in a configure script
+# and AC_CONFIG_SUBDIRS this configure.
+AC_ARG_VAR([$1][_CFLAGS], [CFLAGS for compiling with ][$2])dnl
+AC_ARG_VAR([$1][_LIBS], [LIBS to add for linking against ][$2])dnl
+dnl
+AC_MSG_CHECKING([for ][$2][ to use])
+m4_ifval([$3],[REQUIREMENTS_FOR_][$1][="][$2][ $3]["],
+ [REQUIREMENTS_FOR_][$1][="][$2]["])
+userdef_[$1]=no
+have_[$1]=no
+if test "x${[$1][_LIBS]}" = "x" && test "x${[$1][_CFLAGS]}" = "x"; then
+ # define --with/--without argument
+ m4_if([$8], [default-off],
+ [m4_pushdef([gp_lib_arg],[--without-][$2])dnl
+ try_[$1]=no
+ ],
+ [m4_pushdef([gp_lib_arg],[--with-][$2])dnl
+ try_[$1]=auto
+ ])dnl
+ AC_ARG_WITH([$2],[AS_HELP_STRING([gp_lib_arg][=PREFIX],[where to find ][$2][, "no" or "auto"])],[try_][$1][="$withval"])
+ if test "x${[try_][$1]}" = "xno"; then
+ [REQUIREMENTS_FOR_][$1][=]
+ fi
+ if test "x${[try_][$1]}" = "xauto"; then [try_][$1]=autodetect; fi
+ AC_MSG_RESULT([${try_][$1][}])
+ m4_popdef([gp_lib_arg])dnl
+ if test "x${[try_][$1]}" = "xautodetect"; then
+ # OK, we have to autodetect.
+ # We start autodetection with the cleanest known method: pkg-config
+ if test "x${[have_][$1]}" = "xno"; then
+ # we need that line break after the PKG_CHECK_MODULES
+ m4_ifval([$3],
+ [PKG_CHECK_MODULES([$1],[$2][ $3],[have_][$1][=yes],[:])],
+ [PKG_CHECK_MODULES([$1],[$2], [have_][$1][=yes],[:])]
+ )
+ fi
+ # If pkg-config didn't find anything, try the libfoo-config program
+ # certain known libraries ship with.
+ if test "x${[have_][$1]}" = "xno"; then
+ AC_MSG_CHECKING([$2][ config program])
+ m4_pushdef([gp_lib_config],[m4_if([$2],[libusb],[libusb-config],
+ [$2],[libgphoto2],[gphoto2-config],
+ [$2],[libgphoto2_port],[gphoto2-port-config],
+ [$2],[gdlib],[gdlib-config],
+ [$2],[libxml-2.0],[xml2-config],
+ [none])])dnl
+ AC_MSG_RESULT([gp_lib_config])
+ AC_PATH_PROG([$1][_CONFIG_PROG],[gp_lib_config])
+ if test -n "${[$1][_CONFIG_PROG]}" &&
+ test "${[$1][_CONFIG_PROG]}" != "none"; then
+ m4_ifval([$3],[
+ AC_MSG_CHECKING([for ][$2][ version according to ][gp_lib_config])
+ m4_pushdef([gp_lib_compop],[regexp([$3], [\(>=\|>\|<\|<=\|=\)[ \t]*.*], [\1])])dnl comparison operator
+ m4_if( gp_lib_compop,[>=],[_][$1][_COMPN="-lt"],
+ gp_lib_compop,[>], [_][$1][_COMPN="-le"],
+ gp_lib_compop,[<], [_][$1][_COMPN="-ge"],
+ gp_lib_compop,[<=],[_][$1][_COMPN="-gt"],
+ gp_lib_compop,[=], [_][$1][_COMPN="-ne"],
+ [m4_errprint(__file__:__line__:[ Error:
+Illegal version comparison operator: `gp_lib_compop'
+It must be one of ">=", ">", "<", "<=", "=".
+])m4_exit(1)])
+ m4_popdef([gp_lib_compop])dnl
+ # split requested version number using m4 regexps
+ _[$1]_REQ_1="regexp([$3], [\(>=\|>\|<\|<=\|=\)[ \t]*\([0-9]+\).*], [\2])"
+ _[$1]_REQ_2="regexp([$3], [\(>=\|>\|<\|<=\|=\)[ \t]*\([0-9]+\)\.\([0-9]+\).*], [\3])"
+ _[$1]_REQ_3="regexp([$3], [\(>=\|>\|<\|<=\|=\)[ \t]*\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\).*], [\4])"
+ _[$1]_REQ_4="regexp([$3], [\(>=\|>\|<\|<=\|=\)[ \t]*\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)\(.*\)], [\5])"
+ # split installed version number via shell and sed
+ _[$1]_VERSION="$("${[$1][_CONFIG_PROG]}" --version | sed 's/^.* //')"
+ _[$1]_VER_1="$(echo "${_[$1]_VERSION}" | sed 's/\([[0-9]]*\).*/\1/g')"
+ _[$1]_VER_2="$(echo "${_[$1]_VERSION}" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/g')"
+ _[$1]_VER_3="$(echo "${_[$1]_VERSION}" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/g')"
+ _[$1]_VER_4="$(echo "${_[$1]_VERSION}" | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)\(.*\)/\4/g')"
+ AC_MSG_RESULT([${_][$1][_VERSION}])
+ _tmp=false
+ if test "${_[$1]_VER_1}" "${_[$1]_COMPN}" "${_[$1]_REQ_1}"; then _tmp=true;
+ elif test "${_[$1]_VER_2}" "${_[$1]_COMPN}" "${_[$1]_REQ_2}"; then _tmp=true;
+ elif test "${_[$1]_VER_3}" "${_[$1]_COMPN}" "${_[$1]_REQ_3}"; then _tmp=true;
+ elif test "x${_[$1]_VER_4}" = "x" && test "x${_[$1]_REQ_4}" != "x"; then _tmp=true;
+ elif test "${_[$1]_VER_4}" "${_[$1]_COMPN}" "${_[$1]_REQ_4}"; then _tmp=true;
+ fi
+ AC_MSG_CHECKING([if ][$2][ version is matching requirement ][$3])
+ if "${_tmp}"; then
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Version requirement ][$2][ ][$3][ not met. Found: ${_][$1][_VERSION}])
+ else
+ AC_MSG_RESULT([yes])
+ fi
+ ])dnl if version requirement given
+ AC_MSG_CHECKING([for ][$2][ parameters from ][gp_lib_config])
+ [$1]_LIBS="$(${[$1][_CONFIG_PROG]} --libs || echo "*error*")"
+ [$1]_CFLAGS="$(${[$1][_CONFIG_PROG]} --cflags || echo "*error*")"
+ if test "x${[$1]_LIBS}" = "*error*" ||
+ test "x${[$1]_CFLAGS}" = "*error*"; then
+ AC_MSG_RESULT([error])
+ else
+ have_[$1]=yes
+ AC_MSG_RESULT([ok])
+ fi
+ fi
+ m4_popdef([gp_lib_config])dnl
+ fi
+ m4_ifval([$3],[# Version requirement given, so we do not rely on probing.],[
+ # Neither pkg-config, nor the libfoo-config program have found anything.
+ # So let's just probe the system.
+ AC_MSG_WARN([The `$2' library could not be found using pkg-config or its known config program.
+No version checks will be performed if it is found using any other method.])
+ if test "x${[have_][$1]}" = "xno"; then
+ ifs="$IFS"
+ IFS=":" # FIXME: for W32 and OS/2 we may need ";" here
+ for _libdir_ in \
+ ${LD_LIBRARY_PATH} \
+ "${libdir}" \
+ "${prefix}/lib64" "${prefix}/lib" \
+ /usr/lib64 /usr/lib \
+ /usr/local/lib64 /usr/local/lib \
+ /opt/lib64 /opt/lib
+ do
+ IFS="$ifs"
+ for _soext_ in .la ${soext} .a; do
+ if test -f "${_libdir_}/[$2]${_soext_}"
+ then
+ if test "x${_soext_}" = "x.la" ||
+ test "x${_soext_}" = "x.a"; then
+ [$1]_LIBS="${_libdir_}/[$2]${_soext_}"
+ else
+ [$1]_LIBS="-L${_libdir_} -l$(echo "$2" | sed 's/^lib//')"
+ fi
+ break
+ fi
+ done
+ if test "x${[$1][_LIBS]}" != "x"; then
+ break
+ fi
+ done
+ IFS="$ifs"
+ if test "x${[$1][_LIBS]}" != "x"; then
+ have_[$1]=yes
+ fi
+ fi
+ ])
+ elif test "x${[try_][$1]}" = "xno"; then
+ :
+ else
+ # We've been given a prefix to look in for library $2.
+ # We start looking for $2.la files first.
+ AC_MSG_CHECKING([for ][$2][.la file in ${[try_][$1]}])
+ if test -f "${[try_][$1]}/lib/[$2].la"; then
+ [$1][_LIBS]="${[try_][$1]}/lib/[$2].la"
+ [$1][_CFLAGS]="-I${[try_][$1]}/include"
+ AC_MSG_RESULT([libtool file $][$1][_LIBS (good)])
+ have_[$1]=yes
+ elif test -f "${[try_][$1]}/lib64/[$2].la"; then # HACK
+ [$1][_LIBS]="${[try_][$1]}/lib64/[$2].la"
+ [$1][_CFLAGS]="-I${[try_][$1]}/include"
+ AC_MSG_RESULT([libtool file $][$1][_LIBS (good)])
+ have_[$1]=yes
+ else
+ AC_MSG_RESULT([wild guess that something is in $try_][$1])
+ [$1][_LIBS]="-L${[try_][$1]}/lib -l$(echo "$2" | sed 's/^lib//')"
+ [$1][_CFLAGS]="-I${[try_][$1]}/include"
+ have_[$1]=yes
+ AC_MSG_WARN([
+* Warning:
+* libtool file $2.la could not be found.
+* We may be linking against the WRONG library.
+])
+ fi
+ fi
+elif test "x${[$1][_LIBS]}" != "x" && test "x${[$1][_CFLAGS]}" != "x"; then
+ AC_MSG_RESULT([user-defined])
+ userdef_[$1]=yes
+ have_[$1]=yes
+else
+ AC_MSG_RESULT([broken call])
+ AC_MSG_ERROR([
+* Fatal:
+* When calling configure for ${PACKAGE_TARNAME}
+* ${PACKAGE_NAME}
+* either set both [$1][_LIBS] *and* [$1][_CFLAGS]
+* or neither.
+])
+fi
+AC_SUBST([REQUIREMENTS_FOR_][$1])
+dnl
+dnl ACTION-IF-FOUND
+dnl
+m4_ifval([$6],[dnl
+if test "x${[have_][$1]}" = "xyes"; then
+# ACTION-IF-FOUND
+$6
+fi
+])dnl
+dnl
+dnl ACTION-IF-NOT-FOUND
+dnl
+m4_ifval([$7],[dnl
+if test "x${[have_][$1]}" = "xno"; then
+# ACTION-IF-NOT-FOUND
+$7
+fi
+])dnl
+dnl
+dnl Run our own test compilation
+dnl
+m4_ifval([$4],[dnl
+if test "x${[have_][$1]}" = "xyes"; then
+dnl AC_MSG_CHECKING([whether ][$2][ test compile succeeds])
+dnl AC_MSG_RESULT([${[have_][$1]}])
+CPPFLAGS_save="$CPPFLAGS"
+CPPFLAGS="${[$1]_CFLAGS}"
+AC_CHECK_HEADER([$4],[have_][$1][=yes],[have_][$1][=no])
+CPPFLAGS="$CPPFLAGS_save"
+fi
+])dnl
+dnl
+dnl Run our own test link
+dnl Does not work for libraries which be built after configure time,
+dnl so we deactivate it for them (userdef_).
+dnl
+m4_ifval([$5],[dnl
+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])
+ LIBS="$LIBS_save"
+ AC_MSG_RESULT([${[have_][$1]}])
+fi
+])dnl
+dnl
+dnl Abort configure script if mandatory, but not found
+dnl
+m4_if([$8],[mandatory],[
+if test "x${[have_][$1]}" = "xno"; then
+ AC_MSG_ERROR([
+PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
+[$1][_LIBS]=${[$1][_LIBS]}
+[$1][_CFLAGS]=${[$1][_CFLAGS]}
+
+* Fatal: ${PACKAGE_NAME} requires $2 $3 to build.
+*
+* Possible solutions:
+* - set PKG_CONFIG_PATH to adequate value
+* - call configure with [$1][_LIBS]=.. and [$1][_CFLAGS]=..
+* - call configure with one of the --with-$2 parameters
+][m4_ifval([$9],[dnl
+* - get $2 and install it:
+* $9],[dnl
+* - get $2 and install it])])
+fi
+])dnl
+dnl
+dnl Abort configure script if not found and not explicitly disabled
+dnl
+m4_if([$8],[disable-explicitly],[
+if test "x${[try_][$1]}" != "xno" && test "x${[have_][$1]}" = "xno"; then
+ AC_MSG_ERROR([
+PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
+[$1][_LIBS]=${[$1][_LIBS]}
+[$1][_CFLAGS]=${[$1][_CFLAGS]}
+
+* Fatal: ${PACKAGE_NAME} by default requires $2 $3 to build.
+* You must explicitly disable $2 to build ${PACKAGE_TARNAME} without it.
+*
+* Possible solutions:
+* - call configure with --with-$2=no or --without-$2
+* - set PKG_CONFIG_PATH to adequate value
+* - call configure with [$1][_LIBS]=.. and [$1][_CFLAGS]=..
+* - call configure with one of the --with-$2 parameters
+][m4_ifval([$9],[dnl
+* - get $2 and install it:
+* $9],[dnl
+* - get $2 and install it
+])][m4_if([$2],[libusb],[dnl
+* - if you have libusb >= 1.0 installed, you must also install
+* either the libusb0 compat library or a libusb 0.x version
+])])
+fi
+])dnl
+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
+ 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
+fi
+dnl AC_SUBST is done implicitly by AC_ARG_VAR above.
+dnl AC_SUBST([$1][_LIBS])
+dnl AC_SUBST([$1][_CFLAGS])
+])dnl
+dnl
+dnl ####################################################################
+dnl
+AC_DEFUN([_GP_CHECK_LIBRARY_SYNTAX_ERROR],[dnl
+m4_errprint(__file__:__line__:[ Error:
+*** Calling $0 macro with old syntax
+*** Aborting.
+])dnl
+m4_exit(1)dnl
+])dnl
+dnl
+dnl ####################################################################
+dnl
+AC_DEFUN([GP_CHECK_LIBRARY],[dnl
+m4_if([$4], [mandatory], [_GP_CHECK_LIBRARY_SYNTAX_ERROR($0)],
+ [$4], [default-enabled], [_GP_CHECK_LIBRARY_SYNTAX_ERROR($0)],
+ [$4], [default-disabled], [_GP_CHECK_LIBRARY_SYNTAX_ERROR($0)])dnl
+m4_if([$8], [], [dnl
+ _GP_CHECK_LIBRARY([$1],[$2],[$3],[$4],[$5],[$6],[$7],[mandatory],[$9])],
+ [$8], [default-on], [dnl
+ _GP_CHECK_LIBRARY([$1],[$2],[$3],[$4],[$5],[$6],[$7],[$8],[$9])],
+ [$8], [disable-explicitly], [dnl
+ _GP_CHECK_LIBRARY([$1],[$2],[$3],[$4],[$5],[$6],[$7],[$8],[$9])],
+ [$8], [default-off], [dnl
+ _GP_CHECK_LIBRARY([$1],[$2],[$3],[$4],[$5],[$6],[$7],[$8],[$9])],
+ [$8], [mandatory], [dnl
+ _GP_CHECK_LIBRARY([$1],[$2],[$3],[$4],[$5],[$6],[$7],[$8],[$9])],
+ [m4_errprint(__file__:__line__:[ Error:
+Illegal argument 6 to $0: `$6'
+It must be one of "default-on", "default-off", "mandatory".
+])m4_exit(1)])dnl
+])dnl
+dnl
+m4_pattern_disallow([GP_CHECK_LIBRARY])
+m4_pattern_disallow([_GP_CHECK_LIBRARY])
+m4_pattern_disallow([_GP_CHECK_LIBRARY_SYNTAX_ERROR])
+m4_pattern_disallow([_GP_CHECK_LIBRARY_SOEXT])
+dnl
+dnl ####################################################################
+dnl
+dnl Please do not remove this:
+dnl filetype: 6e60b4f0-acb2-4cd5-8258-42014f92bd2c
+dnl I use this to find all the different instances of this file which
+dnl are supposed to be synchronized.
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl End:
diff --git a/gphoto-m4/gp-check-popt.m4 b/gphoto-m4/gp-check-popt.m4
new file mode 100644
index 000000000..9bf506a24
--- /dev/null
+++ b/gphoto-m4/gp-check-popt.m4
@@ -0,0 +1,180 @@
+dnl @synopsis GP_CHECK_POPT(FLAG)
+dnl
+dnl Check whether libpopt is available.
+dnl FLAG must be one of
+dnl "mandatory"
+dnl "default-enabled"
+dnl "default-disabled"
+dnl
+AC_DEFUN([GP_CHECK_POPT],[
+#
+# [GP_CHECK_POPT]
+#
+AC_REQUIRE([GP_CONFIG_MSG])dnl
+m4_if([$1],[mandatory], [_GP_CHECK_POPT([mandatory])],
+ [$1],[default-enabled], [_GP_CHECK_POPT([disable])],
+ [$1],[default-disabled], [_GP_CHECK_POPT([enable])],
+ [m4_errprint(__file__:__line__:[ Error:
+Illegal argument to $0: `$1'
+Valid values are: mandatory, default-enabled, default-disabled
+])m4_exit(1)])dnl
+])dnl
+dnl
+AC_DEFUN([_GP_CHECK_POPT],[
+m4_if([$1],[mandatory],[
+try_popt=yes
+require_popt=yes
+],[
+try_popt=auto
+require_popt=no
+AC_ARG_ENABLE([popt],
+[AS_HELP_STRING([--$1-popt],[Do not use popt])],
+[ if test "x$enableval" = xno \
+ || test "x$enableval" = xoff \
+ || test "x$enableval" = xfalse;
+ then
+ try_popt=no
+ require_popt=no
+ elif test "x$enableval" = xyes \
+ || test "x$enableval" = xon \
+ || test "x$enableval" = xtrue
+ then
+ try_popt=yes
+ require_popt=yes
+ fi
+])dnl
+])dnl
+
+AC_MSG_CHECKING([whether popt is required])
+AC_MSG_RESULT([${require_popt}])
+
+if test "$require_popt" != yes; then
+ AC_MSG_CHECKING([whether popt is requested])
+ AC_MSG_RESULT([${try_popt}])
+fi
+
+dnl Implicit AC_SUBST
+AC_ARG_VAR([POPT_CFLAGS],[cppflags to compile with libpopt])dnl
+AC_ARG_VAR([POPT_LIBS],[location of libpopt to link against])dnl
+
+have_popt=no
+
+if test "x$POPT_CFLAGS" = "x" && test "x$POPT_LIBS" = "x"; then
+
+ # try to find options to compile popt.h
+ CPPFLAGS_save="$CPPFLAGS"
+ popth_found=no
+ for popt_prefix in "" /usr /usr/local
+ do
+ if test -n "${popt_prefix}"; then
+ :
+ elif test -d "${popt_prefix}/include"; then
+ CPPFLAGS="-I${popt_prefix}/include ${CPPFLAGS}"
+ else
+ continue
+ fi
+ ac_cv_header_popt_h=""
+ unset ac_cv_header_popt_h
+ AC_CHECK_HEADER([popt.h], [popth_found=yes])
+ if test "$popth_found" = yes; then break; fi
+ done
+ CPPFLAGS="$CPPFLAGS_save"
+ if test "$popth_found" = "yes"; then
+ if test "$popt_prefix" = ""; then
+ POPT_CFLAGS=""
+ else
+ POPT_CFLAGS="-I${popt_prefix}/include"
+ fi
+ elif test "$require_popt" = "yes"; then
+ AC_MSG_ERROR([
+* Cannot autodetect popt.h
+*
+* Set POPT_CFLAGS and POPT_LIBS correctly.
+])
+ fi
+
+ # try to find options to link against popt
+ LDFLAGS_save="$LDFLAGS"
+ popt_links=no
+ for popt_prefix in /usr "" /usr/local; do
+ # We could have "/usr" and "lib64" at the beginning of the
+ # lists. Then the first tested location would
+ # incidentally be the right one on 64bit systems, and
+ # thus work around a bug in libtool on 32bit systems:
+ #
+ # 32bit libtool doesn't know about 64bit systems, and so the
+ # compilation will fail when linking a 32bit library from
+ # /usr/lib to a 64bit binary.
+ #
+ # This hack has been confirmed to workwith a
+ # 32bit Debian Sarge and 64bit Fedora Core 3 system.
+ for ldir in lib64 "" lib; do
+ popt_libdir="${popt_prefix}/${ldir}"
+ if test "${popt_libdir}" = "/"; then
+ popt_libdir=""
+ elif test -d "${popt_libdir}"; then
+ LDFLAGS="-L${popt_libdir} ${LDFLAGS}"
+ else
+ continue
+ fi
+ # Avoid caching of results
+ ac_cv_lib_popt_poptStuffArgs=""
+ unset ac_cv_lib_popt_poptStuffArgs
+ AC_CHECK_LIB([popt], [poptStuffArgs], [popt_links=yes])
+ if test "$popt_links" = yes; then break; fi
+ done
+ if test "$popt_links" = yes; then break; fi
+ done
+ LDFLAGS="$LDFLAGS_save"
+ if test "$popt_links" = "yes"; then
+ if test "$popt_libdir" = ""; then
+ POPT_LIBS="-lpopt"
+ else
+ POPT_LIBS="-L${popt_libdir} -lpopt"
+ fi
+ have_popt=yes
+ elif test "$require_popt" = "yes"; then
+ AC_MSG_ERROR([
+* Cannot autodetect library directory containing popt
+*
+* Set POPT_CFLAGS and POPT_LIBS correctly.
+])
+ fi
+elif test "x$POPT_CFLAGS" != "x" && test "x$POPT_LIBS" != "x"; then
+ # just use the user specivied option
+ popt_msg="yes (user specified)"
+ have_popt=yes
+else
+ AC_MSG_ERROR([
+* Fatal: Either set both POPT_CFLAGS and POPT_LIBS or neither.
+])
+fi
+
+AC_MSG_CHECKING([if popt is functional])
+if test "$require_popt$have_popt" = "yesno"; then
+ AC_MSG_RESULT([no, but required])
+ AC_MSG_ERROR([
+* popt library not found
+* Fatal: ${PACKAGE_NAME} (${PACKAGE_TARNAME}) requires popt
+* Please install it and/or set POPT_CFLAGS and POPT_LIBS.
+])
+fi
+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}])
+fi
+AM_CONDITIONAL([HAVE_POPT],[test "$have_popt" = "yes"])
+])dnl
+dnl
+dnl Please do not remove this:
+dnl filetype: 7595380e-eff3-49e5-90ab-e40f1d544639
+dnl I use this to find all the different instances of this file which
+dnl are supposed to be synchronized.
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl End:
diff --git a/gphoto-m4/gp-check-shell-environment.m4 b/gphoto-m4/gp-check-shell-environment.m4
new file mode 100644
index 000000000..b9850e7aa
--- /dev/null
+++ b/gphoto-m4/gp-check-shell-environment.m4
@@ -0,0 +1,48 @@
+dnl @synopsis GP_CHECK_SHELL_ENVIRONMENT([SHOW-LOCALE-VARS])
+dnl
+dnl Check that the shell environment is sane.
+dnl
+dnl If SHOW-LOCALE-VARS is set to [true], print all LC_* and LANG*
+dnl variables at configure time. (WARNING: This is not portable!)
+dnl
+dnl
+AC_DEFUN([GP_CHECK_SHELL_ENVIRONMENT],
+[
+# make sure "cd" doesn't print anything on stdout
+if test x"${CDPATH+set}" = xset
+then
+ CDPATH=:
+ export CDPATH
+fi
+
+# make sure $() command substitution works
+AC_MSG_CHECKING([for POSIX sh \$() command substitution])
+if test "x$(pwd)" = "x`pwd`" && test "y$(echo "foobar")" = "y`echo foobar`" # ''''
+then
+ AC_MSG_RESULT([yes])
+else
+ AC_MSG_RESULT([no])
+ uname=`uname 2>&1` # ''
+ uname_a=`uname -a 2>&1` # ''
+ AC_MSG_ERROR([
+
+* POSIX sh \$() command substition does not work with this shell.
+*
+* You are running a very rare species of shell. Please report this
+* sighting to <${PACKAGE_BUGREPORT}>:
+* SHELL=${SHELL}
+* uname=${uname}
+* uname-a=${uname_a}
+* Please also include your OS and version.
+*
+* Run this configure script using a better (i.e. POSIX compliant) shell.
+])
+fi
+dnl
+m4_if([$1],[true],[dnl
+printenv | grep -E '^(LC_|LANG)'
+])dnl
+
+dnl
+])dnl
+dnl
diff --git a/gphoto-m4/gp-config-msg.m4 b/gphoto-m4/gp-config-msg.m4
new file mode 100644
index 000000000..cc1935182
--- /dev/null
+++ b/gphoto-m4/gp-config-msg.m4
@@ -0,0 +1,102 @@
+dnl
+dnl GP_CONFIG_INIT
+dnl use default LHS width (called implicitly if not called explicitly)
+dnl GP_CONFIG_INIT([WIDTH-OF-LHS])
+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 formatted output line "LHS: RHS"
+dnl
+dnl GP_CONFIG_OUTPUT
+dnl print all the output messages we collected in the mean time
+dnl
+dnl Simple way to print a configuration summary at the end of ./configure.
+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
+dnl GP_CONFIG_MSG([Feature foo],[${foo}])
+dnl GP_CONFIG_MSG([Location of bar],[${bar}])
+dnl [...]
+dnl AC_OUTPUT
+dnl GP_CONFIG_OUTPUT
+dnl
+dnl
+AC_DEFUN([GP_CONFIG_INIT],
+[dnl
+AC_REQUIRE([GP_CHECK_SHELL_ENVIRONMENT])
+dnl the empty string must contain at least as many spaces as the substr length
+dnl FIXME: let m4 determine that length
+dnl (collect left parts in array and choose largest length)
+m4_if([$1],[],[gp_config_len="30"],[gp_config_len="$1"])
+gp_config_empty=""
+gp_config_len3="$(expr "$gp_config_len" - 3)"
+n="$gp_config_len"
+while test "$n" -gt 0; do
+ gp_config_empty="${gp_config_empty} "
+ n="$(expr "$n" - 1)"
+done
+gp_config_msg="
+Configuration (${PACKAGE_TARNAME} ${PACKAGE_VERSION}):
+"
+])dnl
+dnl
+dnl
+AC_DEFUN([GP_CONFIG_MSG],
+[AC_REQUIRE([GP_CONFIG_INIT])dnl
+m4_if([$1],[],[
+gp_config_msg="${gp_config_msg}
+"
+],[$2],[],[
+gp_config_msg="${gp_config_msg}
+ [$1]
+"
+],[
+gp_config_msg_len="$(expr "[$1]" : '.*')"
+if test "$gp_config_msg_len" -ge "$gp_config_len"; then
+ gp_config_msg_lhs="$(expr "[$1]" : "\(.\{0,${gp_config_len3}\}\)")..:"
+else
+ gp_config_msg_lhs="$(expr "[$1]:${gp_config_empty}" : "\(.\{0,${gp_config_len}\}\)")"
+fi
+gp_config_msg="${gp_config_msg} ${gp_config_msg_lhs} [$2]
+"
+])])dnl
+dnl
+AC_DEFUN([GP_CONFIG_MSG_SUBDIRS],[dnl
+# Message about configured subprojects
+if test "x$subdirs" != "x"; then
+ GP_CONFIG_MSG()dnl
+ _subdirs=""
+ for sd in $subdirs; do
+ ssd="$(basename "$sd")"
+ if test "x$_subdirs" = "x"; then
+ _subdirs="$ssd";
+ else
+ _subdirs="$_subdirs $ssd"
+ fi
+ done
+ GP_CONFIG_MSG([Subprojects],[${_subdirs}])dnl
+fi
+])dnl
+dnl
+AC_DEFUN([GP_CONFIG_OUTPUT],
+[AC_REQUIRE([GP_CONFIG_INIT])dnl
+AC_REQUIRE([GP_CONFIG_MSG])dnl
+AC_REQUIRE([GP_CONFIG_MSG_SUBDIRS])dnl
+echo "${gp_config_msg}
+You may run \"make\" and \"make install\" now."
+])dnl
+dnl
+dnl Please do not remove this:
+dnl filetype: de774af3-dc3b-4b1d-b6f2-4aca35d3da16
+dnl I use this to find all the different instances of this file which
+dnl are supposed to be synchronized.
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl End:
diff --git a/gphoto-m4/gp-documentation.m4 b/gphoto-m4/gp-documentation.m4
new file mode 100644
index 000000000..a73301b6a
--- /dev/null
+++ b/gphoto-m4/gp-documentation.m4
@@ -0,0 +1,113 @@
+dnl
+dnl check where to install documentation
+dnl
+dnl determines documentation "root directory", i.e. the directory
+dnl where all documentation will be placed in
+dnl
+
+AC_DEFUN([GP_CHECK_DOC_DIR],
+[
+AC_BEFORE([$0], [GP_BUILD_GTK_DOCS])dnl
+AC_BEFORE([$0], [GP_CHECK_DOXYGEN])dnl
+
+AC_ARG_WITH([doc-dir],
+[AS_HELP_STRING([--with-doc-dir=PATH],
+[Where to install docs [default=autodetect]])])
+
+# check for the main ("root") documentation directory
+AC_MSG_CHECKING([main docdir])
+
+if test "x${with_doc_dir}" != "x"
+then # docdir is given as parameter
+ docdir="${with_doc_dir}"
+ AC_MSG_RESULT([${docdir} (from parameter)])
+else # otherwise invent a docdir hopefully compatible with system policy
+ if test -d "/usr/share/doc"
+ then
+ maindocdir='${prefix}/share/doc'
+ AC_MSG_RESULT([${maindocdir} (FHS style)])
+ elif test -d "/usr/doc"
+ then
+ maindocdir='${prefix}/doc'
+ AC_MSG_RESULT([${maindocdir} (old style)])
+ else
+ maindocdir='${datadir}/doc'
+ AC_MSG_RESULT([${maindocdir} (default value)])
+ fi
+ AC_MSG_CHECKING([package docdir])
+ # check whether to include package version into documentation path
+ # FIXME: doesn't work properly.
+ if ls -d /usr/{share/,}doc/make-[0-9]* > /dev/null 2>&1
+ then
+ docdir="${maindocdir}/${PACKAGE}-${VERSION}"
+ AC_MSG_RESULT([${docdir} (redhat style)])
+ else
+ docdir="${maindocdir}/${PACKAGE}"
+ AC_MSG_RESULT([${docdir} (default style)])
+ fi
+fi
+
+AC_SUBST([docdir])
+])dnl
+
+dnl
+dnl check whether to build docs and where to:
+dnl
+dnl * determine presence of prerequisites (only gtk-doc for now)
+dnl * determine destination directory for HTML files
+dnl
+
+AC_DEFUN([GP_BUILD_GTK_DOCS],
+[
+# docdir has to be determined in advance
+AC_REQUIRE([GP_CHECK_DOC_DIR])
+
+# ---------------------------------------------------------------------------
+# gtk-doc: We use gtk-doc for building our documentation. However, we
+# require the user to explicitely request the build.
+# ---------------------------------------------------------------------------
+try_gtkdoc=false
+gtkdoc_msg="no (not requested)"
+have_gtkdoc=false
+AC_ARG_ENABLE([docs],
+[AS_HELP_STRING([--enable-docs],
+[Use gtk-doc to build documentation [default=no]])],[
+ if test x$enableval = xyes; then
+ try_gtkdoc=true
+ fi
+])
+if $try_gtkdoc; then
+ AC_PATH_PROG([GTKDOC],[gtkdoc-mkdb])
+ if test -n "${GTKDOC}"; then
+ have_gtkdoc=true
+ gtkdoc_msg="yes"
+ else
+ gtkdoc_msg="no (http://www.gtk.org/rdp/download.html)"
+ fi
+fi
+AM_CONDITIONAL([ENABLE_GTK_DOC], [$have_gtkdoc])
+GP_CONFIG_MSG([build API docs with gtk-doc],[$gtkdoc_msg])
+
+
+# ---------------------------------------------------------------------------
+# Give the user the possibility to install html documentation in a
+# user-defined location.
+# ---------------------------------------------------------------------------
+AC_ARG_WITH([html-dir],
+[AS_HELP_STRING([--with-html-dir=PATH],
+[Where to install html docs [default=autodetect]])])
+
+AC_MSG_CHECKING([for html dir])
+if test "x${with_html_dir}" = "x" ; then
+ htmldir="${docdir}/html"
+ AC_MSG_RESULT([${htmldir} (default)])
+else
+ htmldir="${with_html_dir}"
+ AC_MSG_RESULT([${htmldir} (from parameter)])
+fi
+AC_SUBST([htmldir])
+apidocdir="${htmldir}/api"
+AC_SUBST([apidocdir])
+
+])dnl
+
diff --git a/gphoto-m4/gp-dynamic-libraries.m4 b/gphoto-m4/gp-dynamic-libraries.m4
new file mode 100644
index 000000000..a83fc0f79
--- /dev/null
+++ b/gphoto-m4/gp-dynamic-libraries.m4
@@ -0,0 +1,60 @@
+AC_DEFUN([GP_DYNAMIC_LIBRARIES],[dnl
+dnl We require either of those
+dnl AC_REQUIRE([AC_LIBTTDL_INSTALLABLE])dnl
+dnl AC_REQUIRE([AC_LIBLTDL_CONVENIENCE])dnl
+AC_REQUIRE([AC_LIBTOOL_DLOPEN])dnl
+AC_REQUIRE([AC_PROG_LIBTOOL])dnl
+dnl ---------------------------------------------------------------------------
+dnl Check for libltdl:
+dnl - lt_dlforeachfile has been introduced in libtool-1.4.
+dnl - However, there are still systems out there running libtool-1.3.
+dnl For those, we will use our shipped libltdl. This has the welcome
+dnl side effect that we don't have to distinguish between libltdl 1.3 with
+dnl and without the notorious segfault bug.
+dnl - FIXME: In case we're using our own version, we have to check whether
+dnl -ldl is required?
+dnl ---------------------------------------------------------------------------
+# $0
+ltdl_msg="no (not found or too old)"
+have_ltdl=false
+LIBS_save="$LIBS"
+LIBS="$LIBLTDL"
+AC_CHECK_LIB([ltdl], [lt_dlforeachfile],[
+ CPPFLAGS_save="$CPPFLAGS"
+ CPPFLAGS="$LTDLINCL"
+ AC_CHECK_HEADER([ltdl.h],[
+ AC_DEFINE([HAVE_LTDL],1,[whether we use libltdl])
+ ltdl_msg="yes (from system)"
+ have_ltdl=:
+ ])
+ CPPFLAGS="$CPPFLAGS_save"
+])
+LIBS="$LIBS_save"
+if "$have_ltdl"; then :; else
+ AC_MSG_CHECKING([for included libltdl])
+ if test -d "$srcdir/libltdl"; then
+ LIBLTDL="\$(top_builddir)/libltdl/libltdlc.la"
+ LTDLINCL="-I\$(top_srcdir)/libltdl"
+ have_ltdl=:
+ ltdl_msg="yes (included)"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([
+*** Could not detect or configure libltdl.
+])
+ fi
+fi
+GP_CONFIG_MSG([libltdl],["${ltdl_msg}"])
+])dnl
+dnl
+dnl ####################################################################
+dnl
+dnl Please do not remove this:
+dnl filetype: 2b993145-3256-47b4-84fd-ec4dcdf4fdf9
+dnl I use this to find all the different instances of this file which
+dnl are supposed to be synchronized.
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl End:
diff --git a/gphoto-m4/gp-gettext-hack.m4 b/gphoto-m4/gp-gettext-hack.m4
new file mode 100644
index 000000000..3f5dbb72a
--- /dev/null
+++ b/gphoto-m4/gp-gettext-hack.m4
@@ -0,0 +1,78 @@
+dnl
+dnl GP_GETTEXT_HACK
+dnl
+dnl gettext hack, originally designed for libexif, libgphoto2, and Co.
+dnl This creates a po/Makevars file with adequate values if the
+dnl po/Makevars.template is present.
+dnl
+dnl Example usage:
+dnl GP_GETTEXT_HACK([${PACKAGE_TARNAME}-${LIBFOO_CURRENT}],
+dnl [Copyright Holder],
+dnl [foo-translation@example.org])
+dnl ALL_LINGUAS="de es fr"
+dnl AM_GNU_GETTEXT_VERSION([0.14.1])
+dnl AM_GNU_GETTEXT([external])
+dnl AM_PO_SUBDIRS()
+dnl AM_ICONV()
+dnl GP_GETTEXT_FLAGS
+dnl
+dnl You can leave out the GP_GETTEXT_HACK parameters if you want to,
+dnl GP_GETTEXT_HACK will try fall back to sensible values in that case:
+dnl
+
+AC_DEFUN([GP_GETTEXT_HACK],
+[
+AC_BEFORE([$0], [AM_GNU_GETTEXT])dnl
+AC_BEFORE([$0], [AM_GNU_GETTEXT_VERSION])dnl
+m4_if([$1],[],[GETTEXT_PACKAGE="${PACKAGE_TARNAME}"],[GETTEXT_PACKAGE="$1"])
+AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"],
+ [The gettext domain we're using])
+AC_SUBST([GETTEXT_PACKAGE])
+sed_cmds="s|^DOMAIN.*|DOMAIN = ${GETTEXT_PACKAGE}|"
+m4_if([$2],[],[],[sed_cmds="${sed_cmds};s|^COPYRIGHT_HOLDER.*|COPYRIGHT_HOLDER = $2|"])
+m4_ifval([$3],[
+if test -n "$PACKAGE_BUGREPORT"; then
+ sed_mb="${PACKAGE_BUGREPORT}"
+else
+ AC_MSG_ERROR([
+*** Your configure.{ac,in} is wrong.
+*** Either define PACKAGE_BUGREPORT (by using the 4-parameter AC INIT syntax)
+*** or give [GP_GETTEXT_HACK] the third parameter.
+***
+])
+fi
+],[
+sed_mb="$3"
+])
+sed_cmds="${sed_cmds};s|^MSGID_BUGS_ADDRESS.*|MSGID_BUGS_ADDRESS = ${sed_mb}|"
+# Not so sure whether this hack is all *that* evil...
+AC_MSG_CHECKING([for po/Makevars requiring hack])
+if test -f "${srcdir}/po/Makevars.template"; then
+ sed "$sed_cmds" < "${srcdir}/po/Makevars.template" > "${srcdir}/po/Makevars"
+ AC_MSG_RESULT([yes, done.])
+else
+ AC_MSG_RESULT([no])
+fi
+])
+
+AC_DEFUN([GP_GETTEXT_FLAGS],
+[
+AC_REQUIRE([AM_GNU_GETTEXT])
+AC_REQUIRE([GP_CONFIG_INIT])
+if test "x${BUILD_INCLUDED_LIBINTL}" = "xyes"; then
+ AM_CFLAGS="${AM_CFLAGS} -I\$(top_srcdir)/intl"
+fi
+GP_CONFIG_MSG([Use translations],[${USE_NLS}])
+if test "x$USE_NLS" = "xyes" && test "${BUILD_INCLUDED_LIBINTL}"; then
+ GP_CONFIG_MSG([Use included libintl],[${BUILD_INCLUDED_LIBINTL}])
+fi
+])
+
+dnl Please do not remove this:
+dnl filetype: 71ff3941-a5ae-4677-a369-d7cb01f92c81
+dnl I use this to find all the different instances of this file which
+dnl are supposed to be synchronized.
+
+dnl Local Variables:
+dnl mode: autoconf
+dnl End:
diff --git a/gphoto-m4/gp-internal-docs.m4 b/gphoto-m4/gp-internal-docs.m4
new file mode 100644
index 000000000..8593620aa
--- /dev/null
+++ b/gphoto-m4/gp-internal-docs.m4
@@ -0,0 +1,29 @@
+dnl
+dnl
+dnl
+AC_DEFUN([GP_INTERNAL_DOCS],[dnl
+# Whether to enable the internal docs build.
+#
+# This takes quite some time due to the generation of lots of call
+# graphs, so it is disabled by default.
+set_enable_internal_docs=no
+AC_ARG_ENABLE([internal-docs], [dnl
+AS_HELP_STRING([--enable-internal-docs],
+[Build internal code docs if doxygen available])], [dnl
+dnl If either --enable-foo nor --disable-foo were given, execute this.
+ if test "x$enableval" = xno \
+ || test "x$enableval" = xoff \
+ || test "x$enableval" = xfalse;
+ then
+ set_enable_internal_docs=no
+ elif test "x$enableval" = xyes \
+ || test "x$enableval" = xon \
+ || test "x$enableval" = xtrue
+ then
+ set_enable_internal_docs=yes
+ fi
+])
+AC_MSG_CHECKING([whether to create internal code docs])
+AC_MSG_RESULT([${set_enable_internal_docs}])
+AM_CONDITIONAL([ENABLE_INTERNAL_DOCS], [test "x${set_enable_internal_docs}" = "xyes"])
+])dnl
diff --git a/gphoto-m4/gp-libltdl.m4 b/gphoto-m4/gp-libltdl.m4
new file mode 100644
index 000000000..2a37c9305
--- /dev/null
+++ b/gphoto-m4/gp-libltdl.m4
@@ -0,0 +1,59 @@
+dnl Written by Hans Ulrich Niedermann
+dnl LDFLAGS vs LIBS fix by Dan Nicholson
+dnl
+dnl We are using our own libltdl checks instead of AC_WITH_LTDL
+dnl because we do not want to ship our own copy of libltdl any more.
+dnl Not shipping libltdl makes it possible to ditch our own autogen.sh
+dnl and relying on standard autoconf's "autoreconf".
+dnl
+dnl Look for external libltdl, not shipping internal libltdl.
+AC_DEFUN([GP_LIB_LTDL],[dnl
+AC_ARG_VAR([LTDLINCL],[CFLAGS for compiling with libltdl])
+AC_ARG_VAR([LIBLTDL],[LIBS to add for linking against libltdl])
+if test "x${LTDLINCL}${LIBLTDL}" = "x"; then
+AC_CHECK_HEADER([ltdl.h],
+[dnl
+AC_CHECK_LIB([ltdl], [lt_dlinit],[dnl
+LTDLINCL=""
+LIBLTDL="-lltdl"
+AC_DEFINE([HAVE_LTDL],[1],[Whether libltdl (of libtool fame) is present])
+],[dnl
+AC_MSG_ERROR([
+$PACKAGE requires the ltdl library, included with libtool
+
+Please make sure that the proper development package is installed
+(libltdl-dev, libtool-ltdl-devel, etc.)
+])[]dnl
+])dnl
+])
+else
+ AC_MSG_CHECKING([for libltdl flags])
+ AC_MSG_RESULT([set explicitly: ${LTDLINCL} ${LIBLTDL}])
+fi
+AC_SUBST([LTDLINCL])
+AC_SUBST([LIBLTDL])
+dnl
+dnl Make sure we can actually compile and link against libltdl
+AC_LANG_PUSH([C])
+AC_MSG_CHECKING([that we can compile and link with libltdl])
+saved_CPPFLAGS="$CPPFLAGS"
+saved_LIBS="$LIBS"
+CPPFLAGS="$CPPFLAGS $LTDLINCL"
+LIBS="$LIBS $LIBLTDL"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
+#include <stdlib.h> /* for NULL */
+#include <ltdl.h> /* for lt_* */
+],[dnl
+int ret = lt_dlforeachfile("/usr/lib:/usr/local/lib", NULL, NULL);
+])], [AC_MSG_RESULT([yes])], [dnl
+AC_MSG_RESULT([no])
+AC_MSG_ERROR([cannot compile and link against libltdl
+${PACKAGE_TARNAME} requires libltdl (the libtool dl* library),
+but cannot compile and link against it.
+Aborting.
+])
+])
+CPPFLAGS="$saved_CPPFLAGS"
+LIBS="$saved_LIBS"
+AC_LANG_POP
+])dnl
diff --git a/gphoto-m4/gp-manual-docbook-xml.m4 b/gphoto-m4/gp-manual-docbook-xml.m4
new file mode 100644
index 000000000..bec00c7fd
--- /dev/null
+++ b/gphoto-m4/gp-manual-docbook-xml.m4
@@ -0,0 +1,46 @@
+dnl ------------------------------------------------------------------------
+dnl try to find xmlto (required for generation of man pages and html docs)
+dnl ------------------------------------------------------------------------
+AC_DEFUN([GP_CHECK_DOCBOOK_XML],
+[
+
+AC_MSG_CHECKING([for XML catalogs])
+XML_CATALOG_FILES="`find /etc/xml /usr/share/xml /usr/share/sgml -type f \( -iname 'catalog.xml' -or -iname 'catalog' \) -print 2> /dev/null | while read file; do echo -n "$file "; done`"
+if test "x$XML_CATALOG_FILES" = "x"
+then
+ AC_MSG_RESULT([none found.])
+else
+ AC_MSG_RESULT([found ${XML_CATALOG_FILES}])
+fi
+AC_SUBST(XML_CATALOG_FILES)
+
+#XML_DEBUG_CATALOG=0
+#AC_SUBST(XML_DEBUG_CATALOG)
+
+manual_msg="no (http://cyberelk.net/tim/xmlto/)"
+try_xmlto=true
+have_xmlto=false
+AC_ARG_WITH(xmlto, [ --without-xmlto Don't use xmlto],[
+ if test x$withval = xno; then
+ try_xmlto=false
+ fi])
+if $try_xmlto; then
+ AC_PATH_PROG(XMLTO,xmlto)
+ if test -n "${XMLTO}"; then
+ have_xmlto=true
+ manual_msg="yes"
+ PURE_XMLTO="$XMLTO"
+ if true || test "x$XML_CATALOG_FILES" = "x"; then
+ unset XML_CATALOG_FILES
+ XMLTO="${XMLTO} -m \$(top_srcdir)/src/xsl/custom.xsl"
+ else
+ XMLTO="env XML_CATALOG_FILES=\"${XML_CATALOG_FILES}\" ${XMLTO} -m ${top_srcdir}/src/xsl/custom.xsl"
+ fi
+ else
+ # in case anybody runs $(XMLTO) somewhere, we return false
+ XMLTO=false
+ fi
+fi
+
+AM_CONDITIONAL(XMLTO, $have_xmlto)
+])
diff --git a/gphoto-m4/gp-manual-documentation.m4 b/gphoto-m4/gp-manual-documentation.m4
new file mode 100644
index 000000000..cb7b4e866
--- /dev/null
+++ b/gphoto-m4/gp-manual-documentation.m4
@@ -0,0 +1,329 @@
+dnl
+dnl check where to install documentation
+dnl
+dnl determines documentation "root directory", i.e. the directory
+dnl where all documentation will be placed in
+dnl
+
+AC_DEFUN([GP_CHECK_DOCDIR],
+[
+
+AC_ARG_WITH(doc-dir, [ --with-doc-dir=PATH Where to install docs [default=autodetect]])dnl
+
+# check for the main ("root") documentation directory
+AC_MSG_CHECKING([main docdir])
+
+if test "x${with_doc_dir}" != "x"
+then # docdir is given as parameter
+ docdir="${with_doc_dir}"
+ AC_MSG_RESULT([${docdir} (from parameter)])
+else # otherwise invent a docdir hopefully compatible with system policy
+ if test -d "/usr/share/doc"
+ then
+ maindocdir='${prefix}/share/doc'
+ AC_MSG_RESULT([${maindocdir} (FHS style)])
+ elif test -d "/usr/doc"
+ then
+ maindocdir='${prefix}/doc'
+ AC_MSG_RESULT([${maindocdir} (old style)])
+ else
+ maindocdir='${datadir}/doc'
+ AC_MSG_RESULT([${maindocdir} (default value)])
+ fi
+ AC_MSG_CHECKING(package docdir)
+ # check whether to include package version into documentation path
+ # FIXME: doesn't work properly.
+ if ls -d /usr/{share/,}doc/*-[[]0-9[]]* > /dev/null 2>&1
+ then
+ docdir="${maindocdir}/${PACKAGE}-${VERSION}"
+ AC_MSG_RESULT([${docdir} (redhat style)])
+ else
+ docdir="${maindocdir}/${PACKAGE}"
+ AC_MSG_RESULT([${docdir} (default style)])
+ fi
+fi
+
+AC_SUBST(docdir)
+
+])dnl
+
+dnl Solaris hack for grep and tr
+AC_DEFUN([GP_CHECK_TR],
+[
+if test -n "`echo $host_os | grep '[sS]olaris'`"; then
+ TR=/usr/xpg4/bin/tr
+ GREP=/usr/xpg4/bin/grep
+else
+ TR=tr
+ GREP=grep
+fi
+])
+
+dnl
+dnl check whether to build docs and where to:
+dnl
+dnl * determine presence of prerequisites (only gtk-doc for now)
+dnl * determine destination directory for HTML files
+dnl
+
+AC_DEFUN([GP_BUILD_DOCS],
+[
+# doc dir has to be determined in advance
+AC_REQUIRE([GP_CHECK_DOCDIR])
+AC_REQUIRE([GP_CHECK_GTK_DOC])
+AC_REQUIRE([GP_CHECK_FIG2DEV])
+AC_REQUIRE([GP_CHECK_DOCBOOK_XML])
+AC_REQUIRE([GP_CHECK_TR])
+AC_REQUIRE([GP_CHECK_PSTOIMG])
+AC_REQUIRE([GP_CHECK_DOT])
+AC_REQUIRE([GP_CHECK_W3M])
+
+gphoto2xml='$(top_srcdir)/src/gphoto2.xml'
+AC_SUBST(gphoto2xml)
+
+dnl ---------------------------------------------------------------------------
+dnl Give the user the possibility to install documentation in
+dnl user-defined locations.
+dnl ---------------------------------------------------------------------------
+AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Where to install html docs [default=autodetect]])
+AC_MSG_CHECKING([for html dir])
+if test "x${with_html_dir}" = "x" ; then
+ htmldir="${docdir}/html"
+ AC_MSG_RESULT([${htmldir} (default)])
+else
+ htmldir="${with_html_dir}"
+ AC_MSG_RESULT([${htmldir} (from parameter)])
+fi
+AC_SUBST(htmldir)
+
+AC_ARG_WITH(xhtml-dir, [ --with-xhtml-dir=PATH Where to install xhtml docs [default=autodetect]])
+AC_MSG_CHECKING([for xhtml dir])
+if test "x${with_xhtml_dir}" = "x" ; then
+ xhtmldir="${docdir}/xhtml"
+ AC_MSG_RESULT([${xhtmldir} (default)])
+else
+ xhtmldir="${with_xhtml_dir}"
+ AC_MSG_RESULT([${xhtmldir} (from parameter)])
+fi
+AC_SUBST(xhtmldir)
+
+AC_ARG_WITH(html-nochunks-dir, [ --with-html-nochunks-dir=PATH Where to install html-nochunks docs [default=autodetect]])
+AC_MSG_CHECKING([for html-nochunks dir])
+if test "x${with_html_nochunks_dir}" = "x" ; then
+ htmlnochunksdir="${docdir}/html-nochunks"
+ AC_MSG_RESULT([${htmlnochunksdir} (default)])
+else
+ htmlnochunksdir="${with_html_nochunks_dir}"
+ AC_MSG_RESULT([${htmlnochunksdir} (from parameter)])
+fi
+AC_SUBST(htmlnochunksdir)
+
+AC_ARG_WITH(xhtml-nochunks-dir, [ --with-xhtml-nochunks-dir=PATH Where to install xhtml-nochunks docs [default=autodetect]])
+AC_MSG_CHECKING([for xhtml-nochunks dir])
+if test "x${with_xhtml_nochunks_dir}" = "x" ; then
+ xhtmlnochunksdir="${docdir}/xhtml-nochunks"
+ AC_MSG_RESULT([${xhtmlnochunksdir} (default)])
+else
+ xhtmlnochunksdir="${with_xhtml_nochunks_dir}"
+ AC_MSG_RESULT([${xhtmlnochunksdir} (from parameter)])
+fi
+AC_SUBST(xhtmlnochunksdir)
+
+AC_ARG_WITH(xml-dir, [ --with-xml-dir=PATH Where to install xml docs [default=autodetect]])
+AC_MSG_CHECKING([for xml dir])
+if test "x${with_xml_dir}" = "x" ; then
+ xmldir="${docdir}/xml"
+ AC_MSG_RESULT([${xmldir} (default)])
+else
+ xmldir="${with_xml_dir}"
+ AC_MSG_RESULT([${xmldir} (from parameter)])
+fi
+AC_SUBST(xmldir)
+xmlcssdir="${xmldir}/css"
+AC_SUBST(xmlcssdir)
+
+AC_ARG_WITH(txt-dir, [ --with-txt-dir=PATH Where to install txt docs [default=autodetect]])
+AC_MSG_CHECKING([for txt dir])
+if test "x${with_txt_dir}" = "x" ; then
+ txtdir="${docdir}/txt"
+ AC_MSG_RESULT([${txtdir} (default)])
+else
+ txtdir="${with_txt_dir}"
+ AC_MSG_RESULT([${txtdir} (from parameter)])
+fi
+AC_SUBST(txtdir)
+
+AC_ARG_WITH(man-dir, [ --with-man-dir=PATH Where to install man docs [default=autodetect]])
+AC_MSG_CHECKING([for man dir])
+if test "x${with_man_dir}" = "x" ; then
+ manmandir="${docdir}/man"
+ AC_MSG_RESULT([${manmandir} (default)])
+else
+ manmandir="${with_man_dir}"
+ AC_MSG_RESULT([${manmandir} (from parameter)])
+fi
+AC_SUBST(manmandir)
+
+AC_ARG_WITH(pdf-dir, [ --with-pdf-dir=PATH Where to install pdf docs [default=autodetect]])
+AC_MSG_CHECKING([for pdf dir])
+if test "x${with_pdf_dir}" = "x" ; then
+ pdfdir="${docdir}/pdf"
+ AC_MSG_RESULT([${pdfdir} (default)])
+else
+ pdfdir="${with_pdf_dir}"
+ AC_MSG_RESULT([${pdfdir} (from parameter)])
+fi
+AC_SUBST(pdfdir)
+
+AC_ARG_WITH(ps-dir, [ --with-ps-dir=PATH Where to install ps docs [default=autodetect]])
+AC_MSG_CHECKING([for ps dir])
+if test "x${with_ps_dir}" = "x" ; then
+ psdir="${docdir}/ps"
+ AC_MSG_RESULT([${psdir} (default)])
+else
+ psdir="${with_ps_dir}"
+ AC_MSG_RESULT([${psdir} (from parameter)])
+fi
+AC_SUBST(psdir)
+
+AC_ARG_WITH(figure-dir, [ --with-figure-dir=PATH Where to install figures [default=autodetect]])
+AC_MSG_CHECKING([for figure dir])
+if test "x${with_figure_dir}" = "x" ; then
+ figuredir="${docdir}/figures"
+ AC_MSG_RESULT([${figuredir} (default)])
+else
+ figuredir="${with_figure_dir}"
+ AC_MSG_RESULT([${figuredir} (from parameter)])
+fi
+AC_SUBST(figuredir)
+
+AC_ARG_WITH(screenshots-dir, [ --with-screenshots-dir=PATH Where to install screenshotss [default=autodetect]])
+AC_MSG_CHECKING([for screenshots dir])
+if test "x${with_screenshots_dir}" = "x" ; then
+ screenshotsdir="${docdir}/screenshots"
+ AC_MSG_RESULT([${screenshotsdir} (default)])
+else
+ screenshotsdir="${with_screenshots_dir}"
+ AC_MSG_RESULT([${screenshotsdir} (from parameter)])
+fi
+AC_SUBST(screenshotsdir)
+screenshotsgtkamdir="${screenshotsdir}/gtkam"
+AC_SUBST(screenshotsgtkamdir)
+
+doc_formats_list='man html txt ps pdf'
+
+# initialize have_xmlto* to false
+for i in $doc_formats_list; do
+ d=`echo $i | $TR A-Z a-z`
+ eval "have_xmlto$d=false"
+done
+
+AC_MSG_CHECKING(checking doc formats)
+AC_ARG_WITH(doc_formats,
+ [ --with-doc-formats=<list> create doc with format in <list>; ]
+ [ 'all' build all doc formats; ]
+ [ possible formats are: ]
+ [ man, html, ps, pdf ],
+ doc_formats="$withval", doc_formats="man html txt")
+
+if test "$doc_formats" = "all"; then
+ doc_formats=$doc_formats_list
+else
+ doc_formats=`echo $doc_formats | sed 's/,/ /g'`
+fi
+
+# set have_xmlto* to true if requested and possible
+if $have_xmlto; then
+ for i in $doc_formats; do
+ if test -n "`echo $doc_formats_list | $GREP -E \"(^| )$i( |\$)\"`"; then
+ eval "have_xmlto$i=true"
+ else
+ AC_ERROR(Unknown doc format $i!)
+ fi
+ done
+ AC_MSG_RESULT($doc_formats)
+else
+ AC_MSG_RESULT([deactivated (requires xmlto)])
+fi
+
+# Make sure that xmltopdf actually works
+if $have_xmltopdf; then
+ AC_MSG_CHECKING([whether pdf creation works])
+ oldcwd="$(pwd)"
+ top_srcdir() { echo "$srcdir"; }
+ mkdir test-pdf
+ cd test-pdf
+ cat>test-db.xml<<EOF
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+<book id="foobook">
+ <bookinfo>
+ <title>Foo Title</title>
+ </bookinfo>
+ <chapter id="foochapter">
+ <title>Foo Chapter</title>
+ <para>
+ Foo bar blah blah
+ <!--ulink url="https://www.hypothetical-url.invalid/with&amp;ersand">ampersand</ulink-->.
+ </para>
+ </chapter>
+</book>
+EOF
+ ${PURE_XMLTO} pdf -o . test-db.xml --searchpath ..
+ if test -s test-db.pdf; then
+ AC_MSG_RESULT([yes, look at $(pwd)/test-db.pdf to verify])
+ else
+ if $have_xmltopdf; then
+ AC_MSG_ERROR([PDF creation requested, but failed. See $(pwd) ...])
+ else
+ AC_MSG_RESULT([no, but not requested])
+ fi
+ fi
+ cd "$oldcwd"
+ unset top_srcdir
+fi
+
+AM_CONDITIONAL(XMLTOHTML,$have_xmltohtml)
+AM_CONDITIONAL(XMLTOMAN,$have_xmltoman)
+AM_CONDITIONAL(XMLTOTXT,$have_xmltotxt)
+AM_CONDITIONAL(XMLTOTXT2,$have_xmltotxt && $have_w3m)
+AM_CONDITIONAL(XMLTOPDF,$have_xmltopdf)
+AM_CONDITIONAL(XMLTOPS,$have_xmltops)
+
+# create list of supported formats
+AC_MSG_CHECKING([for manual formats to re­create])
+xxx=""
+manual_html=""
+manual_pdf=""
+manual_ps=""
+if $have_xmltohtml; then
+ xxx="${xxx} html"
+fi
+if $have_xmltoman; then
+ xxx="${xxx} man"
+fi
+if $have_xmltopdf; then
+ xxx="${xxx} pdf"
+fi
+if $have_xmltops; then
+ xxx="${xxx} ps"
+fi
+if $have_xmltotxt; then
+ xxx="${xxx} txt"
+fi
+AC_SUBST(manual_html)
+AC_SUBST(manual_pdf)
+AC_SUBST(manual_ps)
+AC_MSG_RESULT($xxx)
+
+if test "x$xxx" != "x"
+then
+ if $have_fig2dev; then
+ fig_out=""
+ else
+ fig_out="out"
+ fi
+ manual_msg="in (${xxx} ) formats with${fig_out} figures"
+fi
+
+])dnl
diff --git a/gphoto-m4/gp-manual-fig2dev.m4 b/gphoto-m4/gp-manual-fig2dev.m4
new file mode 100644
index 000000000..c61f2b7fe
--- /dev/null
+++ b/gphoto-m4/gp-manual-fig2dev.m4
@@ -0,0 +1,40 @@
+dnl ---------------------------------------------------------------------------
+dnl fig2dev: This program is needed for processing images. If not found,
+dnl documentation can still be built, but without figures.
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([GP_CHECK_FIG2DEV],
+[
+
+try_fig2dev=true
+have_fig2dev=false
+AC_ARG_WITH(fig2dev, [ --without-fig2dev Don't use fig2dev],[
+ if test "x$withval" = "xno"; then
+ try_fig2dev=false
+ fi])
+if $try_fig2dev; then
+ AC_PATH_PROG(FIG2DEV,fig2dev)
+ if test -n "${FIG2DEV}"; then
+ have_fig2dev=true
+ fi
+fi
+if $have_fig2dev; then
+ AC_SUBST(FIG2DEV)
+ ${FIG2DEV} -L ps > /dev/null <<EOF
+#FIG 3.2
+Landscape
+Center
+Inches
+Letter
+100.00
+Single
+-2
+1200 2
+1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 3000 3750 270 270 3000 3750 3150 3975
+EOF
+ if test $? != 0; then
+ have_fig2dev=false
+ fi
+fi
+AM_CONDITIONAL(ENABLE_FIGURES, $have_fig2dev)
+
+])
diff --git a/gphoto-m4/gp-manual-graphviz.m4 b/gphoto-m4/gp-manual-graphviz.m4
new file mode 100644
index 000000000..08e162d49
--- /dev/null
+++ b/gphoto-m4/gp-manual-graphviz.m4
@@ -0,0 +1,49 @@
+dnl ---------------------------------------------------------------------------
+dnl dot: This program is needed for processing images. If not found,
+dnl documentation can still be built, but without figures.
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([GP_CHECK_DOT],
+[
+
+try_dot=true
+have_dot=false
+AC_ARG_WITH(dot, AS_HELP_STRING([--without-dot], [Do not use dot]), [
+ if test "x$withval" = "xno"; then
+ try_dot=false
+ fi])
+if $try_dot; then
+ AC_PATH_PROG(DOT,dot)
+ if test -n "${DOT}"; then
+ have_dot=true
+ fi
+fi
+if $have_dot; then
+ AC_SUBST(DOT)
+ AC_MSG_CHECKING([whether ${DOT} works])
+ ${DOT} -Tps -o tesseract.ps 2> /dev/null <<EOF
+graph tesseract {
+ node [[shape=point]];
+ o -- {a;b;c;d;}
+ a -- {ab;ac;ad;}
+ b -- {ab;bc;bd;}
+ c -- {ac;bc;cd;}
+ d -- {ad;bd;cd;}
+ ab -- {abc;abd;}
+ ac -- {abc;acd;}
+ ad -- {abd;acd;}
+ bc -- {abc;bcd;}
+ bd -- {abd;bcd;}
+ cd -- {acd;bcd;}
+ {abc;abd;acd;bcd;} -- abcd;
+}
+EOF
+ if test $? != 0 || test ! -f tesseract.ps; then
+ have_dot=false
+ AC_MSG_RESULT([no (see http://www.graphviz.org/ ...)])
+ else
+ AC_MSG_RESULT(yes)
+ fi
+fi
+AM_CONDITIONAL(ENABLE_GRAPHS, $have_dot)
+
+])
diff --git a/gphoto-m4/gp-manual-gtk-doc.m4 b/gphoto-m4/gp-manual-gtk-doc.m4
new file mode 100644
index 000000000..8bca629d1
--- /dev/null
+++ b/gphoto-m4/gp-manual-gtk-doc.m4
@@ -0,0 +1,24 @@
+dnl ---------------------------------------------------------------------------
+dnl gtk-doc: We use gtk-doc for building our documentation. However, we
+dnl require the user to explicitely request the build.
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([GP_CHECK_GTK_DOC],
+[
+try_gtkdoc=false
+gtkdoc_msg="no (not requested)"
+have_gtkdoc=false
+AC_ARG_ENABLE(docs, [ --enable-docs Use gtk-doc to build documentation [default=no]],[
+ if test x$enableval = xyes; then
+ try_gtkdoc=true
+ fi])
+if $try_gtkdoc; then
+ AC_PATH_PROG(GTKDOC,gtkdoc-mkdb)
+ if test -n "${GTKDOC}"; then
+ have_gtkdoc=true
+ gtkdoc_msg="yes"
+ else
+ gtkdoc_msg="no (http://www.gtk.org/rdp/download.html)"
+ fi
+fi
+AM_CONDITIONAL(ENABLE_GTK_DOC, $have_gtkdoc)
+])
diff --git a/gphoto-m4/gp-manual-pstoimg.m4 b/gphoto-m4/gp-manual-pstoimg.m4
new file mode 100644
index 000000000..8d40690cd
--- /dev/null
+++ b/gphoto-m4/gp-manual-pstoimg.m4
@@ -0,0 +1,36 @@
+dnl ---------------------------------------------------------------------------
+dnl pstoimg: This program is needed for processing images. If not found,
+dnl documentation can still be built, but without figures.
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([GP_CHECK_PSTOIMG],
+[
+AC_REQUIRE([GP_CHECK_DOT])dnl for creating tesseract.ps
+
+try_pstoimg=true
+have_pstoimg=false
+AC_ARG_WITH(pstoimg, AS_HELP_STRING([--without-pstoimg], [Do not use pstoimg]),[
+ if test "x$withval" = "xno"; then
+ try_pstoimg=false
+ fi])
+if $try_pstoimg; then
+ AC_PATH_PROG(PSTOIMG,pstoimg)
+ if test -n "${PSTOIMG}"; then
+ have_pstoimg=true
+ fi
+fi
+if $have_pstoimg; then
+ AC_SUBST(PSTOIMG)
+ AC_MSG_CHECKING([whether ${PSTOIMG} works])
+ rm -f tesseract.png
+ ${PSTOIMG} -type png -scale 1.2 -antialias -crop a tesseract.ps > /dev/null
+ if test $? != 0 || test ! -f tesseract.png; then
+ have_pstoimg=false
+ AC_MSG_RESULT(no)
+ else
+ AC_MSG_RESULT(yes)
+ fi
+ rm -f tesseract.png
+fi
+AM_CONDITIONAL(ENABLE_PSTOIMG, $have_pstoimg)
+
+])
diff --git a/gphoto-m4/gp-manual-w3m.m4 b/gphoto-m4/gp-manual-w3m.m4
new file mode 100644
index 000000000..e563d7b90
--- /dev/null
+++ b/gphoto-m4/gp-manual-w3m.m4
@@ -0,0 +1,45 @@
+dnl ---------------------------------------------------------------------------
+dnl w3m: This program is needed for converting HTML to text.
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([GP_CHECK_W3M],
+[
+
+try_w3m=true
+have_w3m=false
+AC_ARG_WITH(w3m, [ --without-w3m Don't use w3m],[
+ if test "x$withval" = "xno"; then
+ try_w3m=false
+ fi])
+if $try_w3m; then
+ AC_PATH_PROG(W3M,w3m)
+ if test -n "${W3M}"; then
+ have_w3m=true
+ fi
+fi
+if $have_w3m; then
+ AC_MSG_CHECKING([whether ${W3M} works])
+ cat > html2text-test.xxxhtml 2> /dev/null <<EOF
+<html>
+<title>
+<h1>HTML2TEXT Test</h1>
+</title>
+<body>
+<p>This is a test.</p>
+</body>
+</html>
+EOF
+ ${W3M} -T text/html -cols 78 -dump html2text-test.xxxhtml > html2text-test.txt
+ if test $? != 0 || test ! -f html2text-test.txt || test ! -s html2text-test.txt
+ then
+ have_w3m=false
+ AC_MSG_RESULT([no (see http://www.w3m.org/ or http://w3m.sourceforge.net/ ...)])
+ W3M=false
+ AC_SUBST(W3M)
+ else
+ AC_MSG_RESULT([yes])
+ AC_SUBST(W3M)
+ fi
+fi
+AM_CONDITIONAL([HAVE_W3M], [$have_w3m])
+
+])
diff --git a/gphoto-m4/gp-packaging.m4 b/gphoto-m4/gp-packaging.m4
new file mode 100644
index 000000000..d85b418a2
--- /dev/null
+++ b/gphoto-m4/gp-packaging.m4
@@ -0,0 +1,81 @@
+AC_DEFUN([GPKG_CHECK_RPM],
+[
+AC_ARG_WITH([rpmbuild],
+[AS_HELP_STRING([--with-rpmbuild=PATH],
+[Program to use for building RPMs])])
+
+AC_MSG_CHECKING([for rpmbuild or rpm])
+if test -x "${with_rpmbuild}"
+then
+ RPMBUILD="${with_rpmbuild}"
+ AC_MSG_RESULT([${RPMBUILD} (from parameter)])
+else
+ AC_MSG_RESULT([using autodetection])
+ AC_CHECK_PROGS(RPMBUILD, [rpmbuild rpm], false)
+ AC_MSG_CHECKING([for rpmbuild or rpm])
+ AC_MSG_RESULT([${RPMBUILD} (autodetected)])
+fi
+AC_SUBST([RPMBUILD])
+AM_CONDITIONAL([ENABLE_RPM], [test "$RPMBUILD" != "false"])
+
+])
+
+AC_DEFUN([GPKG_CHECK_LINUX],
+[
+ # effective_target has to be determined in advance
+ AC_REQUIRE([AC_NEED_BYTEORDER_H])
+
+ is_linux=false
+ case "$effective_target" in
+ *linux*)
+ is_linux=true
+ ;;
+ esac
+ AM_CONDITIONAL([HAVE_LINUX], ["$is_linux"])
+
+ # required for docdir
+ # FIXME: Implicit dependency
+ # AC_REQUIRE(GP_CHECK_DOC_DIR)
+
+ AC_ARG_WITH([hotplug-doc-dir],
+ [AS_HELP_STRING([--with-hotplug-doc-dir=PATH],
+ [Where to install hotplug scripts as docs [default=autodetect]])])
+
+ if "$is_linux"; then
+ AC_MSG_CHECKING([for hotplug doc dir])
+ if test "x${with_hotplug_doc_dir}" != "x"
+ then # given as parameter
+ hotplugdocdir="${with_hotplug_doc_dir}"
+ AC_MSG_RESULT([${hotplugdocdir} (from parameter)])
+ else # start at docdir
+ hotplugdocdir="${docdir}/linux-hotplug"
+ AC_MSG_RESULT([${hotplugdocdir} (default)])
+ fi
+ else
+ hotplugdocdir=""
+ fi
+
+ AC_ARG_WITH([hotplug-usermap-dir],
+ [AS_HELP_STRING([--with-hotplug-usermap-dir=PATH],
+ [Where to install hotplug scripts as docs [default=autodetect]])])
+
+ if "$is_linux"; then
+ AC_MSG_CHECKING([for hotplug usermap dir])
+ if test "x${with_hotplug_usermap_dir}" != "x"
+ then # given as parameter
+ hotplugusermapdir="${with_hotplug_usermap_dir}"
+ AC_MSG_RESULT([${hotplugusermapdir} (from parameter)])
+ else # start at docdir
+ hotplugusermapdir="${docdir}/linux-hotplug"
+ AC_MSG_RESULT([${hotplugusermapdir} (default)])
+ fi
+ else
+ hotplugusermapdir=""
+ fi
+
+ # Let us hope that automake does not create "" directories
+ # on non-Linux systems now.
+ AC_SUBST([hotplugdocdir])
+ AC_SUBST([hotplugusermapdir])
+])
+
diff --git a/gphoto-m4/gp-pkg-config.m4 b/gphoto-m4/gp-pkg-config.m4
new file mode 100644
index 000000000..531bfe476
--- /dev/null
+++ b/gphoto-m4/gp-pkg-config.m4
@@ -0,0 +1,42 @@
+dnl @synopsis GP_PKG_CONFIG
+dnl
+dnl If you want to set the PKG_CONFIG_PATH, best do so before
+dnl calling GP_PKG_CONFIG
+AC_DEFUN([GP_PKG_CONFIG],[
+#
+# [GP_PKG_CONFIG]
+#
+AC_ARG_VAR([PKG_CONFIG],[pkg-config package config utility])
+export PKG_CONFIG
+AC_ARG_VAR([PKG_CONFIG_PATH],[directory where pkg-config looks for *.pc files])
+export PKG_CONFIG_PATH
+
+AC_MSG_CHECKING([PKG_CONFIG_PATH])
+if test "x${PKG_CONFIG_PATH}" = "x"; then
+ AC_MSG_RESULT([empty])
+else
+ AC_MSG_RESULT([${PKG_CONFIG_PATH}])
+fi
+
+dnl AC_REQUIRE([PKG_CHECK_MODULES])
+AC_PATH_PROG([PKG_CONFIG],[pkg-config],[false])
+if test "$PKG_CONFIG" = "false"; then
+AC_MSG_ERROR([
+*** Build requires pkg-config
+***
+*** Possible solutions:
+*** - set PKG_CONFIG to where your pkg-config is located
+*** - set PATH to include the directory where pkg-config is installed
+*** - get it from http://freedesktop.org/software/pkgconfig/ and install it
+])
+fi
+])dnl
+
+dnl Please do not remove this:
+dnl filetype: d87b877b-80ec-447c-b042-21ec4a27c6f0
+dnl I use this to find all the different instances of this file which
+dnl are supposed to be synchronized.
+
+dnl Local Variables:
+dnl mode: autoconf
+dnl End:
diff --git a/gphoto-m4/gp-references.m4 b/gphoto-m4/gp-references.m4
new file mode 100644
index 000000000..fca98f14e
--- /dev/null
+++ b/gphoto-m4/gp-references.m4
@@ -0,0 +1,48 @@
+dnl
+dnl Define external references
+dnl
+dnl Define once, use many times.
+dnl No more URLs and Mail addresses in translated strings and stuff.
+dnl
+
+AC_DEFUN([GP_REF],[
+AC_SUBST([$1],["$2"])
+AC_DEFINE_UNQUOTED([$1],["$2"],[$3])
+])
+
+AC_DEFUN([GP_REFERENCES],
+[
+
+GP_REF( [URL_GPHOTO_HOME],
+ [http://www.gphoto.org/],
+ [gphoto project home page])dnl
+
+GP_REF( [URL_GPHOTO_PROJECT],
+ [http://sourceforge.net/projects/gphoto],
+ [gphoto sourceforge project page])
+
+GP_REF( [URL_DIGICAM_LIST],
+ [http://www.teaser.fr/~hfiguiere/linux/digicam.html],
+ [camera list with support status])
+
+GP_REF( [URL_JPHOTO_HOME],
+ [http://jphoto.sourceforge.net/],
+ [jphoto home page])
+
+GP_REF( [URL_USB_MASSSTORAGE],
+ [http://www.linux-usb.org/USB-guide/x498.html],
+ [information about using USB mass storage])
+
+GP_REF( [MAIL_GPHOTO_DEVEL],
+ [<gphoto-devel@lists.sourceforge.net>],
+ [gphoto development mailing list])
+
+GP_REF( [MAIL_GPHOTO_USER],
+ [<gphoto-user@lists.sourceforge.net>],
+ [gphoto user mailing list])
+
+GP_REF( [MAIL_GPHOTO_TRANSLATION],
+ [<gphoto-translation@lists.sourceforge.net>],
+ [gphoto translation mailing list])
+
+])
diff --git a/gphoto-m4/gp-stdint.m4 b/gphoto-m4/gp-stdint.m4
new file mode 100644
index 000000000..d3e59249b
--- /dev/null
+++ b/gphoto-m4/gp-stdint.m4
@@ -0,0 +1,732 @@
+dnl AC_NEED_STDINT_H ( HEADER-TO-GENERATE )
+dnl Originally written 2001 by Dan Fandrich <dan@coneharvesters.com>
+dnl My contribution is hereby placed into the public domain.
+dnl No warranty is expressed or implied.
+dnl
+dnl Look for a header file that defines size-specific integer types like the
+dnl ones recommended to be in stdint.h in the C99 standard (e.g. uint32_t).
+dnl This is a dumbed-down version of the macro of the same name in the file
+dnl ac_need_stdint_h.m4 which is part of the ac-archive, available at
+dnl <URL:http://ac-archive.sourceforge.net/> (also, another macro
+dnl AC_CREATE_STDINT_H by the same author). This version is not as smart,
+dnl but works on older autoconf versions and has a different license.
+
+dnl AX_CHECK_DEFINED_TYPE ( TYPE, FILE, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND )
+dnl This is similar to _AC_CHECK_TYPE_NEW (a.k.a. new syntax version of
+dnl AC_CHECK_TYPE) in autoconf 2.50 but works on older versions
+AC_DEFUN([AX_CHECK_DEFINED_TYPE],
+[AC_MSG_CHECKING([for $1 in $2])
+AC_EGREP_CPP(changequote(<<,>>)dnl
+<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
+changequote([,]), [#include <$2>],
+ac_cv_type_$1=yes, ac_cv_type_$1=no)dnl
+AC_MSG_RESULT($ac_cv_type_$1)
+if test $ac_cv_type_$1 = yes; then
+ $3
+else
+ $4
+fi
+])
+
+dnl Look for a header file that defines size-specific integer types
+AC_DEFUN([AX_NEED_STDINT_H],
+[
+ac_dir=`AS_DIRNAME(["$1"])`
+if test "$ac_dir" != "$1" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && AS_MKDIR_P(["$ac_dir"])
+fi
+
+AX_CHECK_DEFINED_TYPE(uint8_t,
+stdint.h,
+[
+cat > "$1" <<EOF
+/* This file is generated automatically by configure */
+#include <stdint.h>
+EOF],
+[AX_CHECK_DEFINED_TYPE(uint8_t,
+inttypes.h,
+[cat > "$1" <<EOF
+/* This file is generated automatically by configure */
+#include <inttypes.h>
+EOF],
+[AX_CHECK_DEFINED_TYPE(uint8_t,
+sys/types.h,
+[cat > "$1" <<EOF
+/* This file is generated automatically by configure */
+#include <sys/types.h>
+EOF],
+[AX_CHECK_DEFINED_TYPE(u_int8_t,
+sys/types.h,
+[cat > "$1" <<EOF
+/* This file is generated automatically by configure */
+#ifndef __STDINT_H
+#define __STDINT_H
+#include <sys/types.h>
+typedef u_int8_t uint8_t;
+typedef u_int16_t uint16_t;
+typedef u_int32_t uint32_t;
+EOF
+
+AX_CHECK_DEFINED_TYPE(u_int64_t,
+sys/types.h,
+[cat >> "$1" <<EOF
+typedef u_int64_t uint64_t;
+#endif /*!__STDINT_H*/
+EOF],
+[cat >> "$1" <<EOF
+/* 64-bit types are not available on this system */
+/* typedef u_int64_t uint64_t; */
+#endif /*!__STDINT_H*/
+EOF])
+
+],
+[AC_MSG_WARN([I can't find size-specific integer definitions on this system])
+if test -e "$1" ; then
+ rm -f "$1"
+fi
+])])])])dnl
+])
+
+AC_DEFUN([AX_CHECK_DATA_MODEL],[
+ AC_CHECK_SIZEOF(char)
+ AC_CHECK_SIZEOF(short)
+ AC_CHECK_SIZEOF(int)
+ AC_CHECK_SIZEOF(long)
+ AC_CHECK_SIZEOF(void*)
+ ac_cv_char_data_model=""
+ ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char"
+ ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short"
+ ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int"
+ ac_cv_long_data_model=""
+ ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int"
+ ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long"
+ ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp"
+ AC_MSG_CHECKING([data model])
+ case "$ac_cv_char_data_model/$ac_cv_long_data_model" in
+ 122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;;
+ 122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;;
+ 122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;;
+ 124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;;
+ 124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;;
+ 124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;;
+ 124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;;
+ 128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;;
+ 128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;;
+ 222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;;
+ 333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;;
+ 444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;;
+ 666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;;
+ 888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;;
+ 222/*|333/*|444/*|666/*|888/*) :
+ ac_cv_data_model="iDSP" ; n="unusual dsptype" ;;
+ *) ac_cv_data_model="none" ; n="very unusual model" ;;
+ esac
+ AC_MSG_RESULT([$ac_cv_data_model ($ac_cv_long_data_model, $n)])
+])
+
+dnl AX_CHECK_HEADER_STDINT_X([HEADERLIST][,ACTION-IF])
+AC_DEFUN([AX_CHECK_HEADER_STDINT_X],[
+AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
+ ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
+ AC_MSG_RESULT([(..)])
+ for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h]) ; do
+ unset ac_cv_type_uintptr_t
+ unset ac_cv_type_uint64_t
+ AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>])
+ AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
+ m4_ifvaln([$1],[$1]) break
+ done
+ AC_MSG_CHECKING([for stdint uintptr_t])
+ ])
+])
+
+AC_DEFUN([AX_CHECK_HEADER_STDINT_O],[
+AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
+ ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
+ AC_MSG_RESULT([(..)])
+ for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h stdint.h]) ; do
+ unset ac_cv_type_uint32_t
+ unset ac_cv_type_uint64_t
+ AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>])
+ AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
+ m4_ifvaln([$1],[$1]) break
+ break;
+ done
+ AC_MSG_CHECKING([for stdint uint32_t])
+ ])
+])
+
+AC_DEFUN([AX_CHECK_HEADER_STDINT_U],[
+AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
+ ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
+ AC_MSG_RESULT([(..)])
+ for i in m4_ifval([$1],[$1],[sys/types.h inttypes.h sys/inttypes.h]) ; do
+ unset ac_cv_type_u_int32_t
+ unset ac_cv_type_u_int64_t
+ AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],continue,[#include <$i>])
+ AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
+ m4_ifvaln([$1],[$1]) break
+ break;
+ done
+ AC_MSG_CHECKING([for stdint u_int32_t])
+ ])
+])
+
+AC_DEFUN([AX_CREATE_STDINT_H],
+[# ------ AX CREATE STDINT H -------------------------------------
+AC_MSG_CHECKING([for stdint types])
+ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
+# try to shortcircuit - if the default include path of the compiler
+# can find a "stdint.h" header then we assume that all compilers can.
+AC_CACHE_VAL([ac_cv_header_stdint_t],[
+old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
+old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
+old_CFLAGS="$CFLAGS" ; CFLAGS=""
+AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
+[ac_cv_stdint_result="(assuming C99 compatible system)"
+ ac_cv_header_stdint_t="stdint.h"; ],
+[ac_cv_header_stdint_t=""])
+CXXFLAGS="$old_CXXFLAGS"
+CPPFLAGS="$old_CPPFLAGS"
+CFLAGS="$old_CFLAGS" ])
+
+v="... $ac_cv_header_stdint_h"
+if test "$ac_stdint_h" = "stdint.h" ; then
+ AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
+elif test "$ac_stdint_h" = "inttypes.h" ; then
+ AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
+elif test "_$ac_cv_header_stdint_t" = "_" ; then
+ AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
+else
+ ac_cv_header_stdint="$ac_cv_header_stdint_t"
+ AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
+fi
+
+if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
+
+dnl .....intro message done, now do a few system checks.....
+dnl btw, all old CHECK_TYPE macros do automatically "DEFINE" a type,
+dnl therefore we use the autoconf implementation detail CHECK_TYPE_NEW
+dnl instead that is triggered with 3 or more arguments (see types.m4)
+
+inttype_headers=`echo $2 | sed -e 's/,/ /g'`
+
+ac_cv_stdint_result="(no helpful system typedefs seen)"
+AX_CHECK_HEADER_STDINT_X(dnl
+ stdint.h inttypes.h sys/inttypes.h $inttype_headers,
+ ac_cv_stdint_result="(seen uintptr_t$and64 in $i)")
+
+if test "_$ac_cv_header_stdint_x" = "_" ; then
+AX_CHECK_HEADER_STDINT_O(dnl,
+ inttypes.h sys/inttypes.h stdint.h $inttype_headers,
+ ac_cv_stdint_result="(seen uint32_t$and64 in $i)")
+fi
+
+if test "_$ac_cv_header_stdint_x" = "_" ; then
+if test "_$ac_cv_header_stdint_o" = "_" ; then
+AX_CHECK_HEADER_STDINT_U(dnl,
+ sys/types.h inttypes.h sys/inttypes.h $inttype_headers,
+ ac_cv_stdint_result="(seen u_int32_t$and64 in $i)")
+fi fi
+
+dnl if there was no good C99 header file, do some typedef checks...
+if test "_$ac_cv_header_stdint_x" = "_" ; then
+ AC_MSG_CHECKING([for stdint datatype model])
+ AC_MSG_RESULT([(..)])
+ AX_CHECK_DATA_MODEL
+fi
+
+if test "_$ac_cv_header_stdint_x" != "_" ; then
+ ac_cv_header_stdint="$ac_cv_header_stdint_x"
+elif test "_$ac_cv_header_stdint_o" != "_" ; then
+ ac_cv_header_stdint="$ac_cv_header_stdint_o"
+elif test "_$ac_cv_header_stdint_u" != "_" ; then
+ ac_cv_header_stdint="$ac_cv_header_stdint_u"
+else
+ ac_cv_header_stdint="stddef.h"
+fi
+
+AC_MSG_CHECKING([for extra inttypes in chosen header])
+AC_MSG_RESULT([($ac_cv_header_stdint)])
+dnl see if int_least and int_fast types are present in _this_ header.
+unset ac_cv_type_int_least32_t
+unset ac_cv_type_int_fast32_t
+AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
+AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
+AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
+
+fi # shortcircut to system "stdint.h"
+# ------------------ PREPARE VARIABLES ------------------------------
+if test "$GCC" = "yes" ; then
+ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
+else
+ac_cv_stdint_message="using $CC"
+fi
+
+AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
+$ac_cv_stdint_result])
+
+dnl -----------------------------------------------------------------
+# ----------------- DONE inttypes.h checks START header -------------
+AC_CONFIG_COMMANDS([$ac_stdint_h],[
+AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
+ac_stdint=$tmp/_stdint.h
+
+echo "#ifndef" $_ac_stdint_h >$ac_stdint
+echo "#define" $_ac_stdint_h "1" >>$ac_stdint
+echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
+echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
+echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
+if test "_$ac_cv_header_stdint_t" != "_" ; then
+echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
+echo "#include <stdint.h>" >>$ac_stdint
+echo "#endif" >>$ac_stdint
+echo "#endif" >>$ac_stdint
+else
+
+cat >>$ac_stdint <<STDINT_EOF
+
+/* ................... shortcircuit part ........................... */
+
+#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
+#include <stdint.h>
+#else
+#include <stddef.h>
+
+/* .................... configured part ............................ */
+
+STDINT_EOF
+
+echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
+if test "_$ac_cv_header_stdint_x" != "_" ; then
+ ac_header="$ac_cv_header_stdint_x"
+ echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
+else
+ echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
+fi
+
+echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
+if test "_$ac_cv_header_stdint_o" != "_" ; then
+ ac_header="$ac_cv_header_stdint_o"
+ echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
+else
+ echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
+fi
+
+echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
+if test "_$ac_cv_header_stdint_u" != "_" ; then
+ ac_header="$ac_cv_header_stdint_u"
+ echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
+else
+ echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
+fi
+
+echo "" >>$ac_stdint
+
+if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
+ echo "#include <$ac_header>" >>$ac_stdint
+ echo "" >>$ac_stdint
+fi fi
+
+echo "/* which 64bit typedef has been found */" >>$ac_stdint
+if test "$ac_cv_type_uint64_t" = "yes" ; then
+echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
+fi
+if test "$ac_cv_type_u_int64_t" = "yes" ; then
+echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
+fi
+echo "" >>$ac_stdint
+
+echo "/* which type model has been detected */" >>$ac_stdint
+if test "_$ac_cv_char_data_model" != "_" ; then
+echo "#define _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdint
+echo "#define _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdint
+else
+echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
+echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
+fi
+echo "" >>$ac_stdint
+
+echo "/* whether int_least types were detected */" >>$ac_stdint
+if test "$ac_cv_type_int_least32_t" = "yes"; then
+echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
+fi
+echo "/* whether int_fast types were detected */" >>$ac_stdint
+if test "$ac_cv_type_int_fast32_t" = "yes"; then
+echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
+fi
+echo "/* whether intmax_t type was detected */" >>$ac_stdint
+if test "$ac_cv_type_intmax_t" = "yes"; then
+echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
+else
+echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
+fi
+echo "" >>$ac_stdint
+
+ cat >>$ac_stdint <<STDINT_EOF
+/* .................... detections part ............................ */
+
+/* whether we need to define bitspecific types from compiler base types */
+#ifndef _STDINT_HEADER_INTPTR
+#ifndef _STDINT_HEADER_UINT32
+#ifndef _STDINT_HEADER_U_INT32
+#define _STDINT_NEED_INT_MODEL_T
+#else
+#define _STDINT_HAVE_U_INT_TYPES
+#endif
+#endif
+#endif
+
+#ifdef _STDINT_HAVE_U_INT_TYPES
+#undef _STDINT_NEED_INT_MODEL_T
+#endif
+
+#ifdef _STDINT_CHAR_MODEL
+#if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
+#ifndef _STDINT_BYTE_MODEL
+#define _STDINT_BYTE_MODEL 12
+#endif
+#endif
+#endif
+
+#ifndef _STDINT_HAVE_INT_LEAST32_T
+#define _STDINT_NEED_INT_LEAST_T
+#endif
+
+#ifndef _STDINT_HAVE_INT_FAST32_T
+#define _STDINT_NEED_INT_FAST_T
+#endif
+
+#ifndef _STDINT_HEADER_INTPTR
+#define _STDINT_NEED_INTPTR_T
+#ifndef _STDINT_HAVE_INTMAX_T
+#define _STDINT_NEED_INTMAX_T
+#endif
+#endif
+
+
+/* .................... definition part ............................ */
+
+/* some system headers have good uint64_t */
+#ifndef _HAVE_UINT64_T
+#if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
+#define _HAVE_UINT64_T
+#elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
+#define _HAVE_UINT64_T
+typedef u_int64_t uint64_t;
+#endif
+#endif
+
+#ifndef _HAVE_UINT64_T
+/* .. here are some common heuristics using compiler runtime specifics */
+#if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
+#define _HAVE_UINT64_T
+#define _HAVE_LONGLONG_UINT64_T
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+
+#elif !defined __STRICT_ANSI__
+#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
+#define _HAVE_UINT64_T
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+
+#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
+/* note: all ELF-systems seem to have loff-support which needs 64-bit */
+#if !defined _NO_LONGLONG
+#define _HAVE_UINT64_T
+#define _HAVE_LONGLONG_UINT64_T
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+#endif
+
+#elif defined __alpha || (defined __mips && defined _ABIN32)
+#if !defined _NO_LONGLONG
+typedef long int64_t;
+typedef unsigned long uint64_t;
+#endif
+ /* compiler/cpu type to define int64_t */
+#endif
+#endif
+#endif
+
+#if defined _STDINT_HAVE_U_INT_TYPES
+/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
+typedef u_int8_t uint8_t;
+typedef u_int16_t uint16_t;
+typedef u_int32_t uint32_t;
+
+/* glibc compatibility */
+#ifndef __int8_t_defined
+#define __int8_t_defined
+#endif
+#endif
+
+#ifdef _STDINT_NEED_INT_MODEL_T
+/* we must guess all the basic types. Apart from byte-adressable system, */
+/* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
+/* (btw, those nibble-addressable systems are way off, or so we assume) */
+
+dnl /* have a look at "64bit and data size neutrality" at */
+dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
+dnl /* (the shorthand "ILP" types always have a "P" part) */
+
+#if defined _STDINT_BYTE_MODEL
+#if _STDINT_LONG_MODEL+0 == 242
+/* 2:4:2 = IP16 = a normal 16-bit system */
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned long uint32_t;
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef char int8_t;
+typedef short int16_t;
+typedef long int32_t;
+#endif
+#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
+/* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
+/* 4:4:4 = ILP32 = a normal 32-bit system */
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+#endif
+#elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
+/* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
+/* 4:8:8 = LP64 = a normal 64-bit system */
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+#endif
+/* this system has a "long" of 64bit */
+#ifndef _HAVE_UINT64_T
+#define _HAVE_UINT64_T
+typedef unsigned long uint64_t;
+typedef long int64_t;
+#endif
+#elif _STDINT_LONG_MODEL+0 == 448
+/* LLP64 a 64-bit system derived from a 32-bit system */
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+#endif
+/* assuming the system has a "long long" */
+#ifndef _HAVE_UINT64_T
+#define _HAVE_UINT64_T
+#define _HAVE_LONGLONG_UINT64_T
+typedef unsigned long long uint64_t;
+typedef long long int64_t;
+#endif
+#else
+#define _STDINT_NO_INT32_T
+#endif
+#else
+#define _STDINT_NO_INT8_T
+#define _STDINT_NO_INT32_T
+#endif
+#endif
+
+/*
+ * quote from SunOS-5.8 sys/inttypes.h:
+ * Use at your own risk. As of February 1996, the committee is squarely
+ * behind the fixed sized types; the "least" and "fast" types are still being
+ * discussed. The probability that the "fast" types may be removed before
+ * the standard is finalized is high enough that they are not currently
+ * implemented.
+ */
+
+#if defined _STDINT_NEED_INT_LEAST_T
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+#ifdef _HAVE_UINT64_T
+typedef int64_t int_least64_t;
+#endif
+
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+#ifdef _HAVE_UINT64_T
+typedef uint64_t uint_least64_t;
+#endif
+ /* least types */
+#endif
+
+#if defined _STDINT_NEED_INT_FAST_T
+typedef int8_t int_fast8_t;
+typedef int int_fast16_t;
+typedef int32_t int_fast32_t;
+#ifdef _HAVE_UINT64_T
+typedef int64_t int_fast64_t;
+#endif
+
+typedef uint8_t uint_fast8_t;
+typedef unsigned uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+#ifdef _HAVE_UINT64_T
+typedef uint64_t uint_fast64_t;
+#endif
+ /* fast types */
+#endif
+
+#ifdef _STDINT_NEED_INTMAX_T
+#ifdef _HAVE_UINT64_T
+typedef int64_t intmax_t;
+typedef uint64_t uintmax_t;
+#else
+typedef long intmax_t;
+typedef unsigned long uintmax_t;
+#endif
+#endif
+
+#ifdef _STDINT_NEED_INTPTR_T
+#ifndef __intptr_t_defined
+#define __intptr_t_defined
+/* we encourage using "long" to store pointer values, never use "int" ! */
+#if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
+typedef unsinged int uintptr_t;
+typedef int intptr_t;
+#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
+typedef unsigned long uintptr_t;
+typedef long intptr_t;
+#elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
+typedef uint64_t uintptr_t;
+typedef int64_t intptr_t;
+#else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
+typedef unsigned long uintptr_t;
+typedef long intptr_t;
+#endif
+#endif
+#endif
+
+/* The ISO C99 standard specifies that in C++ implementations these
+ should only be defined if explicitly requested. */
+#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
+#ifndef UINT32_C
+
+/* Signed. */
+# define INT8_C(c) c
+# define INT16_C(c) c
+# define INT32_C(c) c
+# ifdef _HAVE_LONGLONG_UINT64_T
+# define INT64_C(c) c ## L
+# else
+# define INT64_C(c) c ## LL
+# endif
+
+/* Unsigned. */
+# define UINT8_C(c) c ## U
+# define UINT16_C(c) c ## U
+# define UINT32_C(c) c ## U
+# ifdef _HAVE_LONGLONG_UINT64_T
+# define UINT64_C(c) c ## UL
+# else
+# define UINT64_C(c) c ## ULL
+# endif
+
+/* Maximal type. */
+# ifdef _HAVE_LONGLONG_UINT64_T
+# define INTMAX_C(c) c ## L
+# define UINTMAX_C(c) c ## UL
+# else
+# define INTMAX_C(c) c ## LL
+# define UINTMAX_C(c) c ## ULL
+# endif
+
+ /* literalnumbers */
+#endif
+#endif
+
+/* These limits are merily those of a two complement byte-oriented system */
+
+/* Minimum of signed integral types. */
+# define INT8_MIN (-128)
+# define INT16_MIN (-32767-1)
+# define INT32_MIN (-2147483647-1)
+# define INT64_MIN (-__INT64_C(9223372036854775807)-1)
+/* Maximum of signed integral types. */
+# define INT8_MAX (127)
+# define INT16_MAX (32767)
+# define INT32_MAX (2147483647)
+# define INT64_MAX (__INT64_C(9223372036854775807))
+
+/* Maximum of unsigned integral types. */
+# define UINT8_MAX (255)
+# define UINT16_MAX (65535)
+# define UINT32_MAX (4294967295U)
+# define UINT64_MAX (__UINT64_C(18446744073709551615))
+
+/* Minimum of signed integral types having a minimum size. */
+# define INT_LEAST8_MIN INT8_MIN
+# define INT_LEAST16_MIN INT16_MIN
+# define INT_LEAST32_MIN INT32_MIN
+# define INT_LEAST64_MIN INT64_MIN
+/* Maximum of signed integral types having a minimum size. */
+# define INT_LEAST8_MAX INT8_MAX
+# define INT_LEAST16_MAX INT16_MAX
+# define INT_LEAST32_MAX INT32_MAX
+# define INT_LEAST64_MAX INT64_MAX
+
+/* Maximum of unsigned integral types having a minimum size. */
+# define UINT_LEAST8_MAX UINT8_MAX
+# define UINT_LEAST16_MAX UINT16_MAX
+# define UINT_LEAST32_MAX UINT32_MAX
+# define UINT_LEAST64_MAX UINT64_MAX
+
+ /* shortcircuit*/
+#endif
+ /* once */
+#endif
+#endif
+STDINT_EOF
+fi
+ if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
+ AC_MSG_NOTICE([$ac_stdint_h is unchanged])
+ else
+ ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
+ AS_MKDIR_P(["$ac_dir"])
+ rm -f $ac_stdint_h
+ mv $ac_stdint $ac_stdint_h
+ fi
+],[# variables for create stdint.h replacement
+PACKAGE="$PACKAGE"
+VERSION="$VERSION"
+ac_stdint_h="$ac_stdint_h"
+_ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
+ac_cv_stdint_message="$ac_cv_stdint_message"
+ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
+ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
+ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
+ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
+ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
+ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
+ac_cv_char_data_model="$ac_cv_char_data_model"
+ac_cv_long_data_model="$ac_cv_long_data_model"
+ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
+ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
+ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
+])
+])
diff --git a/gphoto-m4/gp-subpackage.m4 b/gphoto-m4/gp-subpackage.m4
new file mode 100644
index 000000000..afabd8b17
--- /dev/null
+++ b/gphoto-m4/gp-subpackage.m4
@@ -0,0 +1,5 @@
+AC_DEFUN([GP_SUBPACKAGE],
+[
+AC_ARG_VAR([enable_subpackage_][$1], [enable subpackage ][$1][ (true or false)])
+test "x${[enable_subpackage_][$1]}" = "x" && [enable_subpackage_][$1]=true
+])dnl
diff --git a/gphoto-m4/gp-udev.m4 b/gphoto-m4/gp-udev.m4
new file mode 100644
index 000000000..ef5ecb52c
--- /dev/null
+++ b/gphoto-m4/gp-udev.m4
@@ -0,0 +1,9 @@
+dnl Determines whether UDEV code should be compiled.
+dnl $1 contains shell code that returns 0 if all other prerequisites (like
+dnl libusb) are available.
+AC_DEFUN([GP_UDEV],[dnl
+if test "x${udevscriptdir}" = "x"; then udevscriptdir="\${libdir}/udev"; fi
+AC_ARG_VAR([udevscriptdir],[Directory where udev scripts like check-ptp-camera will be installed])
+AC_SUBST([udevscriptdir])
+AM_CONDITIONAL([HAVE_UDEV],[if echo "$host"|grep -i linux >/dev/null ; then $1; fi ])
+])dnl
diff --git a/gphoto-m4/gp-va-copy.m4 b/gphoto-m4/gp-va-copy.m4
new file mode 100644
index 000000000..8b1ac85c7
--- /dev/null
+++ b/gphoto-m4/gp-va-copy.m4
@@ -0,0 +1,57 @@
+dnl @synopsis GP_VA_COPY
+dnl
+dnl Checks whether one of these compiles and links:
+dnl 1. va_copy()
+dnl 2. __va_copy()
+dnl 3. fallback
+dnl
+dnl In case of 1 or 2, AC_DEFINE(HAVE_VA_COPY).
+dnl In case of 2, AC_DEFINE(va_copy,__va_copy)
+dnl
+dnl In code, use it like this
+dnl #ifdef HAVE_VA_COPY
+dnl ... code with va_copy ...
+dnl #else
+dnl ... code without va_copy or with error ...
+dnl #endif
+dnl
+AC_DEFUN([GP_VA_COPY],[dnl
+dnl
+AC_CHECK_HEADER([stdarg.h],[],[
+ AC_MSG_ERROR([
+Building $PACKAGE_NAME requires <stdarg.h>.
+])
+])
+dnl
+have_va_copy=no
+AC_TRY_LINK([
+ #include <stdarg.h>
+],[
+ va_list a,b;
+ va_copy(a,b);
+],[
+ have_va_copy="va_copy"
+],[
+ AC_TRY_LINK([
+ #include <stdarg.h>
+ ],[
+ 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])
+ ])
+])
+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
+])dnl
+dnl
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl End: