Makefile now builds using cabal, taking advantage of cabal's automatic detection of appropriate build flags.

The only thing lost is ./ghci

Speed: make fast used to take 20 seconds here, when rebuilding from
touching Command/Unused.hs. With cabal, it's 29 seconds.
This commit is contained in:
Joey Hess 2013-02-27 02:39:22 -04:00
parent 32aee1bb3e
commit cbd53b4a8c
18 changed files with 56 additions and 141 deletions

4
.gitignore vendored
View file

@ -1,6 +1,5 @@
tmp tmp
test test
configure
build-stamp build-stamp
Build/SysConfig.hs Build/SysConfig.hs
git-annex git-annex
@ -11,9 +10,6 @@ doc/.ikiwiki
html html
*.tix *.tix
.hpc .hpc
Utility/Touch.hs
Utility/Mounts.hs
Utility/*.o
dist dist
# Sandboxed builds # Sandboxed builds
cabal-dev cabal-dev

View file

@ -287,7 +287,7 @@ withIndex' :: Bool -> Annex a -> Annex a
withIndex' bootstrapping a = do withIndex' bootstrapping a = do
f <- fromRepo gitAnnexIndex f <- fromRepo gitAnnexIndex
g <- gitRepo g <- gitRepo
#ifdef WITH_ANDROID #ifdef __ANDROID__
{- Work around for weird getEnvironment breakage on Android. See {- Work around for weird getEnvironment breakage on Android. See
- https://github.com/neurocyte/ghc-android/issues/7 - https://github.com/neurocyte/ghc-android/issues/7
- Instead, use getEnv to get some key environment variables that - Instead, use getEnv to get some key environment variables that

View file

@ -75,7 +75,7 @@ data PairingInProgress = PairingInProgress
data SomeAddr = IPv4Addr HostAddress data SomeAddr = IPv4Addr HostAddress
{- My Android build of the Network library does not currently have IPV6 {- My Android build of the Network library does not currently have IPV6
- support. -} - support. -}
#ifndef WITH_ANDROID #ifndef __ANDROID__
| IPv6Addr HostAddress6 | IPv6Addr HostAddress6
#endif #endif
deriving (Ord, Eq, Read, Show) deriving (Ord, Eq, Read, Show)

View file

@ -15,9 +15,6 @@ import Git.Remote
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as T import qualified Data.Text as T
import qualified Control.Exception as E
import System.Process (CreateProcess(..))
import Control.Concurrent
import Data.Char import Data.Char
data SshData = SshData data SshData = SshData

View file

@ -7,6 +7,12 @@
{-# LANGUAGE CPP, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-} {-# LANGUAGE CPP, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}
#if defined VERSION_yesod_form
#if ! MIN_VERSION_yesod_form(1,2,0)
#define WITH_OLD_YESOD
#endif
#endif
module Assistant.WebApp.Configurators.Local where module Assistant.WebApp.Configurators.Local where
import Assistant.WebApp.Common import Assistant.WebApp.Common

View file

@ -7,6 +7,12 @@
{-# LANGUAGE CPP, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-} {-# LANGUAGE CPP, TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings, RankNTypes #-}
#if defined VERSION_yesod_default
#if ! MIN_VERSION_yesod_default(1,1,0)
#define WITH_OLD_YESOD
#endif
#endif
module Assistant.WebApp.Notifications where module Assistant.WebApp.Notifications where
import Assistant.Common import Assistant.Common

View file

@ -21,7 +21,7 @@ import Annex.Perms
import Annex.Link import Annex.Link
import qualified Annex import qualified Annex
import qualified Annex.Queue import qualified Annex.Queue
#ifndef WITH_ANDROID #ifndef __ANDROID__
import Utility.Touch import Utility.Touch
#endif #endif
import Utility.FileMode import Utility.FileMode
@ -166,7 +166,7 @@ link file key hascontent = handle (undo file key) $ do
l <- calcGitLink file key l <- calcGitLink file key
makeAnnexLink l file makeAnnexLink l file
#ifndef WITH_ANDROID #ifndef __ANDROID__
when hascontent $ do when hascontent $ do
-- touch the symlink to have the same mtime as the -- touch the symlink to have the same mtime as the
-- file it points to -- file it points to

129
Makefile
View file

@ -1,91 +1,24 @@
CFLAGS=-Wall
GIT_ANNEX_TMP_BUILD_DIR?=tmp
BASEFLAGS=-Wall -outputdir $(GIT_ANNEX_TMP_BUILD_DIR) -IUtility
# If you get build failures due to missing haskell libraries,
# you can turn off some of these features.
#
# If you're using an old version of yesod, enable -DWITH_OLD_YESOD
FEATURES?=$(GIT_ANNEX_LOCAL_FEATURES) -DWITH_ASSISTANT -DWITH_S3 -DWITH_WEBDAV -DWITH_WEBAPP -DWITH_PAIRING -DWITH_XMPP -DWITH_DNS -DWITH_OLD_HTTP_CONDUIT
bins=git-annex
mans=git-annex.1 git-annex-shell.1 mans=git-annex.1 git-annex-shell.1
sources=Build/SysConfig.hs Utility/Touch.hs Utility/Mounts.hs all=git-annex $(mans) docs
all=$(bins) $(mans) docs
OS?=$(shell uname | sed 's/[-_].*//')
ifeq ($(OS),Android)
OPTFLAGS?=-DWITH_INOTIFY -DWITH_ANDROID
clibs=Utility/libdiskfree.o Utility/libmounts.o
CFLAGS:=-Wall -DWITH_ANDROID
THREADFLAGS=-threaded
else
ifeq ($(OS),Linux)
OPTFLAGS?=-DWITH_INOTIFY -DWITH_DBUS
clibs=Utility/libdiskfree.o Utility/libmounts.o
THREADFLAGS=$(shell if test -e `ghc --print-libdir`/libHSrts_thr.a; then printf -- -threaded; fi)
else
ifeq ($(OS),SunOS)
# Solaris is not supported by the assistant or watch command.
FEATURES:=$(shell echo $(FEATURES) | sed -e 's/-DWITH_ASSISTANT//' -e 's/-DWITH_WEBAPP//')
else
# BSD system
THREADFLAGS=-threaded
ifeq ($(OS),Darwin)
# use fsevents for OSX
OPTFLAGS?=-DWITH_FSEVENTS
clibs=Utility/libdiskfree.o Utility/libmounts.o
# Ensure OSX compiler builds for 32 bit when using 32 bit ghc
GHCARCH:=$(shell ghc -e 'print System.Info.arch')
ifeq ($(GHCARCH),i386)
CFLAGS=-Wall -m32
endif
else
# BSD system with kqueue
OPTFLAGS?=-DWITH_KQUEUE
clibs=Utility/libdiskfree.o Utility/libmounts.o Utility/libkqueue.o
endif
endif
endif
endif
ALLFLAGS = $(BASEFLAGS) $(FEATURES) $(OPTFLAGS) $(THREADFLAGS)
PREFIX=/usr
GHCFLAGS=-O2 $(ALLFLAGS)
ifdef PROFILE
GHCFLAGS=-prof -auto-all -rtsopts -caf-all -fforce-recomp $(ALLFLAGS)
endif
GHC?=ghc GHC?=ghc
GHCMAKE=$(GHC) $(GHCFLAGS) --make GHCMAKE=$(GHC) $(GHCFLAGS) --make
PREFIX=/usr
# Am I typing :make in vim? Do a fast build.
ifdef VIM
all=fast
endif
build: $(all) build: $(all)
touch build-stamp
sources: $(sources) fast:
@if [ ! -e dist/setup-config ] || grep -- -O2 dist/setup-config; then \
# Disables optimisation. Not for production use. cabal configure -f-Production; \
fast: GHCFLAGS=$(ALLFLAGS) fi
fast: $(bins) $(MAKE) git-annex
Build/SysConfig.hs: configure.hs Build/TestConfig.hs Build/Configure.hs Build/SysConfig.hs: configure.hs Build/TestConfig.hs Build/Configure.hs
$(GHCMAKE) configure cabal configure
./configure $(OS)
%.hs: %.hsc git-annex: Build/SysConfig.hs
hsc2hs $< cabal build
ln -sf dist/build/git-annex/git-annex git-annex
git-annex: $(sources) $(clibs)
install -d $(GIT_ANNEX_TMP_BUILD_DIR)
$(GHCMAKE) $@ -o $(GIT_ANNEX_TMP_BUILD_DIR)/git-annex $(clibs)
ln -sf $(GIT_ANNEX_TMP_BUILD_DIR)/git-annex git-annex
git-annex.1: doc/git-annex.mdwn git-annex.1: doc/git-annex.mdwn
./Build/mdwn2man git-annex 1 doc/git-annex.mdwn > git-annex.1 ./Build/mdwn2man git-annex 1 doc/git-annex.mdwn > git-annex.1
@ -121,7 +54,7 @@ test: $(sources) $(clibs)
testcoverage: testcoverage:
rm -f test.tix test rm -f test.tix test
$(GHC) $(GHCFLAGS) -outputdir $(GIT_ANNEX_TMP_BUILD_DIR)/testcoverage --make -fhpc test $(GHC) $(GHCFLAGS) -outputdir tmp/testcoverage --make -fhpc test
./test ./test
@echo "" @echo ""
@hpc report test --exclude=Main --exclude=QC @hpc report test --exclude=Main --exclude=QC
@ -150,8 +83,8 @@ docs: $(mans)
--exclude='bugs/*' --exclude='todo/*' --exclude='forum/*' --exclude='bugs/*' --exclude='todo/*' --exclude='forum/*'
clean: clean:
rm -rf $(GIT_ANNEX_TMP_BUILD_DIR) $(bins) $(mans) test configure *.tix .hpc $(sources) \ rm -rf tmp dist git-annex $(mans) test configure *.tix .hpc \
doc/.ikiwiki html dist $(clibs) build-stamp tags doc/.ikiwiki html dist build-stamp tags Build/SysConfig.hs
sdist: clean $(mans) sdist: clean $(mans)
./Build/make-sdist.sh ./Build/make-sdist.sh
@ -160,7 +93,7 @@ sdist: clean $(mans)
hackage: sdist hackage: sdist
@cabal upload dist/*.tar.gz @cabal upload dist/*.tar.gz
LINUXSTANDALONE_DEST=$(GIT_ANNEX_TMP_BUILD_DIR)/git-annex.linux LINUXSTANDALONE_DEST=tmp/git-annex.linux
linuxstandalone: linuxstandalone:
$(MAKE) git-annex $(MAKE) git-annex
@ -194,15 +127,15 @@ linuxstandalone:
sort "$(LINUXSTANDALONE_DEST)/libdirs.tmp" | uniq > "$(LINUXSTANDALONE_DEST)/libdirs" sort "$(LINUXSTANDALONE_DEST)/libdirs.tmp" | uniq > "$(LINUXSTANDALONE_DEST)/libdirs"
rm -f "$(LINUXSTANDALONE_DEST)/libdirs.tmp" rm -f "$(LINUXSTANDALONE_DEST)/libdirs.tmp"
cd $(GIT_ANNEX_TMP_BUILD_DIR) && tar czf git-annex-standalone-$(shell dpkg --print-architecture).tar.gz git-annex.linux cd tmp && tar czf git-annex-standalone-$(shell dpkg --print-architecture).tar.gz git-annex.linux
OSXAPP_DEST=$(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg/git-annex.app OSXAPP_DEST=tmp/build-dmg/git-annex.app
OSXAPP_BASE=$(OSXAPP_DEST)/Contents/MacOS OSXAPP_BASE=$(OSXAPP_DEST)/Contents/MacOS
osxapp: osxapp:
$(MAKE) git-annex $(MAKE) git-annex
rm -rf "$(OSXAPP_DEST)" rm -rf "$(OSXAPP_DEST)"
install -d $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg install -d tmp/build-dmg
cp -R standalone/osx/git-annex.app "$(OSXAPP_DEST)" cp -R standalone/osx/git-annex.app "$(OSXAPP_DEST)"
install -d "$(OSXAPP_BASE)" install -d "$(OSXAPP_BASE)"
@ -210,7 +143,7 @@ osxapp:
strip "$(OSXAPP_BASE)/git-annex" strip "$(OSXAPP_BASE)/git-annex"
ln -sf git-annex "$(OSXAPP_BASE)/git-annex-shell" ln -sf git-annex "$(OSXAPP_BASE)/git-annex-shell"
gzcat standalone/licences.gz > $(OSXAPP_BASE)/LICENSE gzcat standalone/licences.gz > $(OSXAPP_BASE)/LICENSE
cp $(OSXAPP_BASE)/LICENSE $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg/LICENSE.txt cp $(OSXAPP_BASE)/LICENSE tmp/build-dmg/LICENSE.txt
runghc Build/Standalone.hs $(OSXAPP_BASE) runghc Build/Standalone.hs $(OSXAPP_BASE)
@ -219,32 +152,20 @@ osxapp:
runghc Build/OSXMkLibs.hs $(OSXAPP_BASE) runghc Build/OSXMkLibs.hs $(OSXAPP_BASE)
rm -f tmp/git-annex.dmg rm -f tmp/git-annex.dmg
hdiutil create -size 640m -format UDRW -srcfolder $(GIT_ANNEX_TMP_BUILD_DIR)/build-dmg \ hdiutil create -size 640m -format UDRW -srcfolder tmp/build-dmg \
-volname git-annex -o tmp/git-annex.dmg -volname git-annex -o tmp/git-annex.dmg
rm -f tmp/git-annex.dmg.bz2 rm -f tmp/git-annex.dmg.bz2
bzip2 --fast tmp/git-annex.dmg bzip2 --fast tmp/git-annex.dmg
# Cross compile for Android binary. # Cross compile for Android.
# Uses https://github.com/neurocyte/ghc-android # Uses https://github.com/neurocyte/ghc-android
#
# configure is run, probing the local system.
# So the Android should have all the same stuff that configure probes for,
# including the same version of git.
android: android:
OS=Android $(MAKE) Build/SysConfig.hs $$HOME/.ghc/android-14/arm-linux-androideabi-4.7/arm-linux-androideabi/bin/cabal configure -f'Android Assistant DNS'
GHC=$$HOME/.ghc/android-14/arm-linux-androideabi-4.7/bin/arm-unknown-linux-androideabi-ghc \ $(MAKE) git-annex
CC=$$HOME/.ghc/android-14/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc \
FEATURES="-DWITH_ANDROID -DWITH_ASSISTANT -DWITH_DNS" \
OS=Android $(MAKE) fast
ANDROIDAPP_DEST=$(GIT_ANNEX_TMP_BUILD_DIR)/git-annex.android
androidapp: androidapp:
$(MAKE) android $(MAKE) android
$(MAKE) -C standalone/android $(MAKE) -C standalone/android
cp standalone/android/source/term/bin/Term-debug.apk $(GIT_ANNEX_TMP_BUILD_DIR)/git-annex.apk cp standalone/android/source/term/bin/Term-debug.apk tmp/git-annex.apk
# used by ./ghci .PHONY: git-annex test install tags
getflags:
@echo $(ALLFLAGS) $(clibs)
.PHONY: $(bins) test install tags

View file

@ -56,7 +56,7 @@ query opts =
type LsofParser = String -> [(FilePath, LsofOpenMode, ProcessInfo)] type LsofParser = String -> [(FilePath, LsofOpenMode, ProcessInfo)]
parse :: LsofParser parse :: LsofParser
#ifdef WITH_ANDROID #ifdef __ANDROID__
parse = parseDefault parse = parseDefault
#else #else
parse = parseFormatted parse = parseFormatted

View file

@ -31,14 +31,12 @@ import Data.Maybe
import ADNS.Resolver import ADNS.Resolver
import Data.Either import Data.Either
#else #else
#ifndef WITH_HOST
#ifdef WITH_DNS #ifdef WITH_DNS
import qualified Network.DNS.Lookup as DNS import qualified Network.DNS.Lookup as DNS
import Network.DNS.Resolver import Network.DNS.Resolver
import qualified Data.ByteString.UTF8 as B8 import qualified Data.ByteString.UTF8 as B8
#endif #endif
#endif #endif
#endif
newtype SRV = SRV String newtype SRV = SRV String
deriving (Show, Eq) deriving (Show, Eq)
@ -64,9 +62,6 @@ lookupSRV (SRV srv) = initResolver [] $ \resolver -> do
resolveSRV resolver srv resolveSRV resolver srv
return $ either (\_ -> []) id r return $ either (\_ -> []) id r
#else #else
#ifdef WITH_HOST
lookupSRV = lookupSRVHost
#else
#ifdef WITH_DNS #ifdef WITH_DNS
lookupSRV (SRV srv) = do lookupSRV (SRV srv) = do
seed <- makeResolvSeed defaultResolvConf seed <- makeResolvSeed defaultResolvConf
@ -83,7 +78,6 @@ lookupSRV (SRV srv) = do
lookupSRV = lookupSRVHost lookupSRV = lookupSRVHost
#endif #endif
#endif #endif
#endif
lookupSRVHost :: SRV -> IO [HostPort] lookupSRVHost :: SRV -> IO [HostPort]
lookupSRVHost (SRV srv) = catchDefaultIO [] $ lookupSRVHost (SRV srv) = catchDefaultIO [] $

View file

@ -10,7 +10,7 @@
module Utility.Shell where module Utility.Shell where
shellPath :: FilePath shellPath :: FilePath
#ifndef WITH_ANDROID #ifndef __ANDROID__
shellPath = "/bin/sh" shellPath = "/bin/sh"
#else #else
shellPath = "/system/bin/sh" shellPath = "/system/bin/sh"

View file

@ -14,7 +14,7 @@ import Common
import Control.Concurrent import Control.Concurrent
import System.Posix.Signals import System.Posix.Signals
#ifndef WITH_ANDROID #ifndef __ANDROID__
import System.Posix.Terminal import System.Posix.Terminal
#endif #endif
@ -53,7 +53,7 @@ waitForTermination :: IO ()
waitForTermination = do waitForTermination = do
lock <- newEmptyMVar lock <- newEmptyMVar
check softwareTermination lock check softwareTermination lock
#ifndef WITH_ANDROID #ifndef __ANDROID__
whenM (queryTerminal stdInput) $ whenM (queryTerminal stdInput) $
check keyboardSignal lock check keyboardSignal lock
#endif #endif

View file

@ -28,7 +28,7 @@ myUserName :: IO String
myUserName = myVal ["USER", "LOGNAME"] userName myUserName = myVal ["USER", "LOGNAME"] userName
myUserGecos :: IO String myUserGecos :: IO String
#ifdef WITH_ANDROID #ifdef __ANDROID__
myUserGecos = return "" -- userGecos crashes on Android myUserGecos = return "" -- userGecos crashes on Android
#else #else
myUserGecos = myVal [] userGecos myUserGecos = myVal [] userGecos

View file

@ -7,6 +7,12 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
#if defined VERSION_yesod_default
#if ! MIN_VERSION_yesod_default(1,1,0)
#define WITH_OLD_YESOD
#endif
#endif
module Utility.Yesod where module Utility.Yesod where
import Yesod.Default.Util import Yesod.Default.Util

View file

@ -22,7 +22,7 @@
# define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */ # define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */
# define STATSTRUCT statfs # define STATSTRUCT statfs
#else #else
#if defined WITH_ANDROID #if defined __ANDROID__
# warning free space checking code not available for Android # warning free space checking code not available for Android
# define UNKNOWN # define UNKNOWN
#else #else

