diff --git a/GLFW-b.cabal b/GLFW-b.cabal
--- a/GLFW-b.cabal
+++ b/GLFW-b.cabal
@@ -1,5 +1,5 @@
 name:         GLFW-b
-version:      0.0.2.6
+version:      0.0.2.7
 
 category:     Graphics
 
@@ -66,21 +66,22 @@
   include-dirs:
     glfw/include
     glfw/lib
-  c-sources:
-    glfw/lib/enable.c
-    glfw/lib/fullscreen.c
-    glfw/lib/glext.c
-    glfw/lib/image.c
-    glfw/lib/init.c
-    glfw/lib/input.c
-    glfw/lib/joystick.c
-    glfw/lib/stream.c
-    glfw/lib/tga.c
-    glfw/lib/thread.c
-    glfw/lib/time.c
-    glfw/lib/window.c
+  if !os(darwin)
+    c-sources:
+      glfw/lib/enable.c
+      glfw/lib/fullscreen.c
+      glfw/lib/glext.c
+      glfw/lib/image.c
+      glfw/lib/init.c
+      glfw/lib/input.c
+      glfw/lib/joystick.c
+      glfw/lib/stream.c
+      glfw/lib/tga.c
+      glfw/lib/thread.c
+      glfw/lib/time.c
+      glfw/lib/window.c
 
-  if os(linux)
+  if os(linux) || os(freebsd)
     include-dirs:
       glfw/lib/x11
     c-sources:
@@ -109,12 +110,6 @@
       Xrandr
   else
     if os(darwin)
-      include-dirs:
-        glfw/lib/cocoa
-      frameworks:
-        AGL
-        Cocoa
-        OpenGL
       extra-libraries: glfw
       extra-lib-dirs: build
     else
@@ -134,7 +129,7 @@
         extra-libraries:
           opengl32
 
-  ghc-options: -Wall -O2
+  ghc-options: -Wall -O2 -fPIC
   if impl(ghc >= 6.8)
     ghc-options: -fwarn-tabs
 
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,9 @@
-GCCFLAGS  := $(shell ghc --info | ghc -e "fmap read getContents >>= putStrLn . unwords . read . Data.Maybe.fromJust . lookup \"Gcc Linker flags\"")
-FRAMEWORK := -framework AGL -framework Cocoa -framework OpenGL
-GLFW_FLAG := $(GCCFLAGS) -msse2 -O2 -Iglfw/include -Iglfw/lib -Iglfw/lib/cocoa $(CFLAGS)
+GCCFLAGS  := $(shell ghc --info | ghc -e "fmap read getContents >>=   \
+             putStrLn . unwords . read . Data.Maybe.fromJust . lookup \
+             \"Gcc Linker flags\"")
+FRAMEWORK := -framework Cocoa -framework OpenGL
+GLFW_FLAG := $(GCCFLAGS) -O2 -fno-common -Iglfw/include -Iglfw/lib    \
+             -Iglfw/lib/cocoa $(CFLAGS)
 SRC_DIR   := glfw/lib/cocoa
 GLFW_DIR  := glfw/lib
 BUILD_DIR := build
@@ -10,14 +13,14 @@
 GLFW_SRC  := $(wildcard $(GLFW_DIR)/*.c)
 OBJS      := $(addprefix $(BUILD_DIR)/, $(OBJ_C_SRC:.m=.o) $(C_SRC:.c=.o))
 
-all: $(BUILD_DIR)/libglfw.a
+all: $(BUILD_DIR)/libglfw.dylib
 
-# The .dylib was creating more problems than it solved.
-#$(BUILD_DIR)/libglfw.dylib: $(OBJS)
-#	$(CC) -dynamiclib $(GLFW_FLAG) -o $@ $(OBJS) $(GLFW_SRC) $(FRAMEWORK)
+$(BUILD_DIR)/libglfw.dylib: $(OBJS)
+	$(CC) -dynamiclib -Wl,-single_module -compatibility_version 1       \
+        -current_version 1                                            \
+        $(GLFW_FLAG) -o $@ $(OBJS) $(GLFW_SRC) $(FRAMEWORK)
 
-$(BUILD_DIR)/libglfw.a: $(OBJS)
-	ar -r -s $@ $(OBJS)
+.PHONY: $(BUILD_DIR)/$(SRC_DIR)/.build-tag
 
 $(BUILD_DIR)/$(SRC_DIR)/.build-tag:
 	mkdir -p $(BUILD_DIR)/$(SRC_DIR)
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -10,7 +10,7 @@
                                  , CopyFlags(..)
                                  , configProgramArgs )
 import Distribution.Simple.Utils ( rawSystemExit, installOrdinaryFile )
-import Distribution.Verbosity ( verbose )
+import Distribution.Verbosity ( verbose, Verbosity )
 import Distribution.Simple ( defaultMainWithHooks
                            , simpleUserHooks
                            , buildHook, Args, confHook
@@ -25,8 +25,8 @@
                                        , PackageDescription )
 import System.FilePath ( (</>) )
 
-extraLibDir :: FilePath
-extraLibDir = "build"
+dynamicLibDir :: FilePath
+dynamicLibDir = "build"
 
 main :: IO ()
 main = defaultMainWithHooks simpleUserHooks
@@ -71,7 +71,8 @@
 
 libDirGlfw :: HookedBuildInfo
 libDirGlfw = (Just buildinfo, [])
-  where buildinfo = emptyBuildInfo { extraLibDirs = [ extraLibDir ] }
+  where buildinfo = emptyBuildInfo
+                     { extraLibDirs = [ dynamicLibDir ] }
 
 postInstGlfw :: Args -> InstallFlags -> PackageDescription
              -> LocalBuildInfo -> IO ()
@@ -95,9 +96,14 @@
             . fromFlag . copyDest $ flags
           libPref = libdir installDirs
           verbosity = fromFlag $ copyVerbosity flags
-          copy dest f = installOrdinaryFile verbosity (extraLibDir</>f) (dest</>f)
-      maybe (return ()) (copy libPref) (Just libName)
+          copyDynamic dest f = installOrdinaryFile verbosity (dynamicLibDir</>f) (dest</>f)
+      maybe (return ()) (copyDynamic libPref) (Just dynamicLibName)
+      install_name_tool verbosity (libPref</>dynamicLibName)
     _ -> return ()
 
-libName :: FilePath
-libName = "libglfw.a"
+install_name_tool :: Verbosity -> FilePath -> IO ()
+install_name_tool v fp = rawSystemExit v "env" $
+  ["install_name_tool"] ++ ["-id"] ++ [fp] ++ [fp]
+
+dynamicLibName :: FilePath
+dynamicLibName = "libglfw.dylib"
