1 cabal := $(shell find . -name '*.cabal' -print -quit)
2 package := $(notdir ./$(cabal:.cabal=))
7 stack $(STACK_FLAGS) build $(STACK_BUILD_FLAGS)
11 ! grep -q '^Test-Suite\>' $(cabal) || \
12 { stack $(STACK_FLAGS) test $(STACK_TEST_FLAGS); }
15 GHCID_TEST ?= ":main $(GHCID_TEST_ARGS)"
19 --command "stack ghci \
21 $(package):$(package) \
22 --ghci-options=-fobject-code" \
23 --test $(GHCID_TEST) \
27 stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
29 stack $(STACK_FLAGS) clean --full $(STACK_CLEAN_FLAGS)
31 %/fast: override STACK_BUILD_FLAGS+=--fast
32 %/fast: override STACK_HADDOCK_FLAGS+=--fast
33 %/fast: override STACK_TEST_FLAGS+=--fast
37 %/debug: override STACK_BUILD_FLAGS+=--flag $(cabal:.cabal=):debug
38 %/debug: override STACK_TEST_FLAGS+=--flag $(cabal:.cabal=):debug
43 stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
45 markdown $*.md >$*.html
47 sensible-browser $*.html
49 HLint.hs: $(shell find . -name '*.hs' -not -name 'HLint.hs')
50 sed -i -e '/^-- BEGIN: generated hints/,/^-- END: Generated by hlint/d' HLint.hs
51 echo '-- BEGIN: generated hints' >> HLint.hs
52 hlint --find . | grep '^'infix | sort -u >> HLint.hs
53 echo '-- END: generated hints' >> HLint.hs
56 if hlint --quiet --report=hlint.html -XNoCPP \
57 $(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$(cabal)) $(HLINT_FLAGS) .; \
58 then rm -f hlint.html; \
59 else sensible-browser ./hlint.html & fi
62 name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$(cabal)"); \
63 version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$(cabal)"); \
64 git tag --merged | grep -Fqx "$$name-$$version" || \
65 git tag -f -s -m "$$name v$$version" $$name-$$version
68 stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS)
70 LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) .
76 sensible-browser stats/index.html
81 GHC_PROF_CATEGORIES:=hc hm hd hy hr hb
83 GHC_PROF_PS_WIDTH:=11in
85 GHC_PROF_CC_LENGTH:=50
86 STACK_ROOT:=$(shell stack path --local-install-root)
90 TCT_PRINT_PROF=$(STACK_ROOT)/bin/tct-print
92 commit:=$(shell if which git >/dev/null; then git describe --long --always; else echo COMMIT; fi)
94 rmw=$(call if_arg,rm,$(wildcard $1))
95 rmdirw=$(call if_arg,rmdir -p --ignore-fail-on-non-empty,$(wildcard $1))
97 .PHONY: $(TCT_PRINT_PROF)
99 stack $(STACK_FLAGS) build --profile --flag tct:prof $(STACK_BUILD_FLAGS)
102 prof: $(addprefix prof/,$(TCT_COMMANDS))
105 tests:=$(wildcard test/$(command)/*.tct)
106 prof/clean: prof/$(command)/clean
107 prof/$(command)/clean:
108 $$(call rmw, prof/$(command)/$(commit)/*.out)
109 $$(call rmdirw,prof/$(command)/$(commit))
110 prof/$(command)/%/clean: \
111 $(foreach hC,$(GHC_PROF_CATEGORIES),prof/$(command)/%/$(hC)/clean)
112 $$(call rmw,prof/$(command)/$$*)
114 prof/$(command)/$(commit):
119 define prof/command/hC
120 .PHONY: prof/$(command)
121 prof/$(command): prof/$(command)/$(hC)
122 prof/$(command)/clean: prof/$(command)/$(hC)/clean
124 prof/$(command)/$(hC): $(patsubst test/%,prof/%/$(hC),$(tests))
125 .PRECIOUS: $(patsubst test/$(command)/%, \
126 prof/$(command)/$(commit)/%.$(hC).hp, \
128 .PRECIOUS: $(patsubst test/$(command)/%, \
129 prof/$(command)/$(commit)/%.$(hC).ps, \
131 prof/$(command)/$(hC)/clean:
133 prof/$(command)/$(commit)/*.$(hC).aux \
134 prof/$(command)/$(commit)/*.$(hC).hp \
135 prof/$(command)/$(commit)/*.$(hC).prof \
136 prof/$(command)/$(commit)/*.$(hC).ps \
137 prof/$(command)/$(commit)/*.$(hC).stats )
139 prof/$(command)/%: prof/$(command)/%/$(hC) \
140 prof/$(command)/$(commit)/%.$(hC).hs
141 prof/$(command)/%/$(hC): prof/$(command)/$(commit)/%.$(hC).ps
144 prof/$(command)/$(commit)/%.$(hC).prof \
145 prof/$(command)/$(commit)/%.$(hC).hp \
146 prof/$(command)/%.$(command): \
150 | prof/$(command)/$(commit)
152 -$(hC)$$(GHC_PROF_$(hC)) \
153 -i$$(GHC_PROF_RATE) \
154 -L$$(GHC_PROF_CC_LENGTH) \
155 $$(if $$(GHC_PROF_CPUS),-N$$(GHC_PROF_CPUS)) \
156 -tprof/$(command)/$(commit)/$$*.$(hC).stats \
159 $$(TCT_PRINT_PROF) $$(TCT_FLAGS) \
160 $(command) $$(TCT_COMMAND_FLAGS) test/$(command)/$$* \
161 >prof/$(command)/$(commit)/$$*.out
162 mv $(notdir $(TCT_PRINT_PROF)).hp prof/$(command)/$(commit)/$$*.$(hC).hp
163 mv $(notdir $(TCT_PRINT_PROF)).prof prof/$(command)/$(commit)/$$*.$(hC).prof
165 prof/$(command)/%/$(hC)/clean:
167 prof/$(command)/$(commit)/$$*.$(hC).aux \
168 prof/$(command)/$(commit)/$$*.$(hC).hp \
169 prof/$(command)/$(commit)/$$*.$(hC).prof \
170 prof/$(command)/$(commit)/$$*.$(hC).ps \
171 prof/$(command)/$(commit)/$$*.$(hC).stats )
175 $(foreach command,$(TCT_COMMANDS), \
176 $(eval $(call prof/command)) \
177 $(foreach hC,$(GHC_PROF_CATEGORIES), \
178 $(eval $(call prof/command/hC)) ))
180 %.hC.hp: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).hp)
182 %.hC.ps: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).ps)
185 (cd $(@D) && hp2ps -b -c -e$(GHC_PROF_PS_WIDTH) -g $(notdir $*.hp))