diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,7 +1,36 @@
 module Main where
 
 import Distribution.Simple
+import Distribution.Simple.Setup
+import Distribution.Simple.Utils       (rawSystemExit)
+import Distribution.PackageDescription
+import System.Directory                (doesFileExist, withCurrentDirectory)
+import Control.Monad                   (unless)
+import qualified Distribution.Verbosity as V
 
 
+type PreSDistHook = (Args -> SDistFlags -> IO HookedBuildInfo)
+
+
+updatePreSDistHook :: (PreSDistHook -> PreSDistHook) -> UserHooks -> UserHooks
+updatePreSDistHook update hooks@UserHooks{ preSDist = old }  = hooks { preSDist = update old }
+
+
+configureSQLCipher :: PreSDistHook -> PreSDistHook
+configureSQLCipher originalHook args flags@SDistFlags{ sDistVerbosity = verbosity } = do
+    withCurrentDirectory "sqlcipher" $
+        unlessFileExist "sqlite3.c" $ do
+            let verbosity' = fromFlagOrDefault V.normal verbosity
+            rawSystemExit verbosity' "./configure" 
+                [ "--disable-tcl"
+                , "--enable-tempstore"
+                , "CFLAGS=-DSQLITE_HAS_CODEC"
+                , "LDFLAGS=-lcrypto"]
+            rawSystemExit verbosity' "make" []
+    originalHook args flags
+  where 
+    unlessFileExist filePath action = doesFileExist filePath >>= flip unless action
+
+
 main :: IO ()
-main = defaultMainWithHooks autoconfUserHooks
+main = defaultMainWithHooks $ updatePreSDistHook configureSQLCipher autoconfUserHooks
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -17,12 +17,3 @@
       fi
 	  ;;
 esac
-
-# Generate sqlcipher/sqlite3.{c,h}
-(
-    set -e
-    cd sqlcipher
-    ./configure --disable-tcl --enable-tempstore=yes \
-                CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"
-    make
-)
diff --git a/sqlcipher.cabal b/sqlcipher.cabal
--- a/sqlcipher.cabal
+++ b/sqlcipher.cabal
@@ -1,5 +1,5 @@
 Name:            sqlcipher
-Version:         1.0.1.0
+Version:         1.0.1.1
 Synopsis:        Haskell binding to sqlcipher
 Description:
     Haskell binding to sqlcipher <https://www.zetetic.net/sqlcipher/>.
@@ -15,8 +15,8 @@
   Copyright (c) 2016, figo GmbH
 Homepage:        http://github.com/figome/haskell-sqlcipher
 Category:        Database
-cabal-version: >= 1.8
-build-type:      Configure
+cabal-version: >= 1.23
+build-type:      Custom
 
 -- Cheating here, including the tests/ .cabal +
 -- files in the parent (so as to dist them as one.)
@@ -32,9 +32,10 @@
   description: Compile sqlcipher as a part of the library.
 
 library
-  Build-depends:   base >= 3 && < 5, pretty, utf8-string, bytestring, time,
+  default-language: Haskell98
+  build-depends:   base >= 3 && < 5, pretty, utf8-string, bytestring, time,
                    directory
-  Extensions:      ForeignFunctionInterface, GeneralizedNewtypeDeriving,
+  default-extensions:      ForeignFunctionInterface, GeneralizedNewtypeDeriving,
                    TypeSynonymInstances, ScopedTypeVariables,
                    FlexibleInstances, UndecidableInstances, IncoherentInstances
   Ghc-options:     -Wall
@@ -57,6 +58,11 @@
     Database.SQLCipher.Types,
     Database.SQL
     Database.SQL.Types
+
+
+custom-setup
+  setup-depends:   base >= 3 && < 5, Cabal >= 1.23
+
 
 test-suite sqlite-tests
   Type:            exitcode-stdio-1.0
