diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE TemplateHaskell #-}
 import Distribution.Simple
 import Distribution.Simple.LocalBuildInfo
 import Distribution.Simple.Setup
@@ -9,6 +10,7 @@
 import System.Directory
 import System.FilePath
 import System.Exit
+import Language.Haskell.TH (appE, varE, mkName, conE)
 
 main = defaultMainWithHooks hk
  where
@@ -32,7 +34,11 @@
 
 canUseRDRAND :: FilePath -> IO Bool
 canUseRDRAND cc = do
-        withTempDirectory normal "" "testRDRAND" $ \tmpDir -> do
+        -- Template haskell to call withTempDirectory in a backward compatible way
+        -- withTempDirectory normal False "" "testRDRAND" $ \tmpDir -> do 
+        $(if cabalVersion >= Version [1,17,0] []
+            then  appE (appE (varE $ mkName "withTempDirectory") (varE 'normal)) (conE (mkName "False"))
+            else  appE (varE $ mkName "withTempDirectory") (varE 'normal)) "" "testRDRAND" $ \tmpDir -> do
         writeFile (tmpDir ++ "/testRDRAND.c")
                 (unlines        [ "#include <stdint.h>"
                                 , "int main() {"
diff --git a/entropy.cabal b/entropy.cabal
--- a/entropy.cabal
+++ b/entropy.cabal
@@ -1,5 +1,5 @@
 name:           entropy
-version:        0.2.2
+version:        0.2.2.1
 license:        BSD3
 license-file:   LICENSE
 copyright:      Thomas DuBuisson <thomas.dubuisson@gmail.com>