View file

@ -5,7 +5,7 @@
# include <sys/mount.h> # include <sys/mount.h>
# define GETMNTINFO # define GETMNTINFO
#else #else
#if defined WITH_ANDROID #if defined __ANDROID__
# warning mounts listing code not available for Android # warning mounts listing code not available for Android
# define UNKNOWN # define UNKNOWN
#else #else

2
debian/changelog vendored
View file

@ -22,6 +22,8 @@ git-annex (4.20130217) UNRELEASED; urgency=low
the Glob library. the Glob library.
* copy: Update location log when no copy was performed, if the location * copy: Update location log when no copy was performed, if the location
log was out of date. log was out of date.
* Makefile now builds using cabal, taking advantage of cabal's automatic
detection of appropriate build flags.
-- Joey Hess <joeyh@debian.org> Sun, 17 Feb 2013 16:42:16 -0400 -- Joey Hess <joeyh@debian.org> Sun, 17 Feb 2013 16:42:16 -0400

13
debian/rules vendored
View file

@ -1,21 +1,8 @@
#!/usr/bin/make -f #!/usr/bin/make -f
ifeq (install ok installed,$(shell dpkg-query -W -f '$${Status}' libghc-yesod-dev 2>/dev/null))
export FEATURES=-DWITH_ASSISTANT -DWITH_S3 -DWITH_HOST -DWITH_PAIRING -DWITH_XMPP -DWITH_OLD_HTTP_CONDUIT -DWITH_WEBAPP -DWITH_OLD_YESOD
else
export FEATURES=-DWITH_ASSISTANT -DWITH_S3 -DWITH_HOST -DWITH_PAIRING -DWITH_XMPP -DWITH_OLD_HTTP_CONDUIT
endif
ifeq (install ok installed,$(shell dpkg-query -W -f '$${Status}' libghc-dav-dev 2>/dev/null))
export FEATURES:=${FEATURES} -DWITH_WEBDAV
endif
%: %:
dh $@ dh $@
# Builds standalone tarball with the same FEATURES as debian package.
standalone:
$(MAKE) linuxstandalone
# Not intended for use by anyone except the author. # Not intended for use by anyone except the author.
announcedir: announcedir:
@echo ${HOME}/src/git-annex/doc/news @echo ${HOME}/src/git-annex/doc/news