From 04f33e01e3a9626fa7ec431bdcf90bba7cf51aa7 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Sun, 8 Apr 2018 08:45:05 +0200
Subject: add shared objects, remove -Wno-unused-result


diff --git a/Makefile b/Makefile
index 9f7e3ba..248dbf6 100644
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,8 @@
 CC = gcc
 
 # Options for the compiler: A high optimization level is suggested
-CFLAGS = -O2 -W -Wno-unused-result
-# CFLAGS = -O -g -W -Wall -Wno-unused-result -ansi -pedantic # -DDEBUG
+# CFLAGS = -O2 -W -Wno-unused-result
+CFLAGS = -O -g -W -Wall -ansi -pedantic # -DDEBUG
 
 export CC CFLAGS
 
diff --git a/libjbig/Makefile b/libjbig/Makefile
index f2898f5..20a362a 100644
--- a/libjbig/Makefile
+++ b/libjbig/Makefile
@@ -6,7 +6,21 @@ CC = gcc
 # 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
+OBJS=  jbig.o  \
+      jbig_ar.o    \
+      jbig85.o
+
+all: libjbig.a libjbig85.a tstcodec tstcodec85 shared
+
+shared: $(OBJS)
+	$(CC) -shared -Wl,-soname,libjbig.so -o libjbig.so.2.1 $(OBJS)
+	rm -f libjbig.so
+	ln -fs libjbig.so.2.1 libjbig.so.2
+	ln -fs libjbig.so.2.1 libjbig.so
+	$(CC) -shared -Wl,-soname,libjbig85.so -o libjbig85.so.2.1 $(OBJS)
+	rm -f libjbig85.so
+	ln -fs libjbig85.so.2.1 libjbig85.so.2
+	ln -fs libjbig85.so.2.1 libjbig85.so
 
 tstcodec: tstcodec.o jbig.o jbig_ar.o
 	$(CC) $(CFLAGS) -o tstcodec tstcodec.o jbig.o jbig_ar.o
@@ -50,6 +64,7 @@ t82test.pbm: tstcodec
 	./tstcodec $@
 
 clean:
+	rm -f $(OBJS) jbig.o libjbig.so.2.* libjbig.* libjbig85.so.2.* libjbig85.*
 	rm -f *.o *.gcda *.gcno *.gcov *.plist *~ core gmon.out dbg_d\=??.pbm
 	rm -f t82test.pbm
 	rm -f tstcodec tstcodec85
-- 
2.16.2

