diff -ruN imap-2006k.orig/Makefile imap-2006k/Makefile
--- imap-2006k.orig/Makefile	2007-11-07 16:16:50.000000000 -0700
+++ imap-2006k/Makefile	2007-12-10 13:57:06.000000000 -0700
@@ -102,6 +102,7 @@
 # os4	OSF/1 (Digital UNIX) 4
 # osx	Mac OS X
 # oxp	Mac OS X with Pluggable Authentication Modules (PAM)
+# ops	Mac OS X with Pluggable Authentication Modules (Shared c-client lib)
 # ptx	PTX
 # pyr	Pyramid
 # qnx	QNX 4
@@ -411,6 +412,13 @@
 	EXTRACFLAGS="$(EXTRACFLAGS) -I/usr/kerberos/include" \
 	SPECIALS="SSLINCLUDE=/usr/include/openssl SSLLIB=/usr/lib SSLCERTS=/usr/share/ssl/certs SSLKEYS=/usr/share/ssl/private GSSDIR=/usr/kerberos LOCKPGM=/usr/sbin/mlock"
 
+ops:	an
+	$(TOUCH) ip6
+	$(BUILD) BUILDTYPE=osx IP=$(IP6) EXTRAAUTHENTICATORS="$(EXTRAAUTHENTICATORS) gss" \
+	PASSWDTYPE=pam \
+	EXTRACFLAGS="$(EXTRACFLAGS) -DMAC_OSX_KLUDGE=1" \
+	SPECIALS="SSLINCLUDE=/usr/include/openssl SSLLIB=/usr/lib SSLCERTS=@FINKPREFIX@/etc/ssl/certs SSLKEYS=@FINKPREFIX@/etc/ssl/private GSSINCLUDE=/usr/include GSSLIB=/usr/lib SPOOLDIR=@FINKPREFIX@/var/spool LOCKPGM=@FINKPREFIX@/sbin/uw-mlock PAMDLFLAGS=-lpam"
+
 oxp:	an
 	$(TOUCH) ip6
 	$(BUILD) BUILDTYPE=osx IP=$(IP6) EXTRAAUTHENTICATORS="$(EXTRAAUTHENTICATORS) gss" \
@@ -731,3 +739,31 @@
 # A monument to a hack of long ago and far away...
 love:
 	@echo not war?
