]> Git — Sourcephile - doclang.git/blob - GNUmakefile
Add data strictness.
[doclang.git] / GNUmakefile
1 CABAL := $(shell find . -name '*.cabal' -print -quit)
2 HS := $(shell find . -name '*.hs')
3
4 all: build
5
6 build:
7 stack $(STACK_FLAGS) build $(STACK_BUILD_FLAGS)
8
9 .PHONY: test
10 test:
11 ! grep -q '^Test-Suite\>' $(CABAL) || \
12 { stack $(STACK_FLAGS) test $(STACK_TEST_FLAGS); }
13
14 clean:
15 stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
16 cleaner:
17 stack $(STACK_FLAGS) clean --full $(STACK_CLEAN_FLAGS)
18
19 %/fast: override STACK_BUILD_FLAGS+=--fast
20 %/fast: override STACK_HADDOCK_FLAGS+=--fast
21 %/fast: override STACK_TEST_FLAGS+=--fast
22 %/fast: %
23
24
25 doc:
26 stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
27 %.html: %.md
28 markdown $*.md >$*.html
29 %.html/view: %.html
30 sensible-browser $*.html
31
32 HLint.hs: $(HS)
33 sed -i -e '/^-- BEGIN: generated hints/,/^-- END: Generated by hlint/d' HLint.hs
34 echo '-- BEGIN: generated hints' >> HLint.hs
35 hlint --find . | grep '^'infix | sort -u >> HLint.hs
36 echo '-- END: generated hints' >> HLint.hs
37
38 lint: HLint.hs $(HS)
39 if hlint --quiet --report=hlint.html -XNoCPP \
40 $(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$(CABAL)) $(HLINT_FLAGS) .; \
41 then rm -f hlint.html; \
42 else sensible-browser hlint.html & fi
43
44 tag:
45 name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$(CABAL)"); \
46 version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$(CABAL)"); \
47 git tag --merged | grep -Fqx "$$name-$$version" || \
48 git tag -f -s -m "$$name v$$version" $$name-$$version
49
50 tar:
51 stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS)
52 upload:
53 LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) .
54
55 .PHONY: stats
56 stats:
57 gitstats . $@
58 stats/view: stats
59 sensible-browser stats/index.html
60
61 #
62 ## prof
63 ###
64 GHC_PROF_CATEGORIES:=hc hm hd hy hr hb
65 GHC_PROF_CPUS:=
66 GHC_PROF_PS_WIDTH:=11in
67 GHC_PROF_RATE:=0.1
68 GHC_PROF_CC_LENGTH:=50
69 STACK_ROOT=$(shell stack path --local-install-root)
70
71 TCT_COMMANDS:=html5
72 TCT_INPUTS:=tct
73 TCT_PRINT_PROF=$(STACK_ROOT)/bin/tct-print
74 commit:=$(shell if which git >/dev/null; then git describe --long --always; else echo COMMIT; fi)
75
76 .PHONY: $(TCT_PRINT_PROF)
77 $(TCT_PRINT_PROF):
78 stack $(STACK_FLAGS) build --profile --flag tct:prof $(STACK_BUILD_FLAGS)
79
80 .PHONY: prof
81 prof: $(addprefix prof/,$(TCT_COMMANDS))
82
83 define prof/command
84 prof/clean: prof/$(command)/clean
85 prof/$(command)/%/clean: $(foreach hC,$(GHC_PROF_CATEGORIES),prof/$(command)/%/$(hC)/clean)
86 $$(call rmw,prof/$(command)/$$*)
87
88 prof/commit/$$(commit)/$$(command):
89 mkdir -p "$$@"
90
91 endef
92
93 define prof/command/hC
94 .PHONY: prof/$(command)
95 prof/$(command): prof/$(command)/$(hC)
96 prof/$(command)/clean: prof/$(command)/$(hC)/clean
97 prof/$(command)/$(hC): $(addsuffix /$(hC),$(wildcard prof/$(command)/*))
98 prof/$(command)/$(hC)/clean:
99 $$(call rmw, \
100 prof/commit/$$(commit)/$(command)/*.$(hC).aux \
101 prof/commit/$$(commit)/$(command)/*.$(hC).hp \
102 prof/commit/$$(commit)/$(command)/*.$(hC).prof \
103 prof/commit/$$(commit)/$(command)/*.$(hC).ps \
104 prof/commit/$$(commit)/$(command)/*.$(hC).stats )
105
106 .PHONY: prof/$(command)/%
107 prof/$(command)/%: prof/$(command)/%/$(hC)
108 prof/$(command)/%: prof/commit/$$(commit)/$(command)/%.$(hC).hs
109 prof/$(command)/%/$(hC): prof/commit/$$(commit)/$(command)/%.$(hC).ps
110
111
112 prof/commit/$$(commit)/$(command)/%.$(hC).hp \
113 prof/$(command)/%.$(command): \
114 $$(TCT_PRINT_PROF) \
115 prof/$(command)/% \
116 $(TCT_PRINT_PROF) \
117 | prof/commit/$$(commit)/$$(command)
118 GHCRTS=' \
119 -$(hC)$$(GHC_PROF_$(hC)) \
120 -i$$(GHC_PROF_RATE) \
121 -L$$(GHC_PROF_CC_LENGTH) \
122 $$(if $$(GHC_PROF_CPUS),-N$$(GHC_PROF_CPUS)) \
123 -tprof/commit/$(commit)/$(command)/$$*.$(hC).stats \
124 -p \
125 $$(GHCRTS)' \
126 $$(TCT_PRINT_PROF) $$(TCT_FLAGS) \
127 $(command) $$(TCT_COMMAND_FLAGS) prof/$(command)/$$* \
128 >prof/$(command)/$$*.$(command)
129 mv $(notdir $(TCT_PRINT_PROF)).hp prof/commit/$(commit)/$(command)/$$*.$(hC).hp
130 mv $(notdir $(TCT_PRINT_PROF)).prof prof/commit/$(commit)/$(command)/$$*.$(hC).prof
131
132 prof/$(command)/%/$(hC)/clean:
133 $$(call rmw, \
134 prof/commit/$$(commit)/$(command)/$$*.$(hC).aux \
135 prof/commit/$$(commit)/$(command)/$$*.$(hC).hp \
136 prof/commit/$$(commit)/$(command)/$$*.$(hC).prof \
137 prof/commit/$$(commit)/$(command)/$$*.$(hC).ps \
138 prof/commit/$$(commit)/$(command)/$$*.$(hC).stats )
139
140 endef
141
142 $(foreach command,$(TCT_COMMANDS), \
143 $(eval $(call prof/command)) \
144 $(foreach hC,$(GHC_PROF_CATEGORIES), \
145 $(eval $(call prof/command/hC)) ))
146
147 %.hC.hp: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).hp)
148
149 %.hC.ps: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).ps)
150
151 %.ps: %.hp
152 (cd $(@D) && hp2ps -b -c -e$(GHC_PROF_PS_WIDTH) -g $(notdir $*.hp))
153