common macros in m4m/
authorHans Ulrich Niedermann <hun@n-dimensional.de>
Sat, 9 Apr 2005 20:18:59 +0000 (22:18 +0200)
committerHans Ulrich Niedermann <hun@n-dimensional.de>
Sat, 9 Apr 2005 20:18:59 +0000 (22:18 +0200)
13 files changed:
m4m/.gitignore [new file with mode: 0644]
m4m/Makefile.am [new file with mode: 0644]
m4m/gp-byteorder.m4 [new file with mode: 0644]
m4m/gp-check-library.m4 [new file with mode: 0644]
m4m/gp-check-popt.m4 [new file with mode: 0644]
m4m/gp-check-shell-environment.m4 [new file with mode: 0644]
m4m/gp-config-msg.m4 [new file with mode: 0644]
m4m/gp-documentation.m4 [new file with mode: 0644]
m4m/gp-gettext-hack.m4 [new file with mode: 0644]
m4m/gp-packaging.m4 [new file with mode: 0644]
m4m/gp-pkg-config.m4 [new file with mode: 0644]
m4m/gp-references.m4 [new file with mode: 0644]
m4m/stdint.m4 [new file with mode: 0644]

diff --git a/m4m/.gitignore b/m4m/.gitignore
new file mode 100644 (file)
index 0000000..9911b4b
--- /dev/null
@@ -0,0 +1,31 @@
+Makefile
+Makefile.in
+autom4te.cache
+codeset.m4
+gettext.m4
+glibc21.m4
+iconv.m4
+intdiv0.m4
+intmax.m4
+inttypes-pri.m4
+inttypes.m4
+inttypes_h.m4
+isc-posix.m4
+lcmessage.m4
+lib-ld.m4
+lib-link.m4
+lib-prefix.m4
+longdouble.m4
+longlong.m4
+nls.m4
+po.m4
+printf-posix.m4
+progtest.m4
+signed.m4
+size_max.m4
+stdint_h.m4
+uintmax_t.m4
+ulonglong.m4
+wchar_t.m4
+wint_t.m4
+xsize.m4
diff --git a/m4m/Makefile.am b/m4m/Makefile.am
new file mode 100644 (file)
index 0000000..297314a
--- /dev/null
@@ -0,0 +1 @@
+EXTRA_DIST = gp-byteorder.m4 gp-check-library.m4 gp-check-popt.m4 gp-check-shell-environment.m4 gp-config-msg.m4 gp-documentation.m4 gp-gettext-hack.m4 gp-packaging.m4 gp-pkg-config.m4 gp-references.m4 stdint.m4
diff --git a/m4m/gp-byteorder.m4 b/m4m/gp-byteorder.m4
new file mode 100644 (file)
index 0000000..693f939
--- /dev/null
@@ -0,0 +1,354 @@
+dnl AC_NEED_BYTEORDER_H ( HEADER-TO-GENERATE )
+dnl Copyright 2001-2002 by Dan Fandrich <dan@coneharvesters.com>
+dnl This file may be copied and used freely without restrictions.  No warranty
+dnl 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],
+[
+changequote(, )dnl
+ac_dir=`echo $1|sed 's%/[^/][^/]*$%%'`
+changequote([, ])dnl
+if test "$ac_dir" != "$1" && test "$ac_dir" != .; then
+  # The file is in a subdirectory.
+  test ! -d "$ac_dir" && mkdir "$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>
+
+EOF],
+
+ [AC_HAVE_SYMBOL(ntohl,netinet/in.h,
+  [cat >> "$1" << EOF
+/* ntohl and relatives live here */
+#include <netinet/in.h>
+
+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 */
+#define swap16(x)              ntohs(x)
+#define swap32(x)              ntohl(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
+       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 */
+#define htobe16(x) htons(x)
+#define htobe32(x) htonl(x)
+#define be16toh(x) ntohs(x)
+#define be32toh(x) ntohl(x)
+
+#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 */
+#define htole16(x)      swap16(x)
+#define htole32(x)      swap32(x)
+#define le16toh(x)      swap16(x)
+#define le32toh(x)      swap32(x)
+
+#define htobe64(x)      (x)
+#define be64toh(x)      (x)
+
+#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 HTOBE64(x)      (void) (x)
+#define BE64TOH(x)      (void) (x)
+
+EOF
+ else
+  cat >> "$1" << EOF
+/* On little endian machines, these macros are null */
+#define htole16(x)      (x)
+#define htole32(x)      (x)
+#define htole64(x)      (x)
+#define le16toh(x)      (x)
+#define le32toh(x)      (x)
+#define le64toh(x)      (x)
+
+#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 */
+#define htobe64(x)      swap64(x)
+#define be64toh(x)      swap64(x)
+
+#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 */
+#define be16atoh(x)     be16toh(*(uint16_t*)(x))
+#define be32atoh(x)     be32toh(*(uint32_t*)(x))
+#define be64atoh(x)     be64toh(*(uint64_t*)(x))
+#define le16atoh(x)     le16toh(*(uint16_t*)(x))
+#define le32atoh(x)     le32toh(*(uint32_t*)(x))
+#define le64atoh(x)     le64toh(*(uint64_t*)(x))
+
+#define htobe16a(a,x)   *(uint16_t*)(a) = htobe16(x)
+#define htobe32a(a,x)   *(uint32_t*)(a) = htobe32(x)
+#define htobe64a(a,x)   *(uint64_t*)(a) = htobe64(x)
+#define htole16a(a,x)   *(uint16_t*)(a) = htole16(x)
+#define htole32a(a,x)   *(uint32_t*)(a) = htole32(x)
+#define htole64a(a,x)   *(uint64_t*)(a) = htole64(x)
+
+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)     ((uint64_t)(((x)[0]<<56)|((x)[1]<<48)|((x)[2]<<40)| \\
+        ((x)[3]<<32)|((x)[4]<<24)|((x)[5]<<16)|((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)     ((uint64_t)(((x)[7]<<56)|((x)[6]<<48)|((x)[5]<<40)| \\
+        ((x)[4]<<32)|((x)[3]<<24)|((x)[2]<<16)|((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/m4m/gp-check-library.m4 b/m4m/gp-check-library.m4
new file mode 100644 (file)
index 0000000..1799f89
--- /dev/null
@@ -0,0 +1,295 @@
+dnl @synopsis GP_CHECK_LIBRARY([VARNAMEPART],[libname],[VERSION-REQUIREMENT],[headername],[functionname],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],[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                           default: [mandatory]
+dnl    WHERE-TO-GET-IT        place where to find the library
+dnl                           default: []
+dnl
+dnl What the ACTION-IFs can do:
+dnl
+dnl   * change the variable have_[$1] to "yes" or "now" 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 Results after calling it:
+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 ])
+dnl
+dnl Parameters to ./configure which influence the 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
+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" ;;
+       *bsd*)          soext=".so" ;;
+       *darwin*)       soext=".dylib" ;;
+       *w32*)          soext=".dll" ;;
+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
+dnl
+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])
+have_[$1]=no
+if test "x${[$1][_LIBS]}" = "x" && test "x${[$1][_CFLAGS]}" = "x"; then
+       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]}" = "xauto"; then [try_][$1]=autodetect; fi
+       AC_MSG_RESULT([${try_][$1][}])
+       m4_popdef([gp_lib_arg])dnl
+       if test "x${[try_][$1]}" = "xautodetect"; then
+               m4_ifval([$3],
+                       [PKG_CHECK_MODULES([$1],[$2][ $3],[have_][$1][=yes])],
+                       [PKG_CHECK_MODULES([$1],[$2],     [have_][$1][=yes])]
+               )dnl
+               if test "x${[have_][$1]}" = "xno"; then
+                       ifs="$IFS"
+                       IFS=":" # FIXME: for W32 and OS/2 we 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
+               [$1][_LIBS]="-L${[try_][$1]}/lib -l$(echo "$2" | sed 's/^lib//')"
+               [$1][_CFLAGS]="-I${[try_][$1]}/include"
+       fi
+elif test "x${[$1][_LIBS]}" != "x" && test "x${[$1][_CFLAGS]}" != "x"; then
+       AC_MSG_RESULT([user-defined])
+       have_[$1]=yes
+else
+       AC_MSG_ERROR([
+* Fatal:
+* When calling configure for ${PACKAGE_TARNAME}
+*     ${PACKAGE_NAME}
+* either set both [$1][_LIBS] *and* [$1][_CFLAGS]
+* or neither.
+])
+fi
+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 *.la libs, so we deactivated it.
+dnl
+dnl m4_ifval([$5],[dnl
+dnl if test "x${[have_][$1]}" = "xyes"; then
+dnl AC_MSG_CHECKING([whether ][$2][ test link succeeds])
+dnl LDFLAGS_save="$LDFLAGS"
+dnl LDFLAGS="${[$1]_LIBS}"
+dnl AC_TRY_LINK_FUNC([$5],[],[have_][$1][=no])
+dnl LDFLAGS="$LDFLAGS_save"
+dnl AC_MSG_RESULT([${[have_][$1]}])
+dnl fi
+dnl ])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 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
+],[dnl
+*   - get $2 and install it:
+      $9]))
+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
+       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], [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/m4m/gp-check-popt.m4 b/m4m/gp-check-popt.m4
new file mode 100644 (file)
index 0000000..fed18bf
--- /dev/null
@@ -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$withval" = no \
+    || test "x$withval" = off \
+    || test "x$withval" = false; 
+  then
+    try_popt=no
+    require_popt=no
+  elif test "x$withval" = yes \
+    || test "x$withval" = on \
+    || test "x$withval" = true
+  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
+       else
+               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
+       else
+               AC_MSG_ERROR([
+* Cannot autodetect library directory containing popt
+*
+* Set POPT_CFLAGS and POPT_LIBS correctly.
+])
+       fi
+       have_popt=yes
+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/m4m/gp-check-shell-environment.m4 b/m4m/gp-check-shell-environment.m4
new file mode 100644 (file)
index 0000000..b9850e7
--- /dev/null
@@ -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/m4m/gp-config-msg.m4 b/m4m/gp-config-msg.m4
new file mode 100644 (file)
index 0000000..ae8df96
--- /dev/null
@@ -0,0 +1,72 @@
+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="22"],[gp_config_len="$1"])
+gp_config_empty=""
+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
+AC_DEFUN([GP_CONFIG_MSG],
+[AC_REQUIRE([GP_CONFIG_INIT])dnl
+m4_if([$1],[],[
+gp_config_msg="${gp_config_msg}
+"
+],[
+gp_config_msg="${gp_config_msg}        $(expr "$1:${gp_config_empty}" : "\(.\{0,${gp_config_len}\}\)") $2
+"
+])])dnl
+dnl
+AC_DEFUN([GP_CONFIG_OUTPUT],
+[AC_REQUIRE([GP_CONFIG_INIT])dnl
+AC_REQUIRE([GP_CONFIG_MSG])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/m4m/gp-documentation.m4 b/m4m/gp-documentation.m4
new file mode 100644 (file)
index 0000000..a944cc5
--- /dev/null
@@ -0,0 +1,111 @@
+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_DOCS])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_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/m4m/gp-gettext-hack.m4 b/m4m/gp-gettext-hack.m4
new file mode 100644 (file)
index 0000000..82ff9ca
--- /dev/null
@@ -0,0 +1,75 @@
+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_if([$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 second 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_MSG])
+if test "x${BUILD_INCLUDED_LIBINTL}" = "xyes"; then
+   AM_CFLAGS="${AM_CFLAGS} -I\$(top_srcdir)/intl"
+fi
+GP_CONFIG_MSG
+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/m4m/gp-packaging.m4 b/m4m/gp-packaging.m4
new file mode 100644 (file)
index 0000000..163ece3
--- /dev/null
@@ -0,0 +1,74 @@
+AC_DEFUN([GPKG_CHECK_RPM],
+[
+AC_ARG_WITH([rpmbuild],
+[AS_HELP_STRING([--with-rpmbuild=PATH],
+[Program to use for building RPMs])])
+
+if test -x "${with_rpmbuild}"
+then
+    RPMBUILD="${with_rpmbuild}"
+    AC_MSG_CHECKING([for rpmbuild or rpm])
+    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"])
+
+# whether libusb-devel is installed or not defines whether the RPM
+# packages we're going to build will depend on libusb and libusb-devel
+# RPM packages or not.
+AM_CONDITIONAL([RPM_LIBUSB_DEVEL], [rpm -q libusb-devel > /dev/null 2>&1])
+])
+
+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]])])
+
+       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
+       AC_SUBST([hotplugdocdir])
+
+       AC_ARG_WITH([hotplug-usermap-dir],
+       [AS_HELP_STRING([--with-hotplug-usermap-dir=PATH],
+       [Where to install hotplug scripts as docs [default=autodetect]])])
+
+       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
+
+       AC_SUBST([hotplugusermapdir])
+])
diff --git a/m4m/gp-pkg-config.m4 b/m4m/gp-pkg-config.m4
new file mode 100644 (file)
index 0000000..531bfe4
--- /dev/null
@@ -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/m4m/gp-references.m4 b/m4m/gp-references.m4
new file mode 100644 (file)
index 0000000..fca98f1
--- /dev/null
@@ -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/m4m/stdint.m4 b/m4m/stdint.m4
new file mode 100644 (file)
index 0000000..f95b28c
--- /dev/null
@@ -0,0 +1,734 @@
+dnl AC_NEED_STDINT_H ( HEADER-TO-GENERATE )
+dnl Copyright 2001-2002 by Dan Fandrich <dan@coneharvesters.com>
+dnl This file may be copied and used freely without restrictions.  No warranty
+dnl 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],
+[
+changequote(, )dnl
+ac_dir=`echo "$1"|sed 's%/[^/][^/]*$%%'`
+changequote([, ])dnl
+if test "$ac_dir" != "$1" && test "$ac_dir" != .; then
+  # The file is in a subdirectory.
+  test ! -d "$ac_dir" && mkdir "$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"
+])
+])