git-annex/Makefile
Nathan Collins 7753b33c88 Refactor generation of git-annex.cabal and incorporate man pages.
The existing `sed | find | perl` hack in the Makefile was not
including the man pages in the generated git-annex.cabal.  I couldn't
figure out why it didn't work; running the `find | perl` part of the
command *did* list the man pages ...

So, I set up a new hack. It produces a cleaner .cabal file and
includes the man pages in the sdist.  I changed git-annex.cabal and
its generation as follows:

- git-annex.cabal is now generated by a here document in
  git-annex.cabal.template.sh.  The here document has inline file list
  insertion, whereas before the file lists were inserted with sed.

- The 'Extra-Source-Files:' field now only includes the non-source
  files: the man pages, plain text documentation, and license.

- The source dependencies are now listed in 'Other-Modules' sections
  in the 'Executable' and 'Test-Suite' sections.  The list of
  dependencies is generated by `gen-other-modules.sh`.

- The ./debian and ./doc are no longer included in the sdist package.
  These were not installed anywhere by `cabal install`.  A user that
  wants them could clone the git repo.

Running the tests with cabal is not yet working, i.e.

  cabal configure --enable-tests && cabal build && cabal test

and

  cabal install --enable-tests

fail to find Utility.Touch.  However, I did not break this: it doesn't
work for the git-annex package on Hackage either.  Next step is to
figure out how to deal with HSC in cabal ... or not bother, because
`make test` works.  I'm worried this is a cabal bug.

To test building from sdist, I've been running

  cd ../.. ; cabal sdist ; cd dist ; tar xf git-annex-3.20120605.tar.gz && cd git-annex-3.20120605 && rm -fr /tmp/git-annex && cabal install --prefix=/tmp/git-annex && tree -A /tmp/git-annex

in the dist directory.  Using `cabal-dev install` is a better test,
but is very slow.
2012-06-11 00:12:11 -07:00

120 lines
3.2 KiB
Makefile

PREFIX=/usr
IGNORE=-ignore-package monads-fd
BASEFLAGS=-Wall $(IGNORE) -outputdir tmp -IUtility -DWITH_S3
GHCFLAGS=-O2 $(BASEFLAGS)
ifdef PROFILE
GHCFLAGS=-prof -auto-all -rtsopts -caf-all -fforce-recomp $(BASEFLAGS)
endif
GHCMAKE=ghc $(GHCFLAGS) --make
bins=git-annex
mans=git-annex.1 git-annex-shell.1
sources=Build/SysConfig.hs Utility/Touch.hs
clibs=Utility/libdiskfree.o
all=$(bins) $(mans) docs
# Am I typing :make in vim? Do a fast build.
ifdef VIM
all=fast
endif
all: $(all)
sources: $(sources)
# Disables optimisation. Not for production use.
fast: GHCFLAGS=$(BASEFLAGS)
fast: $(bins)
Build/SysConfig.hs: configure.hs Build/TestConfig.hs Build/Configure.hs
$(GHCMAKE) configure
./configure
%.hs: %.hsc
hsc2hs $<
git-annex: $(sources) $(clibs)
$(GHCMAKE) $@ $(clibs)
git-annex.1: doc/git-annex.mdwn
./mdwn2man git-annex 1 doc/git-annex.mdwn > git-annex.1
git-annex-shell.1: doc/git-annex-shell.mdwn
./mdwn2man git-annex-shell 1 doc/git-annex-shell.mdwn > git-annex-shell.1
git-union-merge.1: doc/git-union-merge.mdwn
./mdwn2man git-union-merge 1 doc/git-union-merge.mdwn > git-union-merge.1
install-mans: $(mans)
install -d $(DESTDIR)$(PREFIX)/share/man/man1
install -m 0644 $(mans) $(DESTDIR)$(PREFIX)/share/man/man1
install-docs: docs install-mans
install -d $(DESTDIR)$(PREFIX)/share/doc/git-annex
if [ -d html ]; then \
rsync -a --delete html/ $(DESTDIR)$(PREFIX)/share/doc/git-annex/html/; \
fi
install: all install-docs
install -d $(DESTDIR)$(PREFIX)/bin
install $(bins) $(DESTDIR)$(PREFIX)/bin
ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-annex-shell
test: $(sources) $(clibs)
@if ! $(GHCMAKE) -O0 test $(clibs); then \
echo "** failed to build the test suite" >&2; \
exit 1; \
elif ! ./test; then \
echo "** test suite failed!" >&2; \
exit 1; \
fi
testcoverage:
rm -f test.tix test
ghc $(GHCFLAGS) -outputdir tmp/testcoverage --make -fhpc test
./test
@echo ""
@hpc report test --exclude=Main --exclude=QC
@hpc markup test --exclude=Main --exclude=QC --destdir=.hpc >/dev/null
@echo "(See .hpc/ for test coverage details.)"
# If ikiwiki is available, build static html docs suitable for being
# shipped in the software package.
ifeq ($(shell which ikiwiki),)
IKIWIKI=@echo "** ikiwiki not found, skipping building docs" >&2; true
else
IKIWIKI=ikiwiki
endif
docs: $(mans)
$(IKIWIKI) doc html -v --wikiname git-annex --plugin=goodstuff \
--no-usedirs --disable-plugin=openid --plugin=sidebar \
--underlaydir=/dev/null --disable-plugin=shortcut \
--disable-plugin=smiley \
--plugin=comments --set comments_pagespec="*" \
--exclude='news/.*'
clean:
rm -rf tmp $(bins) $(mans) test configure *.tix .hpc $(sources) \
doc/.ikiwiki html dist $(clibs) git-annex.cabal
# Workaround for cabal sdist not running Setup hooks, so I cannot
# generate a file list there.
sdist: clean $(mans)
# Could make this a .PHONY, but it needs to be rerun each time,
# unless we want to list a *lot* of dependencies.
./git-annex.cabal.template.sh > git-annex.cabal
# Complains about not running 'configure' first, but adding
#
# cabal configure
#
# does not help.
cabal sdist
# Upload to hackage.
hackage: sdist
@cabal upload dist/*.tar.gz
.PHONY: $(bins) test install