Add test infrastructure and initial tests
[ganeti-local] / Makefile
1 HPROGS = hbal hn1 hscan hail test
2 HSRCS := $(wildcard Ganeti/HTools/*.hs)
3 HDDIR = apidoc
4
5 DOCS = README.html NEWS.html
6
7 HFLAGS = -O2 -W -fwarn-monomorphism-restriction -fwarn-tabs
8 HEXTRA =
9
10 HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC
11
12 # Haskell rules
13
14 all: $(HPROGS)
15
16 $(HPROGS): %: %.hs Ganeti/HTools/Version.hs $(HSRCS) Makefile
17         ghc --make $(HFLAGS) $(HEXTRA) $@
18
19 $(DOCS) : %.html : %
20         rst2html $< $@
21
22 doc: $(DOCS)
23         rm -rf $(HDDIR)
24         mkdir -p $(HDDIR)/Ganeti/HTools
25         cp hscolour.css $(HDDIR)/Ganeti/HTools
26         for file in $(HSRCS); do \
27                 HsColour -css -anchor \
28                 $$file > $(HDDIR)/Ganeti/HTools/`basename $$file .hs`.html ; \
29         done
30         haddock --odir $(HDDIR) --html --ignore-all-exports \
31                 -t htools -p haddock-prologue \
32                 --source-module="%{MODULE/.//}.html" \
33                 --source-entity="%{MODULE/.//}.html#%{NAME}" \
34                 $(HSRCS)
35
36 maintainer-clean:
37         rm -rf $(HDDIR)
38         rm -f $(DOCS) TAGS version Ganeti/HTools/Version.hs
39
40 clean:
41         rm -f $(HPROGS)
42         rm -f *.o *.prof *.ps *.stat *.aux *.hi
43         cd Ganeti/HTools && rm -f *.o *.prof *.ps *.stat *.aux *.hi
44
45 version:
46         git describe > $@
47
48 Ganeti/HTools/Version.hs: Ganeti/HTools/Version.hs.in version
49         sed -e "s/%ver%/$$(cat version)/" < $< > $@
50
51 dist: Ganeti/HTools/Version.hs version doc
52         VN=$$(cat version|sed 's/^v//') ; \
53         ANAME="htools-$$VN.tar" ; \
54         rm -f $$ANAME $$ANAME.gz ; \
55         git archive --format=tar --prefix=htools-$$VN/ HEAD > $$ANAME ; \
56         tar -r -f $$ANAME --owner root --group root \
57             --transform="s,^,htools-$$VN/," version apidoc $(DOCS) ; \
58         gzip -v9 $$ANAME ; \
59         tar tzvf $$ANAME.gz
60
61 check:
62         rm -f *.tix *.mix test
63         $(MAKE) HEXTRA=-fhpc test
64         ./test
65 ifeq ($(T),markup)
66         mkdir -p coverage
67         hpc markup --destdir=coverage test $(HPCEXCL)
68 else
69         hpc report test $(HPCEXCL)
70 endif
71
72 .PHONY : all doc maintainer-clean clean dist check