diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,30 @@
+Copyright Neil Mitchell 2013.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the name of Neil Mitchell nor the names of other
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Main.hs b/Main.hs
new file mode 100644
--- /dev/null
+++ b/Main.hs
@@ -0,0 +1,64 @@
+{-# LANGUAGE PatternGuards #-}
+
+module Main(main) where
+
+import Development.Shake
+import Development.Shake.Command
+import Development.Shake.FilePath
+import System.Environment
+import Data.Either
+import Data.List
+import Data.Maybe
+
+
+main :: IO ()
+main = do
+    args <- getArgs
+    let (argsShake, argsGHC) = splitFlags $ delete "--make" args
+    let prefix = maybe ".ghc-make" (</> ".ghc-make") $ dumpDir argsGHC
+
+    withArgs argsShake $ shakeArgs shakeOptions{shakeFiles=prefix, shakeVerbosity=Quiet} $ do
+        want [prefix <.> "makefile"]
+
+        prefix <.> "args" *> \out -> do
+            alwaysRerun
+            writeFileChanged out $ unlines argsGHC
+
+        prefix <.> "makefile" *> \out -> do
+            need [prefix <.> "args"]
+            () <- cmd "ghc -M -dep-makefile" [out] argsGHC
+            opts <- liftIO $ fmap parseMakefile $ readFile out
+            () <- cmd "ghc --make" argsGHC
+            need $ nub $ concatMap (uncurry (:)) opts
+
+
+-- | Split flags into (Shake flags, GHC flags)
+splitFlags :: [String] -> ([String], [String])
+splitFlags = partitionEithers . map f
+    where
+        f x | Just x <- stripPrefix "--shake-" x = Left $ '-':x
+            | Just x <- stripPrefix "-shake-" x = Left $ '-':x
+            | otherwise = Right x
+
+
+-- | Where does the user want to dump temp files (-odir, -hidir)
+--   GHC accepts -odir foo, -odirfoo, -odir=foo
+dumpDir :: [String] -> Maybe FilePath
+dumpDir (flag:x:xs) | flag `elem` dirFlags = Just $ fromMaybe x $ dumpDir xs
+dumpDir (x:xs) | x:_ <- mapMaybe (`stripPrefix` x) dirFlags = Just $ fromMaybe (if "=" `isPrefixOf` x then drop 1 x else x) $ dumpDir xs
+dumpDir (x:xs) = dumpDir xs
+dumpDir [] = Nothing
+
+
+dirFlags = ["-odir","-hidir"]
+
+
+parseMakefile :: String -> [(FilePath, [FilePath])]
+parseMakefile = concatMap f . join . lines
+    where
+        join (x1:x2:xs) | "\\" `isSuffixOf` x1 = join $ (init x1 ++ x2) : xs
+        join (x:xs) = x : join xs
+        join [] = []
+
+        f x = [(a, words $ drop 1 b) | a <- words a]
+            where (a,b) = break (== ':') $ takeWhile (/= '#') x
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/ghc-make.cabal b/ghc-make.cabal
new file mode 100644
--- /dev/null
+++ b/ghc-make.cabal
@@ -0,0 +1,30 @@
+cabal-version:      >= 1.8
+build-type:         Simple
+name:               ghc-make
+version:            0.1
+license:            BSD3
+license-file:       LICENSE
+category:           Development
+author:             Neil Mitchell <ndmitchell@gmail.com>
+maintainer:         Neil Mitchell <ndmitchell@gmail.com>
+copyright:          Neil Mitchell 2013
+synopsis:           Accelerated version of ghc --make
+description:
+    The @ghc-make@ program can be used as an alternative to @ghc --make@. When the build has some
+    work to do it will perform slower than @ghc --make@ alone. When there is no work to do, the build
+    will run faster, sometimes significantly so.
+    .
+    See the readme for full details <https://github.com/ndmitchell/ghc-make#readme>
+homepage:           https://github.com/ndmitchell/ghc-make#readme
+stability:          Beta
+
+source-repository head
+    type:     git
+    location: git://github.com/ndmitchell/ghc-make.git
+
+executable ghc-make
+    main-is: Main.hs
+    ghc-options: -threaded
+    build-depends:
+        base == 4.*,
+        shake == 0.10.*
