--- Makefile.in.orig	2007-03-28 12:26:27.000000000 +0100
+++ Makefile.in	2007-03-28 12:21:01.000000000 +0100
@@ -1,6 +1,7 @@
 # Makefile used by configure to create real Makefile
 
 CC=@CC@
+SHLIB_EXT=@SHLIB_EXT@
 prefix=@prefix@
 exec_prefix = @exec_prefix@
 libexecdir = @libexecdir@
@@ -24,12 +25,13 @@
 SCRIPT = tsocks
 SHLIB_MAJOR = 1
 SHLIB_MINOR = 8
-SHLIB = ${LIB_NAME}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
+SHLIB = ${LIB_NAME}.${SHLIB_EXT}.${SHLIB_MAJOR}.${SHLIB_MINOR}
 DEADPOOL_O = @DEADPOOL_O@
 
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 CFLAGS = @CFLAGS@
+LDFLAGS = @LDFLAGS@
 INCLUDES = -I.
 LIBS = @LIBS@
 SPECIALLIBS = @SPECIALLIBS@
@@ -49,11 +51,11 @@
 	${SHCC} ${CFLAGS} ${INCLUDES} -o ${INSPECT} ${INSPECT}.c ${COMMON}.o ${LIBS} 
 
 ${SAVE}: ${SAVE}.c
-	${SHCC} ${CFLAGS} ${INCLUDES} -static -o ${SAVE} ${SAVE}.c
+	${SHCC} ${CFLAGS} ${INCLUDES} -o ${SAVE} ${SAVE}.c
 
 ${SHLIB}: ${OBJS} ${COMMON}.o ${PARSER}.o ${DEADPOOL_O}
-	${SHCC} ${CFLAGS} ${INCLUDES} -nostdlib -shared -o ${SHLIB} ${OBJS} ${COMMON}.o ${PARSER}.o ${DEADPOOL_O} ${DYNLIB_FLAGS} ${SPECIALLIBS} ${LIBS}
-	ln -sf ${SHLIB} ${LIB_NAME}.so
+	${SHCC} ${CFLAGS} ${INCLUDES} ${LDFLAGS} -o ${SHLIB} ${OBJS} ${COMMON}.o ${PARSER}.o ${DEADPOOL_O}
+	ln -sf ${SHLIB} ${LIB_NAME}.${SHLIB_EXT}
 
 %.so: %.c
 	${SHCC} ${CFLAGS} ${INCLUDES} -c ${CC_SWITCHES} $< -o $@
@@ -69,8 +71,8 @@
 
 installlib:
 	${MKINSTALLDIRS} "${DESTDIR}${libdir}"
-	${INSTALL} ${SHLIB} ${DESTDIR}${libdir}/${LIB_NAME}.so.${SHLIB_MAJOR}
-	ln -sf ${LIB_NAME}.so.${SHLIB_MAJOR} ${DESTDIR}${libdir}/${LIB_NAME}.so
+	${INSTALL} ${SHLIB} ${DESTDIR}${libdir}/${LIB_NAME}.${SHLIB_EXT}.${SHLIB_MAJOR}
+	ln -sf ${LIB_NAME}.${SHLIB_EXT}.${SHLIB_MAJOR} ${DESTDIR}${libdir}/${LIB_NAME}.${SHLIB_EXT}
 
 installman:
 	${MKINSTALLDIRS} "${DESTDIR}${mandir}/man1"
@@ -81,7 +83,7 @@
 	${INSTALL_DATA} tsocks.conf.5 ${DESTDIR}${mandir}/man5/
 	
 clean:
-	-rm -f *.so *.so.* *.o *~ ${TARGETS}
+	-rm -f *.so *.so.* *.dylib *.dylib.* *.o *~ ${TARGETS}
 
 distclean: clean
 	-rm -f config.cache config.log config.h Makefile \
