X-Git-Url: https://git.sourcephile.fr/doclang.git/blobdiff_plain/018b7a5af87a3d183f438c04c6a36bc49cabfc20..04525c9a739c9743663a54cfa961c7754d7de16a:/GNUmakefile diff --git a/GNUmakefile b/GNUmakefile index 8ca044c..bdceb0b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,5 +1,4 @@ -CABAL := $(shell find . -name '*.cabal' -print -quit) -HS := $(shell find . -name '*.hs') +CABAL := $(shell find . -maxdepth 1 -name '*.cabal' -print -quit) all: build @@ -29,13 +28,13 @@ doc: %.html/view: %.html sensible-browser $*.html -HLint.hs: $(HS) +HLint.hs: $(shell find . -name '*.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) +lint: HLint.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; \ @@ -66,12 +65,16 @@ 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) +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) +if_arg=$(if $2,$1 $2) +rmw=$(call if_arg,rm,$(wildcard $1)) +rmdirw=$(call if_arg,rmdir -p --ignore-fail-on-non-empty,$(wildcard $1)) .PHONY: $(TCT_PRINT_PROF) $(TCT_PRINT_PROF): @@ -81,11 +84,16 @@ $(TCT_PRINT_PROF): prof: $(addprefix prof/,$(TCT_COMMANDS)) define prof/command +tests:=$(wildcard test/$(command)/*.tct) prof/clean: prof/$(command)/clean -prof/$(command)/%/clean: $(foreach hC,$(GHC_PROF_CATEGORIES),prof/$(command)/%/$(hC)/clean) +prof/$(command)/clean: + $$(call rmw, prof/$(command)/$(commit)/*.out) + $$(call rmdirw,prof/$(command)/$(commit)) +prof/$(command)/%/clean: \ + $(foreach hC,$(GHC_PROF_CATEGORIES),prof/$(command)/%/$(hC)/clean) $$(call rmw,prof/$(command)/$$*) -prof/commit/$$(commit)/$$(command): +prof/$(command)/$(commit): mkdir -p "$$@" endef @@ -94,48 +102,55 @@ 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): $(patsubst test/%,prof/%/$(hC),$(tests)) +.PRECIOUS: $(patsubst test/$(command)/%, \ + prof/$(command)/$(commit)/%.$(hC).hp, \ + $(tests)) +.PRECIOUS: $(patsubst test/$(command)/%, \ + prof/$(command)/$(commit)/%.$(hC).ps, \ + $(tests)) 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/$(command)/$(commit)/*.$(hC).aux \ + prof/$(command)/$(commit)/*.$(hC).hp \ + prof/$(command)/$(commit)/*.$(hC).prof \ + prof/$(command)/$(commit)/*.$(hC).ps \ + prof/$(command)/$(commit)/*.$(hC).stats ) + +prof/$(command)/%: prof/$(command)/%/$(hC) \ + prof/$(command)/$(commit)/%.$(hC).hs +prof/$(command)/%/$(hC): prof/$(command)/$(commit)/%.$(hC).ps -prof/commit/$$(commit)/$(command)/%.$(hC).hp \ +prof/$(command)/$(commit)/%.$(hC).prof \ +prof/$(command)/$(commit)/%.$(hC).hp \ prof/$(command)/%.$(command): \ $$(TCT_PRINT_PROF) \ - prof/$(command)/% \ + test/$(command)/% \ $(TCT_PRINT_PROF) \ - | prof/commit/$$(commit)/$$(command) + | prof/$(command)/$(commit) 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 \ + -tprof/$(command)/$(commit)/$$*.$(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 + $(command) $$(TCT_COMMAND_FLAGS) test/$(command)/$$* \ + >prof/$(command)/$(commit)/$$*.out + mv $(notdir $(TCT_PRINT_PROF)).hp prof/$(command)/$(commit)/$$*.$(hC).hp + mv $(notdir $(TCT_PRINT_PROF)).prof prof/$(command)/$(commit)/$$*.$(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 ) + prof/$(command)/$(commit)/$$*.$(hC).aux \ + prof/$(command)/$(commit)/$$*.$(hC).hp \ + prof/$(command)/$(commit)/$$*.$(hC).prof \ + prof/$(command)/$(commit)/$$*.$(hC).ps \ + prof/$(command)/$(commit)/$$*.$(hC).stats ) endef @@ -148,6 +163,6 @@ $(foreach command,$(TCT_COMMANDS), \ %.hC.ps: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).ps) -%.ps: %.hp +%.ps %.aux: %.hp (cd $(@D) && hp2ps -b -c -e$(GHC_PROF_PS_WIDTH) -g $(notdir $*.hp))