CABAL := $(shell find . -name '*.cabal' -print -quit) HS := $(shell find . -name '*.hs') all: build build: stack $(STACK_FLAGS) build $(STACK_BUILD_FLAGS) .PHONY: test test: ! grep -q '^Test-Suite\>' $(CABAL) || \ { stack $(STACK_FLAGS) test $(STACK_TEST_FLAGS); } clean: stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS) cleaner: stack $(STACK_FLAGS) clean --full $(STACK_CLEAN_FLAGS) %/fast: override STACK_BUILD_FLAGS+=--fast %/fast: override STACK_HADDOCK_FLAGS+=--fast %/fast: override STACK_TEST_FLAGS+=--fast %/fast: % doc: stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS) %.html: %.md markdown $*.md >$*.html %.html/view: %.html sensible-browser $*.html HLint.hs: $(HS) sed -i -e '/^-- BEGIN: generated hints/,/^-- END: Generated by hlint/d' HLint.hs echo '-- BEGIN: generated hints' >> HLint.hs hlint --find . | grep '^'infix | sort -u >> HLint.hs echo '-- END: generated hints' >> HLint.hs lint: HLint.hs $(HS) if hlint --quiet --report=hlint.html -XNoCPP \ $(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$(CABAL)) $(HLINT_FLAGS) .; \ then rm -f hlint.html; \ else sensible-browser hlint.html & fi tag: name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$(CABAL)"); \ version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$(CABAL)"); \ git tag --merged | grep -Fqx "$$name-$$version" || \ git tag -f -s -m "$$name v$$version" $$name-$$version tar: stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS) upload: LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) . .PHONY: stats stats: gitstats . $@ stats/view: stats sensible-browser stats/index.html # ## prof ### GHC_PROF_CATEGORIES:=hc hm hd hy hr hb GHC_PROF_CPUS:= GHC_PROF_PS_WIDTH:=11in GHC_PROF_RATE:=0.1 GHC_PROF_CC_LENGTH:=50 STACK_ROOT=$(shell stack path --local-install-root) TCT_COMMANDS:=html5 TCT_INPUTS:=tct TCT_PRINT_PROF=$(STACK_ROOT)/bin/tct-print commit:=$(shell if which git >/dev/null; then git describe --long --always; else echo COMMIT; fi) .PHONY: $(TCT_PRINT_PROF) $(TCT_PRINT_PROF): stack $(STACK_FLAGS) build --profile --flag tct:prof $(STACK_BUILD_FLAGS) .PHONY: prof prof: $(addprefix prof/,$(TCT_COMMANDS)) define prof/command prof/clean: prof/$(command)/clean prof/$(command)/%/clean: $(foreach hC,$(GHC_PROF_CATEGORIES),prof/$(command)/%/$(hC)/clean) $$(call rmw,prof/$(command)/$$*) prof/commit/$$(commit)/$$(command): mkdir -p "$$@" endef define prof/command/hC .PHONY: prof/$(command) prof/$(command): prof/$(command)/$(hC) prof/$(command)/clean: prof/$(command)/$(hC)/clean prof/$(command)/$(hC): $(addsuffix /$(hC),$(wildcard prof/$(command)/*)) prof/$(command)/$(hC)/clean: $$(call rmw, \ prof/commit/$$(commit)/$(command)/*.$(hC).aux \ prof/commit/$$(commit)/$(command)/*.$(hC).hp \ prof/commit/$$(commit)/$(command)/*.$(hC).prof \ prof/commit/$$(commit)/$(command)/*.$(hC).ps \ prof/commit/$$(commit)/$(command)/*.$(hC).stats ) .PHONY: prof/$(command)/% prof/$(command)/%: prof/$(command)/%/$(hC) prof/$(command)/%: prof/commit/$$(commit)/$(command)/%.$(hC).hs prof/$(command)/%/$(hC): prof/commit/$$(commit)/$(command)/%.$(hC).ps prof/commit/$$(commit)/$(command)/%.$(hC).hp \ prof/$(command)/%.$(command): \ $$(TCT_PRINT_PROF) \ prof/$(command)/% \ $(TCT_PRINT_PROF) \ | prof/commit/$$(commit)/$$(command) GHCRTS=' \ -$(hC)$$(GHC_PROF_$(hC)) \ -i$$(GHC_PROF_RATE) \ -L$$(GHC_PROF_CC_LENGTH) \ $$(if $$(GHC_PROF_CPUS),-N$$(GHC_PROF_CPUS)) \ -tprof/commit/$(commit)/$(command)/$$*.$(hC).stats \ -p \ $$(GHCRTS)' \ $$(TCT_PRINT_PROF) $$(TCT_FLAGS) \ $(command) $$(TCT_COMMAND_FLAGS) prof/$(command)/$$* \ >prof/$(command)/$$*.$(command) mv $(notdir $(TCT_PRINT_PROF)).hp prof/commit/$(commit)/$(command)/$$*.$(hC).hp mv $(notdir $(TCT_PRINT_PROF)).prof prof/commit/$(commit)/$(command)/$$*.$(hC).prof prof/$(command)/%/$(hC)/clean: $$(call rmw, \ prof/commit/$$(commit)/$(command)/$$*.$(hC).aux \ prof/commit/$$(commit)/$(command)/$$*.$(hC).hp \ prof/commit/$$(commit)/$(command)/$$*.$(hC).prof \ prof/commit/$$(commit)/$(command)/$$*.$(hC).ps \ prof/commit/$$(commit)/$(command)/$$*.$(hC).stats ) endef $(foreach command,$(TCT_COMMANDS), \ $(eval $(call prof/command)) \ $(foreach hC,$(GHC_PROF_CATEGORIES), \ $(eval $(call prof/command/hC)) )) %.hC.hp: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).hp) %.hC.ps: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).ps) %.ps: %.hp (cd $(@D) && hp2ps -b -c -e$(GHC_PROF_PS_WIDTH) -g $(notdir $*.hp))