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.
This commit is contained in:
Joey Hess 2010-11-18 13:30:42 -04:00
parent 5c7d1b0279
commit 54513c69ba
4 changed files with 89 additions and 2 deletions

2
.gitignore vendored
View file

@ -1,5 +1,7 @@
build/* build/*
test test
configure
SysConfig.hs
git-annex git-annex
git-annex.1 git-annex.1
doc/.ikiwiki doc/.ikiwiki

View file

@ -2,7 +2,11 @@ all: git-annex docs
ghcmake=ghc -Wall -odir build -hidir build -O2 --make ghcmake=ghc -Wall -odir build -hidir build -O2 --make
git-annex: SysConfig.hs:
$(ghcmake) configure
./configure
git-annex: SysConfig.hs
$(ghcmake) git-annex $(ghcmake) git-annex
install: install:
@ -29,7 +33,7 @@ docs:
--disable-plugin=smiley --disable-plugin=smiley
clean: 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 rm -rf doc/.ikiwiki html
.PHONY: git-annex test install .PHONY: git-annex test install

78
configure.hs Normal file
View file

@ -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

3
debian/changelog vendored
View file

@ -1,6 +1,9 @@
git-annex (0.08) UNRELEASED; urgency=low git-annex (0.08) UNRELEASED; urgency=low
* Fix `git annex add ../foo` (when ran in a subdir of the repo). * 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 -- Joey Hess <joeyh@debian.org> Wed, 17 Nov 2010 13:54:49 -0400