EXTRA_DIST = bootstrap $(DX_BASEDIR)/scripts/fix-gnulib.pl m4/gnulib-cache.m4
CLEANFILES = $(EXTRA_LTLIBRARIES)
-AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/src
+AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/src \
+ -I$(top_srcdir)/common/src
AM_CFLAGS = $(LIBPNG_CFLAGS) $(GTK_CFLAGS)
dist_man_MANS = doc/man/lbxtool.1 doc/man/lbximg.1
lbxdir = $(includedir)/lbx
lbx_HEADERS = src/lbx.h src/image.h src/error.h
-noinst_HEADERS = src/misc.h src/tools.h src/pack.h
+noinst_HEADERS = src/misc.h src/tools.h
lib_LTLIBRARIES = liblbx.la
-liblbx_la_SOURCES = src/lbx.c src/fops.c src/image.c src/pack.c src/error.c
+liblbx_la_SOURCES = src/lbx.c src/fops.c src/image.c src/error.c \
+ common/src/pack.c common/src/pack.h
liblbx_la_LDFLAGS = -export-symbols-regex '^lbx_'
bin_PROGRAMS = lbxtool lbximg
m4_include([lib/gnulib.mk])
AC_ARG_WITH([libpng],
- [AS_HELP_STRING([--with-libpng],
- [build support for PNG output using libpng. [default=auto]])],
- [with_libpng=$withval],
- [with_libpng=auto])
+ [AS_HELP_STRING([--with-libpng],
+ [build support for PNG output using libpng. [default=auto]])],
+ [with_libpng=$withval], [with_libpng=auto])
AS_CASE([$with_libpng],
- [no], [have_libpng=false],
- [yes], [DX_CHECK_LIBPNG([1.5], [have_libpng=true])],
- [DX_CHECK_LIBPNG([1.5], [have_libpng=true], [have_libpng=false])])
+ [no], [have_libpng=false],
+ [yes], [DX_LIB_LIBPNG([1.5], [have_libpng=true])],
+ [DX_LIB_LIBPNG([1.5], [have_libpng=true], [have_libpng=false])])
AM_CONDITIONAL([HAVE_LIBPNG], [$have_libpng])
AS_IF([$have_libpng], [AC_DEFINE([HAVE_LIBPNG], [1],
- [Define to 1 if libpng support is available])])
+ [Define to 1 if libpng support is available])])
AC_ARG_ENABLE([lbxgui],
- [AS_HELP_STRING([--enable-lbxgui],
- [build the lbxgui tool (requires GTK+) [default=auto]])],
- [enable_lbxgui=$enableval],
- [enable_lbxgui=auto])
+ [AS_HELP_STRING([--enable-lbxgui],
+ [build the lbxgui tool (requires GTK+) [default=auto]])],
+ [enable_lbxgui=$enableval],
+ [enable_lbxgui=auto])
AS_CASE([$enable_lbxgui],
- [no], [have_gtk=false],
- [yes], [DX_CHECK_GTK2([2.16], [have_gtk=true])],
- [DX_CHECK_GTK2([2.16], [have_gtk=true], [have_gtk=false])])
+ [no], [have_gtk=false],
+ [yes], [DX_LIB_GTK2([2.16], [have_gtk=true])],
+ [DX_LIB_GTK2([2.16], [have_gtk=true], [have_gtk=false])])
AM_CONDITIONAL([BUILD_LBXGUI], [$have_gtk])
# Check for utilities used by the test suite.
DX_PROG_MD5SUM
AS_IF([test x"$dx_cv_md5sum_works" = x"yes"],
- [AC_SUBST([HAVE_MD5SUM], [true])],
- [AC_SUBST([HAVE_MD5SUM], [false])])
-AC_SUBST([MD5SUM])
+ [HAVE_MD5SUM=true], [HAVE_MD5SUM=false])
+AC_SUBST([HAVE_MD5SUM])
AC_CHECK_PROGS([PAMARITH], [pamarith], [false])
AC_CHECK_PROGS([PAMCHANNEL], [pamchannel], [false])
AC_SUBST([PAMCHANNEL])
AC_SUBST([PAMARITH])
-AC_CONFIG_FILES([
- tests/util/test-defs.sh
- Makefile
-])
-
+AC_CONFIG_FILES([tests/util/test-defs.sh Makefile])
AC_OUTPUT
+++ /dev/null
-dnl Copyright (C) 2010 Nick Bowler
-dnl Copying and distribution of this file, with or without modification,
-dnl are permitted in any medium without royalty provided the copyright
-dnl notice and this notice are preserved. This file is offered as-is,
-dnl without any warranty.
-
-m4_pattern_forbid([^_?DX_])
-
-dnl DX_PKG_CONFIG(env-base, [pkg-id], [pkg-help])
-AC_DEFUN([DX_PKG_CONFIG], [dnl
-AC_ARG_VAR(m4_toupper([$1])[_CFLAGS], [C compiler flags for ]ifelse(
- [$3], [], [$1], [$3]))dnl
-AC_ARG_VAR(m4_toupper([$1])[_LIBS], [linker flags for ]ifelse(
- [$3], [], [$1], [$3]))dnl
-
-ifelse([$2], [], [], [dnl
-AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-if test x"$PKG_CONFIG" != x; then
- AC_MSG_CHECKING([pkg-config database for $2])
- pkg_failed=no
- _PKG_CONFIG(m4_tolower([$1])[_cflags], [cflags], [$2])
- _PKG_CONFIG(m4_tolower([$1])[_libs], [libs], [$2])
- if test x$pkg_failed = xyes; then
- errors=`$PKG_CONFIG --errors-to-stdout --print-errors $2`
- echo "$errors" >&AS_MESSAGE_LOG_FD
- AC_MSG_RESULT([no])
- else
- AC_MSG_RESULT([yes])
- fi
-fi])])
-
-dnl _DX_CHECK_LIB([env-base], [test-program], [cflags], [libs], [test])
-AC_DEFUN([_DX_CHECK_LIB], [dnl
-if test x"$dx_cv_[]m4_tolower([$1])_found" = x"no"; then
-if ifelse([$5], [], [:], [$5]); then
- CFLAGS="$3 $dx_old_cflags"
- LIBS="$4 $dx_old_libs"
-
- AC_LINK_IFELSE([$2], [dnl
- dx_cv_[]m4_tolower([$1])_found="yes"
- dx_cv_[]m4_tolower([$1])_cflags="$3"
- dx_cv_[]m4_tolower([$1])_libs="$4"
- ], [:])
-fi
-fi
-])
-
-dnl DX_CHECK_LIB([env-base], [message], [test-program],
-dnl [[[cflags1],[libs1],[test1]],[[cflags2],[libs2],[test2]],...])
-AC_DEFUN([DX_CHECK_LIB], [dnl
-AC_LANG_PUSH([C])
-dx_old_cflags=$CFLAGS
-dx_old_libs=$LIBS
-
-AC_CACHE_CHECK([$2], [dx_cv_]m4_tolower([$1])[_found], [dnl
-AC_CACHE_VAL([dx_cv_]m4_tolower([$1])[_libs], [dnl
-AC_CACHE_VAL([dx_cv_]m4_tolower([$1])[_cflags], [dnl
- dx_cv_[]m4_tolower([$1])_found=no
- m4_foreach([dx_tuple], [$4], [_DX_CHECK_LIB([$1], [$3], dx_tuple)])
-])])])
-
-if test x"$dx_cv_[]m4_tolower([$1])_found" = x"yes"; then
- m4_toupper([$1])_CFLAGS=$dx_cv_[]m4_tolower([$1])_cflags
- m4_toupper([$1])_LIBS=$dx_cv_[]m4_tolower([$1])_libs
- AC_SUBST(m4_toupper([$1])[_CFLAGS])
- AC_SUBST(m4_toupper([$1])[_LIBS])
-fi
-
-CFLAGS=$dx_old_cflags
-LIBS=$dx_old_libs
-AC_LANG_POP([C])
-])
+++ /dev/null
-dnl Copyright (C) 2010 Nick Bowler
-dnl Copying and distribution of this file, with or without modification,
-dnl are permitted in any medium without royalty provided the copyright
-dnl notice and this notice are preserved. This file is offered as-is,
-dnl without any warranty.
-
-dnl _DX_GTK2_TEST_PROGRAM(major, minor, micro)
-AC_DEFUN([_DX_GTK2_TEST_PROGRAM], [AC_LANG_PROGRAM([dnl
-#include <gtk/gtk.h>
-#if !GTK_CHECK_VERSION( \
- ifelse([$1], [], [2], [$1]), \
- ifelse([$2], [], [0], [$2]), \
- ifelse([$3], [], [0], [$3]))
-# error Insufficient GTK version
-#endif
-], [dnl
-int argc = 0;
-char *argv[] = {NULL};
-gtk_init(&argc, &argv);
-gtk_main();
-])])
-
-dnl DX_CHECK_GTK2([min-version], [action-if-ok], [action-if-fail])
-AC_DEFUN([DX_CHECK_GTK2],
-[DX_PKG_CONFIG([gtk], [gtk+-2.0], [GTK+])
-
-DX_CHECK_LIB([gtk],
- [for GTK+ version at least ifelse([$1], [], [2.0], [$1])],
- [m4_apply([_DX_GTK2_TEST_PROGRAM], m4_split([$1], [\.]))], [dnl
- [[$GTK_CFLAGS], [$GTK_LIBS]],
- [[$pkg_cv_gtk_cflags], [$pkg_cv_gtk_libs],
- [test ! x"$pkg_failed" = x"yes"]],
- ])
-
-if test x"$dx_cv_gtk_found" = x"yes"; then
- ifelse([$2], [], [:], [$2])
-else
- ifelse([$3], [], [AC_MSG_FAILURE([dnl
-GTK+ version at least ifelse([$1], [], [2.0], [$1]) is required. The latest
-version can be obtained from ftp://ftk.gtk.org/.
-
-If GTK+ is installed but was not found by this configure script,
-consider adjusting GTK_CFLAGS and/or GTK_LIBS as necessary.
-
-If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH
-if GTK+ is installed in a non-standard prefix.
-])], [$3])
-fi
-])
+++ /dev/null
-dnl Copyright (C) 2009-2010 Nick Bowler
-dnl Copying and distribution of this file, with or without modification,
-dnl are permitted in any medium without royalty provided the copyright
-dnl notice and this notice are preserved. This file is offered as-is,
-dnl without any warranty.
-
-dnl _DX_LIBPNG_TEST_PROGRAM(major, minor, release)
-AC_DEFUN([_DX_LIBPNG_TEST_PROGRAM], [AC_LANG_PROGRAM([dnl
-#include <png.h>
-ifelse([$1], [], [], [dnl
-#if PNG_LIBPNG_VER_MAJOR < $1
-# error Invalid libpng major version
-ifelse([$2], [], [], [dnl
-#elif PNG_LIBPNG_VER_MAJOR == $1
-# if PNG_LIBPNG_VER_MINOR < $2
-# error Invalid libpng minor version
-ifelse([$3], [], [], [dnl
-# elif PNG_LIBPNG_VER_MINOR == $2
-# if PNG_LIBPNG_VER_RELEASE < $3
-# error Invalid libpng release
-# endif
-])dnl
-# endif
-])dnl
-#endif
-])dnl
-], [dnl
-png_structp png = png_create_read_struct("", 0, 0, 0);
-png_infop info = png_create_info_struct(png);
-])])
-
-dnl DX_CHECK_LIBPNG([min-version], [action-if-ok], [action-if-fail])
-AC_DEFUN([DX_CHECK_LIBPNG],
-[DX_PKG_CONFIG([libpng], [libpng], [libpng])
-
-DX_CHECK_LIB([libpng],
- [for libpng[]ifelse([$1], [], [], [ version at least $1])],
- [m4_apply([_DX_LIBPNG_TEST_PROGRAM], m4_split([$1], [\.]))], [dnl
- [[$LIBPNG_CFLAGS], [$LIBPNG_LIBS]],
- [[$pkg_cv_libpng_cflags], [$pkg_cv_libpng_libs],
- [test ! x"$pkg_failed" = x"yes"]],
- [[], [-lpng]],
- ])
-
-if test x"$dx_cv_libpng_found" = x"yes"; then
- ifelse([$2], [], [:], [$2])
-else
- ifelse([$3], [], [AC_MSG_FAILURE([dnl
-libpng[]ifelse([$1], [], [], [ version at least $1]) is required. The latest
-version can be obtained from http://libpng.org/pub/png/libpng.html.
-
-If libpng is installed but was not found by this configure script,
-consider adjusting LIBPNG_CFLAGS and/or LIBPNG_LIBS as necessary.
-
-If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH
-if libpng is installed in a non-standard prefix.
-])], [$3])
-fi
-])
+++ /dev/null
-/*
- * Portable binary serialisation of integral types.
- * Copyright (C) 2009 Nick Bowler
- *
- * Copying and distribution of this file, with or without modification,
- * are permitted in any medium without royalty provided the copyright
- * notice and this notice are preserved. This file is offered as-is,
- * without any warranty.
- */
-
-#include "pack.h"
-
-/* Unsigned integer packing. */
-#define DEFPACK_BE(bits, type) void pack_ ## bits ## _be ( \
- unsigned char *out, type v \
-) { \
- unsigned i; \
- for (i = 1; i <= bits/8; i++) { \
- out[bits/8 - i] = v % 256; \
- v /= 256; \
- } \
-}
-
-#define DEFPACK_LE(bits, type) void pack_ ## bits ## _le ( \
- unsigned char *out, type v \
-) { \
- unsigned i; \
- for (i = 0; i < bits/8; i++) { \
- out[i] = v % 256; \
- v /= 256; \
- } \
-}
-
-DEFPACK_BE(16, unsigned short)
-DEFPACK_BE(32, unsigned long)
-#if PACK_HAVE_64BIT
-DEFPACK_BE(64, unsigned long long)
-#endif
-
-DEFPACK_LE(16, unsigned short)
-DEFPACK_LE(32, unsigned long)
-#if PACK_HAVE_64BIT
-DEFPACK_LE(64, unsigned long long)
-#endif
-
-#define DEFUNPACK_BE(bits, type) type unpack_ ## bits ## _be ( \
- const unsigned char *in \
-) { \
- type v = 0; \
- unsigned i; \
- for (i = 0; i < bits/8; i++) { \
- v *= 256; \
- v += in[i]; \
- } \
- return v; \
-}
-
-#define DEFUNPACK_LE(bits, type) type unpack_ ## bits ## _le ( \
- const unsigned char *in \
-) { \
- type v = 0; \
- unsigned i; \
- for (i = 1; i <= bits/8; i++) { \
- v *= 256; \
- v += in[bits/8 - i]; \
- } \
- return v; \
-}
-
-DEFUNPACK_BE(16, unsigned short)
-DEFUNPACK_BE(32, unsigned long)
-#if PACK_HAVE_64BIT
-DEFUNPACK_BE(64, unsigned long long)
-#endif
-
-DEFUNPACK_LE(16, unsigned short)
-DEFUNPACK_LE(32, unsigned long)
-#if PACK_HAVE_64BIT
-DEFUNPACK_LE(64, unsigned long long)
-#endif
-
-/*
- * Two's complement signed integer packing. This is unlikely to work on
- * systems that don't themselves use two's complement.
- */
-
-#define DEFUNPACK_SBE(bits, max, type) type unpack_s ## bits ## _be ( \
- const unsigned char *in \
-) { \
- type v = 0; \
- unsigned i; \
- int sign = (in[0] & 0x80) ? 1 : 0; \
- for (i = 0; i < bits/8; i++) { \
- v *= 256; \
- v += in[i] & (i == 0 ? 0x7f : 0xff); \
- } \
- return sign*(-max-1) + v; \
-}
-
-#define DEFUNPACK_SLE(bits, max, type) type unpack_s ## bits ## _le ( \
- const unsigned char *in \
-) { \
- type v = 0; \
- unsigned i; \
- int sign = (in[bits/8 - 1] & 0x80) ? 1 : 0; \
- for (i = 1; i <= bits/8; i++) { \
- v *= 256; \
- v += in[bits/8 - i] & (i == 1 ? 0x7f : 0xff); \
- } \
- return sign*(-max-1) + v; \
-}
-
-DEFUNPACK_SBE(16, 32767, short)
-DEFUNPACK_SBE(32, 2147483647l, long)
-#if PACK_HAVE_64BIT
-DEFUNPACK_SBE(64, 9223372036854775807ll, long long)
-#endif
-
-DEFUNPACK_SLE(16, 32767, short)
-DEFUNPACK_SLE(32, 2147483647l, long)
-#if PACK_HAVE_64BIT
-DEFUNPACK_SLE(64, 9223372036854775807ll, long long)
-#endif
+++ /dev/null
-/*
- * Portable binary serialisation of integral types.
- * Copyright (C) 2009 Nick Bowler
- *
- * Copying and distribution of this file, with or without modification,
- * are permitted in any medium without royalty provided the copyright
- * notice and this notice are preserved. This file is offered as-is,
- * without any warranty.
- */
-
-#ifndef PACK_H_
-#define PACK_H_
-
-#include <limits.h>
-#if !defined(PACK_HAVE_64BIT) && defined(ULLONG_MAX) && defined(LLONG_MAX)
-# define PACK_HAVE_64BIT 1
-#endif
-
-void pack_16_be(unsigned char *, unsigned short);
-void pack_32_be(unsigned char *, unsigned long);
-#if PACK_HAVE_64BIT
-void pack_64_be(unsigned char *, unsigned long long);
-#endif
-
-void pack_16_le(unsigned char *, unsigned short);
-void pack_32_le(unsigned char *, unsigned long);
-#if PACK_HAVE_64BIT
-void pack_64_le(unsigned char *, unsigned long long);
-#endif
-
-unsigned short unpack_16_be(const unsigned char *);
-unsigned long unpack_32_be(const unsigned char *);
-#if PACK_HAVE_64BIT
-unsigned long long unpack_64_be(const unsigned char *);
-#endif
-
-unsigned short unpack_16_le(const unsigned char *);
-unsigned long unpack_32_le(const unsigned char *);
-#if PACK_HAVE_64BIT
-unsigned long long unpack_64_le(const unsigned char *);
-#endif
-
-short unpack_s16_be(const unsigned char *);
-long unpack_s32_be(const unsigned char *);
-#if PACK_HAVE_64BIT
-long long unpack_s64_be(const unsigned char *);
-#endif
-
-short unpack_s16_le(const unsigned char *);
-long unpack_s32_le(const unsigned char *);
-#if PACK_HAVE_64BIT
-long long unpack_s64_le(const unsigned char *);
-#endif
-
-#endif