--- Makefile.orig	Tue Jul  6 18:38:07 1999
+++ Makefile	Tue Aug 10 22:26:08 1999
@@ -1,7 +1,7 @@
 
 SHELL=/bin/sh
-CC=gcc
-CFLAGS=-Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce
+#CC=gcc
+CFLAGS+=-Wall -Winline -fomit-frame-pointer -fno-strength-reduce
 
 OBJS= blocksort.o  \
       huffman.o    \
@@ -11,9 +11,11 @@
       decompress.o \
       bzlib.o
 
-all: libbz2.a bzip2 bzip2recover test
+.SUFFIXES: .c .so .o
 
-bzip2: libbz2.a bzip2.o
+all: libbz2.a libbz2.so.${VER} bzip2 bzip2recover
+
+bzip2: libbz2.a libbz2.so.${VER} bzip2.o
 	$(CC) $(CFLAGS) -o bzip2 bzip2.o -L. -lbz2
 
 bzip2recover: bzip2recover.o
@@ -28,6 +30,10 @@
 		ranlib libbz2.a ; \
 	fi
 
+libbz2.so.${VER}: $(OBJS:S/o$/so/g)
+	rm -f libbz2.so.${VER}
+	ld -Bshareable -Bforcearchive -o libbz2.so.${VER} $(OBJS:S/o$/so/g)
+
 test: bzip2
 	@cat words1
 	./bzip2 -1  < sample1.ref > sample1.rb2
@@ -44,8 +50,6 @@
 	cmp sample3.tst sample3.ref
 	@cat words3
 
-PREFIX=/usr
-
 install: bzip2 bzip2recover
 	if ( test ! -d $(PREFIX)/bin ) ; then mkdir $(PREFIX)/bin ; fi
 	if ( test ! -d $(PREFIX)/lib ) ; then mkdir $(PREFIX)/lib ; fi
@@ -68,7 +72,7 @@
 	chmod a+r $(PREFIX)/lib/libbz2.a
 
 clean: 
-	rm -f *.o libbz2.a bzip2 bzip2recover \
+	rm -f *.o *.so libbz2.a libbz2.so.${VER} bzip2 bzip2recover \
 	sample1.rb2 sample2.rb2 sample3.rb2 \
 	sample1.tst sample2.tst sample3.tst
 
@@ -90,6 +94,9 @@
 	$(CC) $(CFLAGS) -c bzip2.c
 bzip2recover.o: bzip2recover.c
 	$(CC) $(CFLAGS) -c bzip2recover.c
+
+.c.so:
+	$(CC) -fpic -DPIC $(CFLAGS) -c $*.c -o $*.so
 
 tarfile:
 	tar cvf interim.tar blocksort.c huffman.c crctable.c \
