summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-18 13:30:42 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-18 13:30:42 -0400
commit54513c69baffa40f2fcce42eb8651fdd98e05277 (patch)
treef3934b369e7b5b259b88abeee228381fb2bcd6e0
parent5c7d1b027916ce3fc207329f926041d2bcad3bcd (diff)
Add configure step to build process.
* configure: Check to see if cp -a can be used. * configure: Check to see if cp --reflink=auto can be used.
-rw-r--r--.gitignore2
-rw-r--r--Makefile8
-rw-r--r--configure.hs78
-rw-r--r--debian/changelog3
4 files changed, 89 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 6956c49dd..a4cac10f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
build/*
test
+configure
+SysConfig.hs
git-annex
git-annex.1
doc/.ikiwiki
diff --git a/Makefile b/Makefile
index 77e7a5edb..685044146 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,11 @@ all: git-annex docs
ghcmake=ghc -Wall -odir build -hidir build -O2 --make
-git-annex:
+SysConfig.hs:
+ $(ghcmake) configure
+ ./configure
+
+git-annex: SysConfig.hs
$(ghcmake) git-annex
install:
@@ -29,7 +33,7 @@ docs:
--disable-plugin=smiley
clean:
- rm -rf build git-annex git-annex.1 test
+ rm -rf build git-annex git-annex.1 test configure SysConfig.hs
rm -rf doc/.ikiwiki html
.PHONY: git-annex test install
diff --git a/configure.hs b/configure.hs
new file mode 100644
index 000000000..fa07be3ab
--- /dev/null
+++ b/configure.hs
@@ -0,0 +1,78 @@
+{- Checks system configuration and generates SysConfig.hs.
+ -}
+
+import System.IO
+import System.Cmd
+import System.Exit
+import System.Directory
+
+type Test = IO Bool
+data TestDesc = TestDesc String String Test
+data Config = Config String Bool
+
+tests :: [TestDesc]
+tests = [
+ TestDesc "cp -a" "cp_a" cp_a
+ , TestDesc "cp --reflink" "cp_reflink" cp_reflink
+ ]
+
+tmpDir :: String
+tmpDir = "tmp"
+
+testFile :: String
+testFile = tmpDir ++ "/testfile"
+
+quiet :: String -> String
+quiet s = s ++ " 2>/dev/null"
+
+cp_a :: Test
+cp_a = testCmd $ quiet $ "cp -a " ++ testFile ++ " " ++ testFile ++ ".new"
+
+cp_reflink :: Test
+cp_reflink = testCmd $ quiet $ "cp --reflink=auto " ++ testFile ++ " " ++ testFile ++ ".new"
+
+testCmd :: String -> Test
+testCmd c = do
+ ret <- system c
+ return $ ret == ExitSuccess
+
+testStart :: String -> IO ()
+testStart s = do
+ putStr $ " checking " ++ s ++ "..."
+ hFlush stdout
+
+testEnd :: Bool -> IO ()
+testEnd r = putStrLn $ " " ++ (show r)
+
+writeSysConfig :: [Config] -> IO ()
+writeSysConfig config = do
+ writeFile "SysConfig.hs" $ unlines $ header ++ vars config ++ footer
+ where
+ header = [
+ "{- Automatically generated by configure. -}"
+ , "module SysConfig where"
+ ]
+ footer = []
+ vars [] = []
+ vars (c:cs) = showvar c ++ vars cs
+ showvar (Config name val) = [
+ name ++ " :: Bool"
+ , name ++ " = " ++ show val
+ ]
+
+runTests :: [TestDesc] -> IO [Config]
+runTests [] = return []
+runTests ((TestDesc tname key t):ts) = do
+ testStart tname
+ val <- t
+ testEnd val
+ rest <- runTests ts
+ return $ (Config key val):rest
+
+main :: IO ()
+main = do
+ createDirectoryIfMissing True tmpDir
+ writeFile testFile "test file contents"
+ config <- runTests tests
+ removeDirectoryRecursive tmpDir
+ writeSysConfig config
diff --git a/debian/changelog b/debian/changelog
index 2a8871c30..e6549c1f0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,9 @@
git-annex (0.08) UNRELEASED; urgency=low
* Fix `git annex add ../foo` (when ran in a subdir of the repo).
+ * Add configure step to build process.
+ * configure: Check to see if cp -a can be used.
+ * configure: Check to see if cp --reflink=auto can be used.
-- Joey Hess <joeyh@debian.org> Wed, 17 Nov 2010 13:54:49 -0400