--- ./Makefile-libbz2_so~	2007-12-09 22:00:50.000000000 +0900
+++ ./Makefile-libbz2_so	2010-08-04 00:41:21.000000000 +0900
@@ -1,6 +1,6 @@
 
 # This Makefile builds a shared version of the library, 
-# libbz2.so.1.0.4, with soname libbz2.so.1.0,
+# libbz2.so.1.0.5, with soname libbz2.so.1.0,
 # at least on x86-Linux (RedHat 7.2), 
 # with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98).  
 # Please see the README file for some important info 
@@ -22,10 +22,14 @@
 
 
 SHELL=/bin/sh
-CC=gcc
+CC=gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
 BIGFILES=-D_FILE_OFFSET_BITS=64
 CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
 
+# Where you want it installed when you do 'make install'
+PREFIX=/opt/local
+
+
 OBJS= blocksort.o  \
       huffman.o    \
       crctable.o   \
@@ -35,13 +39,27 @@
       bzlib.o
 
 all: $(OBJS)
-	$(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.4 $(OBJS)
-	$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.4
-	rm -f libbz2.so.1.0
-	ln -s libbz2.so.1.0.4 libbz2.so.1.0
+#	$(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.5 $(OBJS)
+#	$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.5
+#	rm -f libbz2.so.1.0
+#	ln -s libbz2.so.1.0.5 libbz2.so.1.0
+	$(CC) -dynamiclib -install_name /opt/local/lib/libbz2.1.0.5.dylib -current_version 1.0.5 -compatibility_version 1.0.0 -o libbz2.1.0.5.dylib $(OBJS)
+	rm -f libbz2.1.0.dylib libbz2.dylib
+	ln -s libbz2.1.0.5.dylib libbz2.1.0.dylib
+	ln -s libbz2.1.0.5.dylib libbz2.dylib
+
+#install: libbz2.so.1.0.5
+install: libbz2.1.0.5.dylib
+	cp -f libbz2.1.0.5.dylib $(PREFIX)/lib
+	chmod a+r $(PREFIX)/lib/libbz2.1.0.5.dylib	 
+	(cd $(PREFIX)/lib; \
+	rm -f libbz2.1.0.dylib libbz2.dylib; \
+	ln -s libbz2.1.0.5.dylib libbz2.1.0.dylib; \
+	ln -s libbz2.1.0.5.dylib libbz2.dylib)
 
 clean: 
-	rm -f $(OBJS) bzip2.o libbz2.so.1.0.4 libbz2.so.1.0 bzip2-shared
+#	rm -f $(OBJS) bzip2.o libbz2.so.1.0.5 libbz2.so.1.0 bzip2-shared
+	rm -f $(OBJS) bzip2.o libbz2.1.0.5.dylib libbz2.1.0.dylib libbz2.dylib
 
 blocksort.o: blocksort.c
 	$(CC) $(CFLAGS) -c blocksort.c
--- ./Makefile~	2008-02-14 21:39:18.000000000 +0900
+++ ./Makefile	2010-08-04 02:25:56.000000000 +0900
@@ -15,7 +15,7 @@
 SHELL=/bin/sh
 
 # To assist in cross-compiling
-CC=gcc
+CC=gcc -arch ppc -arch ppc64 -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
 AR=ar
 RANLIB=ranlib
 LDFLAGS=
@@ -24,7 +24,7 @@
 CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
 
 # Where you want it installed when you do 'make install'
-PREFIX=/usr/local
+PREFIX=/opt/local
 
 
 OBJS= blocksort.o  \
@@ -38,6 +38,7 @@
 all: libbz2.a bzip2 bzip2recover test
 
 bzip2: libbz2.a bzip2.o
+#	$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o libbz2.a
 	$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
 
 bzip2recover: bzip2recover.o
@@ -55,12 +56,12 @@
 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
+	DYLD_LIBRARY_PATH=. ./bzip2 -1  < sample1.ref > sample1.rb2
+	DYLD_LIBRARY_PATH=. ./bzip2 -2  < sample2.ref > sample2.rb2
+	DYLD_LIBRARY_PATH=. ./bzip2 -3  < sample3.ref > sample3.rb2
+	DYLD_LIBRARY_PATH=. ./bzip2 -d  < sample1.bz2 > sample1.tst
+	DYLD_LIBRARY_PATH=. ./bzip2 -d  < sample2.bz2 > sample2.tst
+	DYLD_LIBRARY_PATH=. ./bzip2 -ds < sample3.bz2 > sample3.tst
 	cmp sample1.bz2 sample1.rb2 
 	cmp sample2.bz2 sample2.rb2
 	cmp sample3.bz2 sample3.rb2
@@ -90,14 +91,20 @@
 	cp -f libbz2.a $(PREFIX)/lib
 	chmod a+r $(PREFIX)/lib/libbz2.a
 	cp -f bzgrep $(PREFIX)/bin/bzgrep
-	ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
-	ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
+	(cd $(PREFIX)/bin; \
+	rm -f bzegrep bzfgrep; \
+	ln -s bzgrep bzegrep; \
+	ln -s bzgrep bzfgrep)
 	chmod a+x $(PREFIX)/bin/bzgrep
 	cp -f bzmore $(PREFIX)/bin/bzmore
-	ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless
+	(cd $(PREFIX)/bin; \
+	rm -f bzless; \
+	ln -s bzmore bzless)
 	chmod a+x $(PREFIX)/bin/bzmore
 	cp -f bzdiff $(PREFIX)/bin/bzdiff
-	ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp
+	(cd $(PREFIX)/bin; \
+	rm -f bzcmp; \
+	ln -s bzdiff bzcmp)
 	chmod a+x $(PREFIX)/bin/bzdiff
 	cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
 	chmod a+r $(PREFIX)/man/man1/bzgrep.1
