Subject: Correct the Makefile for the binaries build
Author: Michael van der Kolff <mvanderkolff@gmail.com>
Forwarded: no

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

This corrects the pbmtools part (jbig <-> pbm tools) so that they
use the shared libraries.
--- jbigkit-2.1/pbmtools/Makefile.orig	2014-03-27 18:47:15.000000000 +0000
+++ jbigkit-2.1/pbmtools/Makefile	2014-04-25 11:43:08.567108000 +0000
@@ -6,6 +6,7 @@
 # Options for the compiler
 CFLAGS = -g -O -W -Wall -Wno-unused-result -ansi -pedantic # --coverage
 CPPFLAGS = -I../libjbig 
+export LD_LIBRARY_PATH = ../libjbig/.libs
 
 .SUFFIXES: .1 .5 .txt $(SUFFIXES)
 .PHONY: txt test test82 test85 clean
@@ -15,16 +16,16 @@
 txt: pbmtojbg.txt jbgtopbm.txt pbm.txt pgm.txt
 
 pbmtojbg: pbmtojbg.o ../libjbig/libjbig.a
-	$(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig -ljbig
+	$(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig/.libs -ljbig
 
 jbgtopbm: jbgtopbm.o ../libjbig/libjbig.a
-	$(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig -ljbig
+	$(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig/.libs -ljbig
 
-pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig85.a
-	$(CC) $(CFLAGS) -o pbmtojbg85 pbmtojbg85.o -L../libjbig -ljbig85
+pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig.a
+	$(CC) $(CFLAGS) -o pbmtojbg85 pbmtojbg85.o -L../libjbig/.libs -ljbig
 
-jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig85.a
-	$(CC) $(CFLAGS) -o jbgtopbm85 jbgtopbm85.o -L../libjbig -ljbig85
+jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig.a
+	$(CC) $(CFLAGS) -o jbgtopbm85 jbgtopbm85.o -L../libjbig/.libs -ljbig
 
 jbgtopbm.o: jbgtopbm.c ../libjbig/jbig.h
 pbmtojbg.o: pbmtojbg.c ../libjbig/jbig.h
@@ -35,10 +36,6 @@
 	../libjbig/jbig_ar.c ../libjbig/jbig_ar.h
 	make -C ../libjbig libjbig.a
 
-../libjbig/libjbig85.a: ../libjbig/jbig85.c ../libjbig/jbig85.h \
-	../libjbig/jbig_ar.c ../libjbig/jbig_ar.h
-	make -C ../libjbig libjbig85.a
-
 analyze:
 	clang $(CPPFLAGS) --analyze *.c
 
@@ -96,6 +93,8 @@
 	cmp test-$(IMG).pgm ../examples/$(IMG).pgm
 
 test85: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85 test-t82.pbm
+	export LD_LIBRARY_PATH=`pwd`/../libjbig/.libs
+	echo $(LD_LIBRARY_PATH)
 	make IMG=t82 "OPTIONSP=-p 0"      dotest85
 	make IMG=t82 "OPTIONSP=-p 8"      dotest85
 	make IMG=t82 "OPTIONSP=-p 8 -r"   dotest85b
