1 CABAL := $(shell find . -name '*.cabal' -print -quit)
2 HS := $(shell find . -name '*.hs')
7 stack $(STACK_FLAGS) build $(STACK_BUILD_FLAGS)
11 ! grep -q '^Test-Suite\>' $(CABAL) || \
12 { stack $(STACK_FLAGS) test $(STACK_TEST_FLAGS); }
15 stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
17 stack $(STACK_FLAGS) clean --full $(STACK_CLEAN_FLAGS)
19 %/fast: override STACK_BUILD_FLAGS+=--fast
20 %/fast: override STACK_HADDOCK_FLAGS+=--fast
21 %/fast: override STACK_TEST_FLAGS+=--fast
26 stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
28 markdown $*.md >$*.html
30 sensible-browser $*.html
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
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
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
51 stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS)
53 LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) .
59 sensible-browser stats/index.html
64 GHC_PROF_CATEGORIES:=hc hm hd hy hr hb
66 GHC_PROF_PS_WIDTH:=11in
68 GHC_PROF_CC_LENGTH:=50
69 STACK_ROOT=$(shell stack path --local-install-root)
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)
76 .PHONY: $(TCT_PRINT_PROF)
78 stack $(STACK_FLAGS) build --profile --flag tct:prof $(STACK_BUILD_FLAGS)
81 prof: $(addprefix prof/,$(TCT_COMMANDS))
84 prof/clean: prof/$(command)/clean
85 prof/$(command)/%/clean: $(foreach hC,$(GHC_PROF_CATEGORIES),prof/$(command)/%/$(hC)/clean)
86 $$(call rmw,prof/$(command)/$$*)
88 prof/commit/$$(commit)/$$(command):
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:
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 )
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
112 prof/commit/$$(commit)/$(command)/%.$(hC).hp \
113 prof/$(command)/%.$(command): \
117 | prof/commit/$$(commit)/$$(command)
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 \
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
132 prof/$(command)/%/$(hC)/clean:
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 )
142 $(foreach command,$(TCT_COMMANDS), \
143 $(eval $(call prof/command)) \
144 $(foreach hC,$(GHC_PROF_CATEGORIES), \
145 $(eval $(call prof/command/hC)) ))
147 %.hC.hp: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).hp)
149 %.hC.ps: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).ps)
152 (cd $(@D) && hp2ps -b -c -e$(GHC_PROF_PS_WIDTH) -g $(notdir $*.hp))