+
+install:
+	mkdir -p $(DESTDIR)/sbin
+	mkdir -p $(DESTDIR)/bin
+	mkdir -p $(DESTDIR)/lib
+	mkdir -p $(DESTDIR)/include/c-client
+	install -m755 ipopd/ipop2d $(DESTDIR)/sbin/uw-ipop2d
+	install -m755 ipopd/ipop3d $(DESTDIR)/sbin/uw-ipop3d
+	install -m755 imapd/imapd $(DESTDIR)/sbin/uw-imapd
+	install -m755 mlock/mlock $(DESTDIR)/bin/uw-mlock
+	install -m755 dmail/dmail $(DESTDIR)/bin/uw-dmail
+	install -m755 tmail/tmail $(DESTDIR)/bin/uw-tmail
+	install -m755 mailutil/mailutil $(DESTDIR)/bin/uw-mailutil
+	for i in src/c-client/*.h; do \
+		install -m644 $$i $(DESTDIR)/include/c-client; \
+	done
+	for i in src/osdep/unix/*.h; do \
+		install -m644 $$i $(DESTDIR)/include/c-client; \
+	done
+	install -m644 c-client/auths.c $(DESTDIR)/include/c-client
+	install -m644 c-client/linkage.c $(DESTDIR)/include/c-client
+	install -m644 c-client/linkage.h $(DESTDIR)/include/c-client
+	install -m644 c-client/osdep.h $(DESTDIR)/include/c-client
+	install -m644 c-client/libc-client.a $(DESTDIR)/lib
+	ranlib $(DESTDIR)/lib/libc-client.a
+	install -m644 c-client/libc-client.`cat c-client/MAJOR`.0.0.`cat c-client/SHLIBEXT` $(DESTDIR)/lib
+	ln -s $(PREFIX)/lib/libc-client.`cat c-client/MAJOR`.0.0.`cat c-client/SHLIBEXT` $(DESTDIR)/lib/libc-client.`cat c-client/MAJOR`.`cat c-client/SHLIBEXT`
+	ln -s $(PREFIX)/lib/libc-client.`cat c-client/MAJOR`.0.0.`cat c-client/SHLIBEXT` $(DESTDIR)/lib/libc-client.`cat c-client/SHLIBEXT`
diff -ruN imap-2006k.orig/src/dmail/Makefile imap-2006k/src/dmail/Makefile
--- imap-2006k.orig/src/dmail/Makefile	2007-09-10 17:56:35.000000000 -0600
+++ imap-2006k/src/dmail/Makefile	2007-12-10 13:26:01.000000000 -0700
@@ -26,7 +26,7 @@
 
 
 C = ../c-client
-CCLIENTLIB = $C/c-client.a
+CCLIENTLIB = 
 SHELL = /bin/sh
 
 # Get local definitions from c-client directory
diff -ruN imap-2006k.orig/src/imapd/Makefile imap-2006k/src/imapd/Makefile
--- imap-2006k.orig/src/imapd/Makefile	2006-08-30 18:10:44.000000000 -0600
+++ imap-2006k/src/imapd/Makefile	2007-12-10 13:25:11.000000000 -0700
@@ -43,12 +43,13 @@
 # Get local definitions from c-client directory
 
 C = ../c-client
-CCLIENTLIB = $C/c-client.a
+CCLIENTLIB = $C/`cat $C/ARCHIVENAME`
+
 CC = `cat $C/CCTYPE`
 CFLAGS = -I$C `cat $C/CFLAGS` $(NSBD) $(ENBD) -DANOFILE=\"$(ANO)\" \
 	-DALERTFILE=\"$(ALERT)\" -DNNTPFILE=\"$(NNTP)\" \
 	-DUSERALERTFILE=\"$(USERALERT)\" -DSHUTDOWNFILE=\"$(SHUTDOWN)\"
-LDFLAGS = $(CCLIENTLIB) `cat $C/LDFLAGS`
+LDFLAGS = `cat $C/LDFLAGS`
 
 all:	imapd
 
diff -ruN imap-2006k.orig/src/ipopd/Makefile imap-2006k/src/ipopd/Makefile
--- imap-2006k.orig/src/ipopd/Makefile	2006-08-30 18:17:30.000000000 -0600
+++ imap-2006k/src/ipopd/Makefile	2007-12-10 13:25:21.000000000 -0700
@@ -26,14 +26,14 @@
 
 
 C = ../c-client
-CCLIENTLIB = $C/c-client.a
+CCLIENTLIB = $C/`cat $C/ARCHIVENAME`
 SHELL = /bin/sh
 
 # Get local definitions from c-client directory
 
 CC = `cat $C/CCTYPE`
 CFLAGS = -I$C `cat $C/CFLAGS`
-LDFLAGS = $(CCLIENTLIB) `cat $C/LDFLAGS`
+LDFLAGS = `cat $C/LDFLAGS`
 
 ipopd: ipop2d ipop3d
 
diff -ruN imap-2006k.orig/src/mailutil/Makefile imap-2006k/src/mailutil/Makefile
--- imap-2006k.orig/src/mailutil/Makefile	2006-08-30 18:21:20.000000000 -0600
+++ imap-2006k/src/mailutil/Makefile	2007-12-10 13:25:45.000000000 -0700
@@ -26,7 +26,7 @@
 
 
 C = ../c-client
-CCLIENTLIB = $C/c-client.a
+CCLIENTLIB = 
 SHELL = /bin/sh
 
 # Get local definitions from c-client directory
diff -ruN imap-2006k.orig/src/mtest/Makefile imap-2006k/src/mtest/Makefile
--- imap-2006k.orig/src/mtest/Makefile	2006-08-30 18:25:07.000000000 -0600
+++ imap-2006k/src/mtest/Makefile	2007-12-10 13:25:33.000000000 -0700
@@ -26,7 +26,7 @@
 
 
 C = ../c-client
-CCLIENTLIB = $C/c-client.a
+CCLIENTLIB = 
 SHELL = /bin/sh
 
 # Get local definitions from c-client directory
diff -ruN imap-2006k.orig/src/osdep/unix/Makefile imap-2006k/src/osdep/unix/Makefile
--- imap-2006k.orig/src/osdep/unix/Makefile	2007-06-17 09:37:44.000000000 -0600
+++ imap-2006k/src/osdep/unix/Makefile	2007-12-10 13:57:39.000000000 -0700
@@ -144,7 +144,11 @@
 
 # Normally no need to change any of these
 
-ARCHIVE=c-client.a
+ARCHIVE=libc-client.a
+SHARED-C-CLIENT=c-client
+MAJOR=1
+SHLIBEXT=dylib
+
 BINARIES=osdep.o mail.o misc.o newsrc.o smanager.o utf8.o utf8aux.o siglocal.o \
  dummy.o pseudo.o netmsg.o flstring.o fdstring.o \
  rfc822.o nntp.o smtp.o imap4r1.o pop3.o \
@@ -577,9 +581,19 @@
 osx:	# Mac OS X
 	$(BUILD) `$(CAT) SPECIALS` OS=$@ \
 	 CRXTYPE=nfs \
-	 SPOOLDIR=/var/spool MAILSPOOL=/var/mail \
+	 SPOOLDIR=@FINKPREFIX@/var/spool MAILSPOOL=@FINKPREFIX@/var/mail \
 	 RSHPATH=/usr/bin/rsh \
-	 BASECFLAGS="$(GCC4CFLAGS)"
+	 BASECFLAGS="$(GCC4CFLAGS)" \
+	 BASELDFLAGS="-L../c-client -l$(SHARED-C-CLIENT)" \
+	 RANLIB=true \
+	 CC=gcc
+
+osxshared: $(BINARIES) $(SHARED-C-CLIENT).$(SHLIBEXT)
+
+$(SHARED-C-CLIENT).$(SHLIBEXT):
+	$(CC) -dynamiclib -undefined dynamic_lookup -install_name @FINKPREFIX@/lib/lib$(SHARED-C-CLIENT).$(MAJOR).$(SHLIBEXT) -compatibility_version 2.0 -current_version 2.0 -o lib$(SHARED-C-CLIENT).$(MAJOR).0.0.$(SHLIBEXT) $(BINARIES) `cat EXTRALDFLAGS`
+	ln -s lib$(SHARED-C-CLIENT).$(MAJOR).0.0.$(SHLIBEXT) lib$(SHARED-C-CLIENT).$(MAJOR).$(SHLIBEXT)
+	ln -s lib$(SHARED-C-CLIENT).$(MAJOR).0.0.$(SHLIBEXT) lib$(SHARED-C-CLIENT).$(SHLIBEXT)
 
 ptx:	# PTX
 	$(BUILD) `$(CAT) SPECIALS` OS=$@ \
@@ -840,7 +854,7 @@
 
 # Build it!
 
-build:	clean once $(ARCHIVE)
+build:	clean once $(ARCHIVE) osxshared
 
 all:	$(ARCHIVE)
 
@@ -856,7 +870,7 @@
 # Cleanup
 
 clean:
-	sh -c '$(RM) auths.c crexcl.c ip_unix.c linkage.[ch] siglocal.c osdep*.[ch] *.o ARCHIVE *FLAGS *TYPE $(ARCHIVE) || true'
+	sh -c '$(RM) auths.c crexcl.c ip_unix.c linkage.[ch] siglocal.c osdep*.[ch] *.o ARCHIVE ARCHIVENAME EXTRALDFLAGS SHARED-C-CLIENT *FLAGS *TYPE $(ARCHIVE) $(SHARED-C-CLIENT).$(SHLIBEXT) $(SHARED-C-CLIENT).$(MAJOR).$(SHLIBEXT) $(SHARED-C-CLIENT).$(MAJOR).0.0.$(SHLIBEXT) || true'
 
 
 # Dependencies
@@ -949,7 +963,12 @@
 
 # Once-only environment setup
 
-once:	onceenv ckp$(PASSWDTYPE) ssl$(SSLTYPE) osdep.c
+once:	onceenv ckp$(PASSWDTYPE) ssl$(SSLTYPE) secondenv osdep.c
+
+secondenv:
+	@echo Second-only environment setup...
+	mv LDFLAGS EXTRALDFLAGS
+	echo $(BASELDFLAGS) `cat EXTRALDFLAGS` > LDFLAGS
 
 onceenv:
 	@echo Once-only environment setup...
@@ -960,8 +979,12 @@
 	 -DANONYMOUSHOME=\"$(MAILSPOOL)/anonymous\" \
 	 -DACTIVEFILE=\"$(ACTIVEFILE)\" -DNEWSSPOOL=\"$(NEWSSPOOL)\" \
 	 -DRSHPATH=\"$(RSHPATH)\" -DLOCKPGM=\"$(LOCKPGM)\" > OSCFLAGS
-	echo $(BASELDFLAGS) $(EXTRALDFLAGS) > LDFLAGS
+	echo $(EXTRALDFLAGS) > LDFLAGS
 	echo "$(ARRC) $(ARCHIVE) $(BINARIES);$(RANLIB) $(ARCHIVE)" > ARCHIVE
+	echo $(ARCHIVE) > ARCHIVENAME
+	echo $(SHARED-C-CLIENT) > SHARED-C-CLIENT
+	echo $(MAJOR) > MAJOR
+	echo $(SHLIBEXT) > SHLIBEXT
 	echo $(OS) > OSTYPE
 	./drivers $(EXTRADRIVERS) $(DEFAULTDRIVERS) dummy
 	./mkauths $(EXTRAAUTHENTICATORS) $(DEFAULTAUTHENTICATORS)
diff -ruN imap-2006k.orig/src/tmail/Makefile imap-2006k/src/tmail/Makefile
--- imap-2006k.orig/src/tmail/Makefile	2007-09-10 17:44:27.000000000 -0600
+++ imap-2006k/src/tmail/Makefile	2007-12-10 13:25:56.000000000 -0700
@@ -26,7 +26,7 @@
 
 
 C = ../c-client
-CCLIENTLIB = $C/c-client.a
+CCLIENTLIB = 
 SHELL = /bin/sh
 
 # Get local definitions from c-client directory
