--- libjbig/Makefile.orig	2010-02-26 14:31:06.000000000 -0800
+++ libjbig/Makefile	2010-02-26 14:31:31.000000000 -0800
@@ -7,7 +7,7 @@ CC = gcc
 # Options for the compiler: A high optimization level is suggested
 CFLAGS = -g -O -Wall -ansi -pedantic # --coverage
 
-all: libjbig.a tstcodec tstcodec85
+all: libjbig.dylib
 
 tstcodec: tstcodec.o jbig.o jbig_ar.o
 	$(CC) $(CFLAGS) -o tstcodec $+
@@ -25,6 +25,13 @@ libjbig85.a: jbig85.o jbig_ar.o
 	ar rc libjbig85.a jbig85.o jbig_ar.o
 	-ranlib libjbig85.a
 
+libjbig.dylib: libjbig.__MACPORTS_VERSION__.dylib
+	ln -s $< $@
+
+libjbig.__MACPORTS_VERSION__.dylib:  jbig.o jbig_ar.o
+	rm -f $@
+	$(CC) $(CFLAGS) -dynamiclib -install_name __MACPORTS_PREFIX__/lib/libjbig.__MACPORTS_INSTALL_VERSION__.dylib -o $@ $^
+
 jbig.o: jbig.c jbig.h jbig_ar.h
 jbig85.o: jbig85.c jbig85.h jbig_ar.h
 jbig_ar.o: jbig_ar.c jbig_ar.h
