Fix broken hscolour.css symlink in tarball
[ganeti-local] / Makefile
1 HPROGS = hbal hscan hail hspace
2 MANS = $(HPROGS:%=man/%.1)
3 MANHTML = $(HPROGS:%=man/%.html)
4 HALLPROGS = $(HPROGS) test
5 HSRCS := $(wildcard Ganeti/HTools/*.hs) $(wildcard Ganeti/*.hs)
6 HDDIR = apidoc
7 GHC := ghc
8
9 DOCS = README.html NEWS.html
10
11 HFLAGS = -O2 -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs
12 HEXTRA =
13
14 HPCEXCL = --exclude Main --exclude Ganeti.HTools.QC
15
16 # Haskell rules
17
18 all: $(HPROGS) man
19
20 man: $(MANS) $(MANHTML)
21
22
23 $(HALLPROGS): %: %.hs Ganeti/HTools/Version.hs $(HSRCS) Makefile
24         $(GHC) --make $(HFLAGS) $(HEXTRA) $@
25
26 test live-test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
27         -fno-warn-monomorphism-restriction -fno-warn-orphans \
28         -fno-warn-missing-methods -fno-warn-unused-imports
29
30 $(DOCS) : %.html : %
31         LANG=en_US.UTF-8 pandoc -f rst -t html -o $@ $<
32
33 %.1: %.rst
34         LANG=en_US.UTF-8 pandoc -s -f rst -t man -o $@ $<
35
36 %.html: %.rst
37         LANG=en_US.UTF-8 pandoc -s -f rst -t html -o $@ $<
38
39 doc: $(DOCS) Ganeti/HTools/Version.hs
40         rm -rf $(HDDIR)/*
41         mkdir -p $(HDDIR)/Ganeti/HTools
42         HsColour -print-css > $(HDDIR)/Ganeti/hscolour.css
43         ln -s ../hscolour.css $(HDDIR)/Ganeti/HTools/hscolour.css
44         for file in $(HSRCS); do \
45                 hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
46                 HsColour -css -anchor $$file > $(HDDIR)/$$hfile ; \
47         done
48         haddock --odir $(HDDIR) --html --ignore-all-exports \
49                 -t ganeti-htools -p haddock-prologue \
50                 --source-module="%{MODULE/.//}.html" \
51                 --source-entity="%{MODULE/.//}.html#%{NAME}" \
52                 $(filter-out Ganeti/HTools/ExtLoader.hs,$(HSRCS))
53
54 maintainer-clean:
55         rm -rf $(HDDIR)
56         rm -f $(DOCS) TAGS version Ganeti/HTools/Version.hs
57
58 clean:
59         rm -f $(HALLPROGS)
60         rm -f *.o *.prof *.ps *.stat *.aux *.hi
61         rm -f Ganeti/HTools/Version.hs
62         cd Ganeti && rm -f *.o *.prof *.ps *.stat *.aux *.hi
63         cd Ganeti/HTools && rm -f *.o *.prof *.ps *.stat *.aux *.hi
64
65 regen-version:
66         rm -f version
67         $(MAKE) version
68
69 version:
70         if test -d .git; then \
71           git describe > $@; \
72         elif test ! -f $@ ; then \
73           echo "Cannot auto-generate $@ file"; exit 1; \
74         fi
75
76 Ganeti/HTools/Version.hs: Ganeti/HTools/Version.hs.in version
77         sed -e "s/%ver%/$$(cat version)/" < $< > $@
78
79 dist: regen-version Ganeti/HTools/Version.hs doc
80         set -e ; \
81         VN=$$(sed 's/^v//' < version) ; \
82         PFX="ganeti-htools-$$VN" ; \
83         ANAME="$$PFX.tar" ; \
84         rm -f $$ANAME $$ANAME.gz ; \
85         git archive --format=tar --prefix=$$PFX/ HEAD > $$ANAME ; \
86         tar -r -f $$ANAME --owner root --group root \
87             --transform="s,^,$$PFX/,S" version apidoc $(DOCS) $(MANS); \
88         gzip -v9 $$ANAME ; \
89         TMPDIR=$$(mktemp -d) ; \
90         tar xzf $$ANAME.gz -C $$TMPDIR; \
91         $(MAKE) -C $$TMPDIR/$$PFX; \
92         $(MAKE) -C $$TMPDIR/$$PFX clean; \
93         $(MAKE) -C $$TMPDIR/$$PFX check; \
94         rm -rf $$TMPDIR ; \
95         tar tzvf $$ANAME.gz ; \
96         sha1sum $$ANAME.gz ; \
97         echo "Archive $$ANAME.gz created."
98
99 check: test
100         rm -f *.tix *.mix
101         ./test
102 ifeq ($(T),markup)
103         mkdir -p coverage
104         hpc markup --destdir=coverage test $(HPCEXCL)
105 else
106         hpc report test $(HPCEXCL)
107 endif
108
109 live-test: all
110         rm -f *.tix *.mix
111         ./live-test.sh
112         # combine the tix files
113         hpc sum --union $(HPCEXCL) $(addsuffix .tix,$(HPROGS)) \
114           --output=live-test.tix
115 ifeq ($(T),markup)
116         mkdir -p coverage
117         hpc markup --destdir=coverage live-test $(HPCEXCL)
118 else
119         hpc report live-test $(HPCEXCL)
120 endif
121
122 tags:
123         find -name '*.hs' | xargs hasktags -e
124
125 lint:
126         hlint -r -u .
127
128 .PHONY : all doc maintainer-clean clean dist check tags regen-version man