hledger/Makefile

259 lines
7.8 KiB
Makefile
Raw Normal View History

2009-01-25 12:00:57 +03:00
# hledger project makefile
2008-12-10 21:43:14 +03:00
2009-01-25 12:00:57 +03:00
# build the normal hledger binary
BUILD=ghc --make hledger.hs -o hledger -O
BUILDFLAGS=-DVTY -DANSI -DHAPPS
build: setbuildversion tag
$(BUILD) $(BUILDFLAGS)
2007-05-02 06:50:10 +04:00
2009-01-25 12:00:57 +03:00
# build the fastest binary we can, as hledgeropt
BUILDOPT=ghc --make hledger.hs -o hledgeropt -O2 -fvia-C
2009-01-26 23:27:41 +03:00
buildopt opt:
2009-01-25 12:00:57 +03:00
$(BUILDOPT)
# recompile and run tests (or another command) whenever a module changes
# see http://searchpath.org , you may need the patched version from
# http://joyful.com/repos/searchpath
CICMD=test
2008-11-08 23:25:22 +03:00
continuous ci:
sp --no-exts --no-default-map -o hledger ghc --make hledger.hs $(BUILDFLAGS) --run $(CICMD)
2009-01-26 23:27:41 +03:00
# force a full rebuild with normal optimisation
rebuild: clean build
2008-12-10 21:43:14 +03:00
# run code tests
test:
./hledger.hs test
PROFBIN=hledgerp
BUILDPROF=ghc --make hledger.hs -prof -auto-all -o $(PROFBIN)
RUNPROF=./$(PROFBIN) +RTS -p -RTS
PROFCMD=-s balance
TIME=`date +"%Y%m%d%H%M"`
2008-12-05 03:38:19 +03:00
profile:
@echo "Profiling $(PROFCMD)"
$(BUILDPROF)
$(RUNPROF) $(PROFCMD) >/dev/null
tools/simplifyprof.hs $(PROFBIN).prof >simple.prof
cp simple.prof profs/$(TIME).prof
2007-07-03 13:11:03 +04:00
cat simple.prof
2007-05-02 06:50:10 +04:00
# run performance benchmarks and save results in profs
2009-01-20 06:48:35 +03:00
# prepend ./ to these if not in $PATH
BENCHEXES=hledger ledger
bench: buildbench sampleledgers
2008-12-10 23:46:18 +03:00
./bench $(BENCHEXES) | tee profs/`date +%Y%m%d%H%M%S`.bench
2009-01-25 12:00:57 +03:00
# build the benchmarking tool
2008-12-10 23:46:18 +03:00
buildbench:
ghc --make tools/bench.hs
rm -f bench; ln -s tools/bench
2009-01-25 12:00:57 +03:00
# generate sample ledgers
sampleledgers:
ghc -e 'putStr $$ unlines $$ replicate 1000 "!include sample.ledger"' >sample1000.ledger
# ghc -e 'putStr $$ unlines $$ replicate 10000 "!include sample.ledger"' >sample10000.ledger
# ghc -e 'putStr $$ unlines $$ replicate 100000 "!include sample.ledger"' >sample10000.ledger
2009-01-25 11:09:09 +03:00
# send unpushed patches to the mail list
send:
darcs send http://joyful.com/repos/hledger --to=hledger@googlegroups.com --edit-description
2009-01-25 11:09:09 +03:00
# push patches to the main repo with ssh
push:
darcs push joyful.com:/repos/hledger
# version numbering, releasing etc.
#
# Places where hledger's version number makes an appearance:
# hledger --version
# the darcs release tag
# the cabal file
# the hackage pages and tarball filenames
#
# Goals and constraints for version numbering:
# 1 automation, robustness, simplicity, platform independence
# 2 cabal versions must be all-numeric
# 3 release versions should be concise
# 4 releases should have a corresponding darcs tag
# 5 development builds should have a precise version appearing in --version
# 6 development builds should generate cabal packages with non-confusing versions
# 7 would like a way to mark builds/releases as alpha or beta
# 8 would like to easily darcs get the .0 even with bugfix releases present
#
# Current plan:
# - Update the release version below, and record, before and/or after
# "make release".
# - The release version looks like major.minor[.bugfix]. bugfix is 0 (and
# elided) for a normal release, or 1..n for a bugfix release, or if
# desired may be set to 98 meaning an alpha for the forthcoming release
# or 99 meaning a beta. This is propagated during "make release".
# - The development build version is the non-elided release version plus
# the number of patches added since the last release, ie
# major.minor.bugfix.patches. This is propagated during "make".
# - The release tag is the non-elided release version.
RELEASE:=0.3.98
2009-01-25 11:09:09 +03:00
# build a cabal release, tag the repo and upload to hackage
# don't forget to first update and record RELEASE, if needed
release: check setreleaseversion tagrelease sdist #upload
ifeq ($(shell ghc -e "length (filter (=='.') \"$(RELEASE)\")"), 1)
RELEASE3:=$(RELEASE).0
else
RELEASE3:=$(RELEASE)
endif
# pre-release checks - cabal is happy, the code builds, tests pass..
check:
cabal check
cabal configure
cabal build
dist/build/hledger/hledger test 2>&1 | tail -1 | grep -q 'Errors: 0 Failures: 1'
# set the precise build version in local files, but don't record.
# This is used for development builds ("make").
setbuildversion:
(export BUILD=$(RELEASE3).`expr \`darcs changes --count --from-tag=.\` - 1` \
&& perl -p -e "s/(^version *= *)\".*?\"/\1\"$$BUILD\"/" -i Options.hs \
&& perl -p -e "s/(^Version: *) .*/\1 $$BUILD/" -i hledger.cabal \
)
# set the release version in local files (which should not have other
# pending edits!), and record.
setreleaseversion:
perl -p -e "s/(^version *= *)\".*?\"/\1\"$(RELEASE)\"/" -i Options.hs \
&& perl -p -e "s/(^Version: *) .*/\1 $(RELEASE)/" -i hledger.cabal \
&& darcs record -a -m "bump version" Options.hs hledger.cabal
tagrelease:
darcs tag $(RELEASE3)
sdist:
cabal sdist
upload:
cabal upload dist/hledger-$(RELEASE).tar.gz
2009-01-25 12:00:57 +03:00
# update emacs TAGS file
2008-10-18 08:34:41 +04:00
tag:
rm -f TAGS; hasktags -e *hs Ledger/*hs
clean:
rm -f {,Ledger/}*{.o,.hi,~} darcs-amend-record*
Clean: clean clean-docs
rm -f hledger TAGS tags
# docs
2008-11-24 00:49:04 +03:00
DOCS=README NEWS
2009-01-25 12:00:57 +03:00
# rebuild all docs
2008-11-09 01:41:20 +03:00
docs: html pdf api-doc-frames
2009-01-25 12:00:57 +03:00
# rebuild html docs
2008-11-09 01:41:20 +03:00
html:
2008-11-24 00:49:04 +03:00
for d in $(DOCS); do rst2html $$d >doc/$$d.html; done
2008-11-24 01:29:17 +03:00
cd doc; ln -f -s README.html index.html
2008-11-09 01:41:20 +03:00
2009-01-25 12:00:57 +03:00
# rebuild pdf docs
2008-11-09 01:41:20 +03:00
pdf:
2008-11-24 00:49:04 +03:00
for d in $(DOCS); do rst2pdf $$d -o doc/$$d.pdf; done
2008-11-09 01:41:20 +03:00
2009-01-25 12:00:57 +03:00
# rebuild api docs (haddock & hoogle)
api-docs: api-doc-frames
api-doc-dir:
mkdir -p api-doc
2008-10-03 11:40:28 +04:00
HSCOLOUR=HsColour -css
colourised-source hscolour: api-doc-dir
echo "Generating colourised source" ; \
2008-10-03 06:02:25 +04:00
for f in *hs Ledger/*hs; do \
2008-10-03 11:40:28 +04:00
$(HSCOLOUR) -anchor $$f -oapi-doc/`echo "src/"$$f | sed -e's%/%-%g' | sed -e's%\.hs$$%.html%'` ; \
done ; \
2008-10-01 14:18:07 +04:00
cp api-doc/src-hledger.html api-doc/src-Main.html ; \
HsColour -print-css >api-doc/hscolour.css
2009-01-25 12:00:57 +03:00
MAIN=hledger.hs
2008-10-03 11:40:28 +04:00
# nb --ignore-all-exports means these are actually implementation docs
HADDOCK=haddock -B `ghc --print-libdir` --no-warnings --ignore-all-exports
2009-01-25 12:00:57 +03:00
api-doc-with-source: api-doc-dir colourised-source $(MAIN)
2008-10-03 11:40:28 +04:00
echo "Generating haddock api docs" ; \
$(HADDOCK) -o api-doc -h --source-module=src-%{MODULE/./-}.html $(filter-out %api-doc-dir colourised-source,$^) ; \
cp api-doc/index.html api-doc/modules-index.html
#--source-entity=src-%{MODULE/./-}.html#%N
#generate a hoogle index
hoogleindex: $(MAIN)
echo "Generating hoogle index" ; \
mkdir -p hoogle && \
2008-10-03 11:40:28 +04:00
$(HADDOCK) -o hoogle --hoogle $^ && \
cd hoogle && \
hoogle --convert=main.txt --output=default.hoo
#set up the hoogle web interface
#uses a hoogle source tree configured with --datadir=., patched to fix haddock urls/target frame
HOOGLESRC=/usr/local/src/hoogle
HOOGLE=$(HOOGLESRC)/dist/build/hoogle/hoogle
HOOGLEVER=`$(HOOGLE) --version |tail -n 1 | sed -e 's/Version /hoogle-/'`
hoogleweb: hoogleindex
echo "Configuring hoogle web interface" ; \
if test -f $(HOOGLE) ; then \
mkdir -p hoogle && \
cd hoogle && \
rm -f $(HOOGLEVER) && \
ln -s . $(HOOGLEVER) && \
cp -r $(HOOGLESRC)/src/res/ . && \
cp -p $(HOOGLE) index.cgi && \
touch log.txt && chmod 666 log.txt ; \
else \
echo "Could not find $(HOOGLE) in the hoogle source tree" ; \
fi
2008-10-03 11:40:28 +04:00
# munge haddock and hoogle into a rough but useful framed layout
# ensure that the hoogle cgi is built with base target "main"
2008-11-09 01:41:20 +03:00
api-doc-frames: api-doc-with-source hoogleweb
2008-10-03 11:40:28 +04:00
echo "Converting api docs to frames" ; \
sed -i -e 's%^></HEAD%><base target="main"></HEAD%' api-doc/modules-index.html ; \
cp doc/misc/api-doc-frames.html api-doc/index.html ; \
cp doc/misc/hoogle-small.html hoogle
2009-01-25 12:00:57 +03:00
# build api docs and open them in a web browser, adjust to taste
2008-10-03 11:40:28 +04:00
BROWSER=open
2009-01-25 12:00:57 +03:00
test-docs: api-docs
2008-10-03 11:40:28 +04:00
$(BROWSER) api-doc/index.html
2008-12-10 21:43:14 +03:00
# $(BROWSER) doc/README.html
2008-10-03 11:40:28 +04:00
clean-docs:
rm -rf api-doc hoogle
2008-10-18 08:34:41 +04:00
# misc
2008-10-17 22:04:24 +04:00
show-changes:
@echo Changes since last release:
@echo
@darcs changes --from-tag . | grep '*'
2009-01-21 01:27:32 +03:00
show-unpushed:
@echo Changes not yet in the main hledger repo:
@echo
@darcs push joyful.com:/repos/hledger --dry-run
show-authors:
@echo Patch authors since last release:
@echo
@darcs changes --from-tag . |grep '^\w' |cut -c 31- |sort |uniq
2009-01-25 12:00:57 +03:00
# count lines of code
2008-10-18 08:34:41 +04:00
sloc:
2008-11-24 00:50:47 +03:00
@echo "test code:"
2008-10-18 08:34:41 +04:00
@sloccount Tests.hs | grep haskell:
2008-11-24 00:50:47 +03:00
@echo "non-test code:"
2008-10-18 08:34:41 +04:00
@sloccount `ls {,Ledger/}*.hs |grep -v Tests.hs` | grep haskell:
2008-10-03 11:40:28 +04:00