d81824
diff -Naur jbigkit-2.1.old/libjbig/Makefile jbigkit-2.1/libjbig/Makefile
d81824
--- jbigkit-2.1.old/libjbig/Makefile	2014-03-27 19:47:15.000000000 +0100
d81824
+++ jbigkit-2.1/libjbig/Makefile	2014-08-04 10:45:31.865773710 +0200
d81824
@@ -4,25 +4,27 @@
d81824
 CC = gcc
d81824
 
d81824
 # Options for the compiler: A high optimization level is suggested
d81824
-CFLAGS = -g -O -W -Wall -ansi -pedantic # --coverage
d81824
+CFLAGS = $(RPM_OPT_FLAGS) -W -Wall -ansi -pedantic # --coverage
d81824
+PICFLAGS := -fPIC -DPIC
d81824
 
d81824
-all: libjbig.a libjbig85.a tstcodec tstcodec85
d81824
+all: libjbig.so.$(VERSION) tstcodec tstcodec85
d81824
 
d81824
-tstcodec: tstcodec.o jbig.o jbig_ar.o
d81824
-	$(CC) $(CFLAGS) -o tstcodec tstcodec.o jbig.o jbig_ar.o
d81824
+tstcodec: tstcodec.o libjbig.so
d81824
+	$(CC) $(CFLAGS) -o tstcodec $< -L. -ljbig
d81824
 
d81824
-tstcodec85: tstcodec85.o jbig85.o jbig_ar.o
d81824
-	$(CC) $(CFLAGS) -o tstcodec85 tstcodec85.o jbig85.o jbig_ar.o
d81824
+tstcodec85: tstcodec85.o libjbig85.so
d81824
+	$(CC) $(CFLAGS) -o tstcodec85 $^ -L. -ljbig
d81824
 
d81824
-libjbig.a: jbig.o jbig_ar.o
d81824
-	rm -f libjbig.a
d81824
-	ar rc libjbig.a jbig.o jbig_ar.o
d81824
-	-ranlib libjbig.a
d81824
+%.so: %.so.$(VERSION)
d81824
+	ln -sf $< $@
d81824
 
