1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
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}
|