Author: Andreas Tille <tille@debian.org>
Last-Update: Tue, 29 Mar 2016 22:11:29 +0200
Description: Enable building dynamic library

--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,8 @@
 # 
 # ============================================================================
 
+SOVERSION=0
+
 # ----------------------------------------------------------------------------
 # adapt these settings to your need:
 # add '-DGZSTREAM_NAMESPACE=name' to CPPFLAGS to place the classes
@@ -47,14 +49,14 @@ AR       = ar cr
 # make cleanall;  removes temporary files, the library, and programs
 # ----------------------------------------------------------------------------
 
-default: libgzstream.a
+default: libgzstream.a libgzstream.so
 
 test:    test_gzip test_gunzip
-	./test_gzip COPYING.LIB gz.tmp.gz
+	LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" ./test_gzip COPYING.LIB gz.tmp.gz
 	gunzip gz.tmp.gz
 	diff COPYING.LIB gz.tmp
 	gzip gz.tmp
-	./test_gunzip gz.tmp.gz gz.tmp
+	LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" ./test_gunzip gz.tmp.gz gz.tmp
 	diff COPYING.LIB gz.tmp
 	rm gz.tmp.gz gz.tmp
 	# *** O.K. Test finished successfully. ***
@@ -77,6 +79,11 @@ test_gunzip.o : test_gunzip.C gzstream.h
 libgzstream.a : gzstream.o
 	${AR} libgzstream.a gzstream.o
 
+libgzstream.so : gzstream.C gzstream.h
+	${CXX} ${CPPFLAGS} -fPIC -c -o gzstream.o gzstream.C
+	${CXX} ${LDFLAGS} -shared -Wl,-soname,$@.$(SOVERSION) -o $@.$(SOVERSION) gzstream.o
+	ln -s $@.$(SOVERSION) $@
+
 test_gzip : test_gzip.o libgzstream.a
 	${CXX} -o test_gzip test_gzip.o ${LDFLAGS}
 
