--- Makefile.orig	2011-08-30 07:28:10.000000000 +1000
+++ Makefile	2011-09-28 01:05:26.000000000 +1000
@@ -23,11 +23,6 @@
 ########
 
 # For GNU CC on *BSD. Should work for FreeBSD, NetBSD, OpenBSD and BSD/OS
-LINK_SHARED	= $(CC) -shared
-SHLIB_EXT	= so
-SHLIB_NOVER	= $(LIB_NAME).$(SHLIB_EXT)
-SHLIB		= $(LIB_NAME).$(SHLIB_EXT).$(VERSION)
-SHLIB_INSTALLED = $(LIBDIR)/$(LIB_NAME).$(SHLIB_EXT).$(MAJOR)
 
 ############
 # Mac OS X #
@@ -35,13 +30,13 @@
 
 # Benjamin Reed <ranger@befunk.com>:
 # On Mac OS X, comment out the above lines, and uncomment these instead.
-#LINK_SHARED	= $(CC) -install_name $(PREFIX)/lib/$(SHLIB) \
-#			-compatibility_version $(COMPAT_VERSION) \
-#			-current_version $(VERSION) -dynamiclib
-#SHLIB_EXT	= dylib
-#SHLIB_NOVER	= $(LIB_NAME).$(SHLIB_EXT)
-#SHLIB		= $(LIB_NAME).$(VERSION).$(SHLIB_EXT)
-#SHLIB_INSTALLED= $(LIBDIR)/$(LIB_NAME).$(MAJOR).$(SHLIB_EXT)
+LINK_SHARED	= $(CC) $(LDFLAGS) -install_name $(PREFIX)/lib/$(SHLIB) \
+			-compatibility_version $(COMPAT_VERSION) \
+			-current_version $(VERSION) -dynamiclib
+SHLIB_EXT	= dylib
+SHLIB_NOVER	= $(LIB_NAME).$(SHLIB_EXT)
+SHLIB		= $(LIB_NAME).$(VERSION).$(SHLIB_EXT)
+SHLIB_INSTALLED= $(LIBDIR)/$(LIB_NAME).$(MAJOR).$(SHLIB_EXT)
 
 # NOTE: If you have linkage problems on the Mac (see the POSSIBLE ISSUES
 # section in the INSTALL file), uncomment the following definition. Be sure
@@ -68,8 +63,8 @@
 CC		= cc
 LIB_NAME	= libpoll
 LIB		= $(LIB_NAME).a
-COMPILE_STATIC	= $(CC) -c 
-COMPILE_SHARED	= $(CC) -c -fPIC 
+COMPILE_STATIC	= $(CC) $(CFLAGS) -c 
+COMPILE_SHARED	= $(CC) $(CFLAGS) -c -fPIC 
 RANLIB		= ranlib
 CPPFLAGS        = $(POLL_RENAME)
 
@@ -107,4 +102,4 @@
 $(LIB):		poll.o
 		ar rv $(LIB) poll.o
 polltest:	polltest.o
-		$(CC) -o polltest polltest.o $(LIB)
+		$(CC) $(CFLAGS) -o polltest polltest.o $(LIB)
