shithub: jbig2

Download patch

ref: e20020b1bd4fae157236fc9716cafa17481e3171
parent: 5ae432288a105122d92f490d2d9cf212dae8aab4
author: Ralph Giles <giles@ghostscript.com>
date: Fri Jun 12 13:16:00 EDT 2009

Build a shared library with GNU libtool.

Previously we used autoconf and automake, but just build a static
library. This commit checks for libtoolize in autogen.sh and adds
support for libtool to the configure.an and Makefile.am scripts.

We use this to build both static and dynamic versions of the jbig2dec
library, including soname versioning for the later.

Based on a patch by Sebastian Rasmussen.

--- a/Makefile.am
+++ b/Makefile.am
@@ -3,10 +3,11 @@
 # require automake 1.7
 AUTOMAKE_OPTIONS = foreign 1.7 dist-bzip2 dist-zip -Wall
 
-lib_LIBRARIES = libjbig2dec.a
+lib_LTLIBRARIES = libjbig2dec.la
 include_HEADERS = jbig2.h
 
-libjbig2dec_a_SOURCES = jbig2.c \
+libjbig2dec_la_LDFLAGS = -version-info @JBIG2DEC_LT_CURRENT@:@JBIG2DEC_LT_REVISION@:@JBIG2DEC_LT_AGE@
+libjbig2dec_la_SOURCES = jbig2.c \
 	jbig2_arith.c jbig2_arith_int.c jbig2_arith_iaid.c jbig2_huffman.c \
 	jbig2_segment.c jbig2_page.c \
 	jbig2_symbol_dict.c jbig2_text.c \
@@ -26,7 +27,7 @@
 jbig2dec_SOURCES = jbig2dec.c sha1.c sha1.h \
 	jbig2.h jbig2_image.h getopt.h \
 	os_types.h config_types.h config_win32.h
-jbig2dec_LDADD = libjbig2dec.a @LIBOBJS@
+jbig2dec_LDADD = libjbig2dec.la @LIBOBJS@
 
 EXTRA_DIST = test_jbig2dec.py msvc.mak LICENSE CHANGES
 
@@ -39,9 +40,9 @@
 
 test_arith_SOURCES = jbig2_arith.c
 test_arith_CFLAGS = -DTEST
-test_arith_LDADD = libjbig2dec.a
+test_arith_LDADD = libjbig2dec.la
 
 test_huffman_SOURCES = jbig2_huffman.c
 test_huffman_CFLAGS = -DTEST
-test_huffman_LDADD = libjbig2dec.a
+test_huffman_LDADD = libjbig2dec.la
 
--- a/autogen.sh
+++ b/autogen.sh
@@ -80,11 +80,33 @@
   }
 fi
 
+# do we need libtool?
+if ! test -z `grep -l -s -e PROG_LIBTOOL configure.ac configure.in`; then
+  echo -n "Checking for libtoolize... "
+  LIBTOOLIZE=
+  for lt in glibtoolize libtoolize; do
+    if ($lt --version < /dev/null > /dev/null 2>&1); then
+      LIBTOOLIZE=$lt
+      echo $lt
+      break;
+    fi
+  done
+  if test -z $LIBTOOLIZE; then
+        echo
+        echo "You must have GNU libtool installed to compile $package."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+	exit 1
+  fi
+fi
 
 echo "Generating configuration files for $package, please wait...."
 
 echo "  $ACLOCAL $ACLOCAL_FLAGS"
 $ACLOCAL $ACLOCAL_FLAGS
+
+echo "  $LIBTOOLIZE"
+$LIBTOOLIZE
 
 echo "  autoheader"
 autoheader
--- a/configure.ac
+++ b/configure.ac
@@ -7,10 +7,21 @@
 AM_INIT_AUTOMAKE([-Wall])
 AM_CONFIG_HEADER(config.h)
 
+dnl Library versioning - Adapted from the libtool info page
+dnl
+dnl 1. If source has changed at all: increment revision
+dnl 2. If the ABI changed: increment current, reset revision to 0
+dnl 3. If interfaces have been added since last public release: increment age
+dnl 4. If interfaces have been removed: reset age to 0
+
+AC_SUBST([JBIG2DEC_LT_CURRENT], [0])
+AC_SUBST([JBIG2DEC_LT_REVISION], [0])
+AC_SUBST([JBIG2DEC_LT_AGE], [0])
+
 # Checks for programs.
 AC_PROG_CC
 AM_PROG_CC_C_O
-AC_PROG_RANLIB
+AC_PROG_LIBTOOL
 
 # platform specific compiler flags
 if test "x$GCC" = xyes; then