--- Makefile.orig	2004-01-28 13:13:03.000000000 -0700
+++ Makefile	2004-01-28 13:13:30.918589000 -0700
@@ -9,7 +9,7 @@
 
 # Suitably paranoid flags to avoid bugs in gcc-2.7
 BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce $(BIGFILES)
+CFLAGS=-Wall -Winline -O2 -fPIC -fpic -fomit-frame-pointer -fno-strength-reduce $(BIGFILES)
 
 # Where you want it installed when you do 'make install'
 PREFIX=/usr
@@ -23,7 +23,7 @@
       decompress.o \
       bzlib.o
 
-all: libbz2.a bzip2 bzip2recover test
+all: libbz2.a libbz2.so.1.0.2 bzip2 bzip2recover test
 
 bzip2: libbz2.a bzip2.o
 	$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
@@ -40,15 +40,19 @@
 		$(RANLIB) libbz2.a ; \
 	fi
 
+libbz2.so.1.0.2: $(OBJS)
+	rm -f libbz2.so
+	$(CC) -shared -o libbz2.so.1.0.2 $(OBJS)
+
 check: test
 test: bzip2
 	@cat words1
-	./bzip2 -1  < sample1.ref > sample1.rb2
-	./bzip2 -2  < sample2.ref > sample2.rb2
-	./bzip2 -3  < sample3.ref > sample3.rb2
-	./bzip2 -d  < sample1.bz2 > sample1.tst
-	./bzip2 -d  < sample2.bz2 > sample2.tst
-	./bzip2 -ds < sample3.bz2 > sample3.tst
+	LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):. ./bzip2 -1  < sample1.ref > sample1.rb2
+	LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):. ./bzip2 -2  < sample2.ref > sample2.rb2
+	LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):. ./bzip2 -3  < sample3.ref > sample3.rb2
+	LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):. ./bzip2 -d  < sample1.bz2 > sample1.tst
+	LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):. ./bzip2 -d  < sample2.bz2 > sample2.tst
+	LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):. ./bzip2 -ds < sample3.bz2 > sample3.tst
 	cmp sample1.bz2 sample1.rb2 
 	cmp sample2.bz2 sample2.rb2
 	cmp sample3.bz2 sample3.rb2
@@ -77,6 +81,10 @@
 	chmod a+r $(PREFIX)/include/bzlib.h
 	cp -f libbz2.a $(PREFIX)/lib
 	chmod a+r $(PREFIX)/lib/libbz2.a
+	cp -f libbz2.so.1.0.2 $(PREFIX)/lib
+	chmod a+r $(PREFIX)/lib/libbz2.so.1.0.2
+	ln -s libbz2.so.1.0.2 $(PREFIX)/lib/libbz2.so.1
+	ln -s libbz2.so.1.0.2 $(PREFIX)/lib/libbz2.so
 	cp -f bzgrep $(PREFIX)/bin/bzgrep
 	ln $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
 	ln $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
@@ -98,7 +106,7 @@
 
 distclean: clean
 clean: 
-	rm -f *.o libbz2.a bzip2 bzip2recover \
+	rm -f *.o libbz2.a libbz2.so.1.0.2 bzip2 bzip2recover \
 	sample1.rb2 sample2.rb2 sample3.rb2 \
 	sample1.tst sample2.tst sample3.tst
 
