Subject: Build library with libtool
Author: Michael van der Kolff <mvanderkolff@gmail.com>
Forwarded: no

Upstream Makefile is barebones, and doesn't make any shared libraries.

This part actually builds the libraries.
--- jbigkit-2.1/libjbig/Makefile.orig	2014-04-25 11:44:08.009156200 +0000
+++ jbigkit-2.1/libjbig/Makefile	2014-04-25 11:46:47.971468800 +0000
@@ -6,29 +6,30 @@
 # Options for the compiler: A high optimization level is suggested
 CFLAGS = -g -O -W -Wall -ansi -pedantic # --coverage
 
-all: libjbig.a libjbig85.a tstcodec tstcodec85
+.PHONY: all clean test
 
-tstcodec: tstcodec.o jbig.o jbig_ar.o
+%.lo %.o: %.c
+	libtool --tag=CC --mode=compile $(CC) $(CFLAGS) -c $<
+
+all: libjbig-0.dll libjbig.a
+
+tstcodec: tstcodec.o libjbig.a
 	$(CC) $(CFLAGS) -o tstcodec tstcodec.o jbig.o jbig_ar.o
 
-tstcodec85: tstcodec85.o jbig85.o jbig_ar.o
+tstcodec85: tstcodec85.o libjbig.a
 	$(CC) $(CFLAGS) -o tstcodec85 tstcodec85.o jbig85.o jbig_ar.o
 
-libjbig.a: jbig.o jbig_ar.o
-	rm -f libjbig.a
-	ar rc libjbig.a jbig.o jbig_ar.o
-	-ranlib libjbig.a
-
-libjbig85.a: jbig85.o jbig_ar.o
-	rm -f libjbig85.a
-	ar rc libjbig85.a jbig85.o jbig_ar.o
-	-ranlib libjbig85.a
-
-jbig.o: jbig.c jbig.h jbig_ar.h
-jbig85.o: jbig85.c jbig85.h jbig_ar.h
-jbig_ar.o: jbig_ar.c jbig_ar.h
-tstcodec.o: tstcodec.c jbig.h
-tstcodec85.o: tstcodec85.c jbig85.h
+libjbig.a: jbig.lo jbig_ar.lo jbig85.lo
+	libtool --tag=CC --mode=link $(CC) --static -o libjbig.a $+ -rpath /usr/lib
+
+libjbig-0.dll: jbig.lo jbig_ar.lo jbig85.lo
+	libtool --tag=CC --mode=link $(CC) --shared -no-undefined -o libjbig-0.dll -Wl,--out-implib=.libs/libjbig.dll.a $+ -rpath /usr/lib
+
+jbig.lo: jbig.c jbig.h jbig_ar.h
+jbig85.lo: jbig85.c jbig85.h jbig_ar.h
+jbig_ar.lo: jbig_ar.c jbig_ar.h
+tstcodec.o: tstcodec.c libjbig.a
+tstcodec85.o: tstcodec85.c libjbig.a
 
 update-po: jbig.c jbig85.c Makefile
 	xgettext -ojbig.pot -k_ \
@@ -50,6 +51,7 @@
 	./tstcodec $@
 
 clean:
-	rm -f *.o *.gcda *.gcno *.gcov *.plist *~ core gmon.out dbg_d\=??.pbm
+	rm -rf .libs
+	rm -f *.gcda *.gcno *.gcov *.a *.la *.o *.lo *~ core gmon.out dbg_d\=??.pbm t82test.pbm
 	rm -f t82test.pbm
 	rm -f tstcodec tstcodec85