d81824
-libjbig85.a: jbig85.o jbig_ar.o
d81824
-	rm -f libjbig85.a
d81824
-	ar rc libjbig85.a jbig85.o jbig_ar.o
d81824
-	-ranlib libjbig85.a
d81824
+libjbig.so.$(VERSION): jbig.o jbig_ar.o
d81824
+	$(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
d81824
+
d81824
+libjbig85.so.$(VERSION): jbig85.o jbig_ar.o
d81824
+	$(CC) $(CFLAGS) -shared -Wl,-soname,$@ -o $@ $^
d81824
+
d81824
+jbig.o jbig85.o jbig_ar.o: CFLAGS += $(PICFLAGS)
d81824
 
d81824
 jbig.o: jbig.c jbig.h jbig_ar.h
d81824
 jbig85.o: jbig85.c jbig85.h jbig_ar.h
d81824
@@ -43,11 +45,11 @@
d81824
 	clang --analyze *.c
d81824
 
d81824
 test: tstcodec tstcodec85
d81824
-	./tstcodec
d81824
-	./tstcodec85
d81824
+	LD_LIBRARY_PATH=`pwd` ./tstcodec
d81824
+	LD_LIBRARY_PATH=`pwd` ./tstcodec85
d81824
 
d81824
 t82test.pbm: tstcodec
d81824
-	./tstcodec $@
d81824
+	LD_LIBRARY_PATH=`pwd` ./tstcodec $@
d81824
 
d81824
 clean:
d81824
 	rm -f *.o *.gcda *.gcno *.gcov *.plist *~ core gmon.out dbg_d\=??.pbm
d81824
diff -Naur jbigkit-2.1.old/Makefile jbigkit-2.1/Makefile
d81824
--- jbigkit-2.1.old/Makefile	2014-03-27 19:47:15.000000000 +0100
d81824
+++ jbigkit-2.1/Makefile	2014-08-04 10:52:09.242027746 +0200
d81824
@@ -4,25 +4,26 @@
d81824
 CC = gcc
d81824
 
d81824
 # Options for the compiler: A high optimization level is suggested
d81824
-CFLAGS = -O2 -W -Wno-unused-result
d81824
+CFLAGS = $(RPM_OPT_FLAGS) -W -Wno-unused-result
d81824
 # CFLAGS = -O -g -W -Wall -Wno-unused-result -ansi -pedantic # -DDEBUG
d81824
 
d81824
 export CC CFLAGS
d81824
 
d81824
 VERSION=2.1
d81824
+export VERSION
d81824
 
d81824
 all: lib pbm
d81824
 	@echo "Enter 'make test' in order to start some automatic tests."
d81824
 
d81824
 lib:
d81824
-	cd libjbig && $(MAKE) -e
d81824
+	make -C libjbig
d81824
 
d81824
 pbm: lib
d81824
-	cd pbmtools && $(MAKE) -e
d81824
+	make -C pbmtools
d81824
 
d81824
 test: lib pbm
d81824
-	cd libjbig  && $(MAKE) test
d81824
-	cd pbmtools && $(MAKE) test
d81824
+	LD_LIBRARY_PATH=`pwd`/libjbig make -C libjbig test
d81824
+	LD_LIBRARY_PATH=`pwd`/libjbig make -C pbmtools test
d81824
 
d81824
 analyze:
d81824
 	cd libjbig  && $(MAKE) analyze
d81824
@@ -30,8 +31,8 @@
d81824
 
d81824
 clean:
d81824
 	rm -f *~ core
d81824
-	cd libjbig  && $(MAKE) clean
d81824
-	cd pbmtools && $(MAKE) clean
d81824
+	make -C libjbig clean
d81824
+	make -C pbmtools clean
d81824
 
d81824
 distribution:
d81824
 	rm -rf jbigkit-$(VERSION)
d81824
diff -Naur jbigkit-2.1.old/pbmtools/Makefile jbigkit-2.1/pbmtools/Makefile
d81824
--- jbigkit-2.1.old/pbmtools/Makefile	2014-03-27 19:47:15.000000000 +0100
d81824
+++ jbigkit-2.1/pbmtools/Makefile	2014-08-04 10:49:47.694581174 +0200
d81824
@@ -4,26 +4,26 @@
d81824
 CC = gcc
d81824
 
d81824
 # Options for the compiler
d81824
-CFLAGS = -g -O -W -Wall -Wno-unused-result -ansi -pedantic # --coverage
d81824
+CFLAGS = $(RPM_OPT_FLAGS) -W -Wall -Wno-unused-result -ansi -pedantic # --coverage
d81824
 CPPFLAGS = -I../libjbig 
d81824
 
d81824
 .SUFFIXES: .1 .5 .txt $(SUFFIXES)
d81824
 .PHONY: txt test test82 test85 clean
d81824
 
d81824
-all: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85 txt
d81824
+all: pbmtojbg jbgtopbm pbmtojbg85 jbgtopbm85 # txt
d81824
 
d81824
 txt: pbmtojbg.txt jbgtopbm.txt pbm.txt pgm.txt
d81824
 
d81824
-pbmtojbg: pbmtojbg.o ../libjbig/libjbig.a
d81824
+pbmtojbg: pbmtojbg.o ../libjbig/libjbig.so
d81824
 	$(CC) $(CFLAGS) -o pbmtojbg pbmtojbg.o -L../libjbig -ljbig
d81824
 
d81824
-jbgtopbm: jbgtopbm.o ../libjbig/libjbig.a
d81824
+jbgtopbm: jbgtopbm.o ../libjbig/libjbig.so
d81824
 	$(CC) $(CFLAGS) -o jbgtopbm jbgtopbm.o -L../libjbig -ljbig
d81824
 
d81824
-pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig85.a
d81824
+pbmtojbg85: pbmtojbg85.o ../libjbig/libjbig85.so
d81824
 	$(CC) $(CFLAGS) -o pbmtojbg85 pbmtojbg85.o -L../libjbig -ljbig85
d81824
 
d81824
-jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig85.a
d81824
+jbgtopbm85: jbgtopbm85.o ../libjbig/libjbig85.so
d81824
 	$(CC) $(CFLAGS) -o jbgtopbm85 jbgtopbm85.o -L../libjbig -ljbig85
d81824
 
d81824
 jbgtopbm.o: jbgtopbm.c ../libjbig/jbig.h
d81824
@@ -31,13 +31,13 @@
d81824
 jbgtopbm85.o: jbgtopbm85.c ../libjbig/jbig85.h
d81824
 pbmtojbg85.o: pbmtojbg85.c ../libjbig/jbig85.h
d81824
 
d81824
-../libjbig/libjbig.a: ../libjbig/jbig.c ../libjbig/jbig.h \
d81824
+../libjbig/libjbig.so: ../libjbig/jbig.c ../libjbig/jbig.h \
d81824
 	../libjbig/jbig_ar.c ../libjbig/jbig_ar.h
d81824
-	make -C ../libjbig libjbig.a
d81824
+	make -C ../libjbig libjbig.so
d81824
 
d81824
-../libjbig/libjbig85.a: ../libjbig/jbig85.c ../libjbig/jbig85.h \
d81824
+../libjbig/libjbig85.so: ../libjbig/jbig85.c ../libjbig/jbig85.h \
d81824
 	../libjbig/jbig_ar.c ../libjbig/jbig_ar.h
d81824
-	make -C ../libjbig libjbig85.a
d81824
+	make -C ../libjbig libjbig85.so
d81824
 
d81824
 analyze:
d81824
 	clang $(CPPFLAGS) --analyze *.c