1 CABAL := $(shell find . -maxdepth 1 -name '*.cabal' -print -quit)
 
   6         stack $(STACK_FLAGS) build $(STACK_BUILD_FLAGS)
 
  10         ! grep -q '^Test-Suite\>' $(CABAL) || \
 
  11         { stack $(STACK_FLAGS) test $(STACK_TEST_FLAGS); }
 
  14         stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
 
  16         stack $(STACK_FLAGS) clean --full $(STACK_CLEAN_FLAGS)
 
  18 %/fast: override STACK_BUILD_FLAGS+=--fast
 
  19 %/fast: override STACK_HADDOCK_FLAGS+=--fast
 
  20 %/fast: override STACK_TEST_FLAGS+=--fast
 
  25         stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
 
  27         markdown $*.md >$*.html
 
  29         sensible-browser $*.html
 
  31 HLint.hs: $(shell find . -name '*.hs')
 
  32         sed -i -e '/^-- BEGIN: generated hints/,/^-- END: Generated by hlint/d' HLint.hs
 
  33         echo '-- BEGIN: generated hints' >> HLint.hs
 
  34         hlint --find . | grep '^'infix | sort -u >> HLint.hs
 
  35         echo '-- END: generated hints' >> HLint.hs
 
  38         if hlint --quiet --report=hlint.html -XNoCPP \
 
  39          $(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$(CABAL)) $(HLINT_FLAGS) .; \
 
  40         then rm -f hlint.html; \
 
  41         else sensible-browser hlint.html & fi
 
  44         name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$(CABAL)"); \
 
  45         version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$(CABAL)"); \
 
  46         git tag --merged | grep -Fqx "$$name-$$version" || \
 
  47         git tag -f -s -m "$$name v$$version" $$name-$$version
 
  50         stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS)
 
  52         LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) .
 
  58         sensible-browser stats/index.html
 
  63 GHC_PROF_CATEGORIES:=hc hm hd hy hr hb
 
  65 GHC_PROF_PS_WIDTH:=11in
 
  67 GHC_PROF_CC_LENGTH:=50
 
  68 STACK_ROOT:=$(shell stack path --local-install-root)
 
  72 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 rmw=$(call if_arg,rm,$(wildcard $1))
 
  77 rmdirw=$(call if_arg,rmdir -p --ignore-fail-on-non-empty,$(wildcard $1))
 
  79 .PHONY: $(TCT_PRINT_PROF)
 
  81         stack $(STACK_FLAGS) build --profile --flag tct:prof $(STACK_BUILD_FLAGS)
 
  84 prof: $(addprefix prof/,$(TCT_COMMANDS))
 
  87 tests:=$(wildcard test/$(command)/*.tct)
 
  88 prof/clean: prof/$(command)/clean
 
  89 prof/$(command)/clean:
 
  90         $$(call rmw,   prof/$(command)/$(commit)/*.out)
 
  91         $$(call rmdirw,prof/$(command)/$(commit))
 
  92 prof/$(command)/%/clean: \
 
  93  $(foreach hC,$(GHC_PROF_CATEGORIES),prof/$(command)/%/$(hC)/clean)
 
  94         $$(call rmw,prof/$(command)/$$*)
 
  96 prof/$(command)/$(commit):
 
 101 define prof/command/hC
 
 102 .PHONY: prof/$(command)
 
 103 prof/$(command):       prof/$(command)/$(hC)
 
 104 prof/$(command)/clean: prof/$(command)/$(hC)/clean
 
 106 prof/$(command)/$(hC): $(patsubst test/%,prof/%/$(hC),$(tests))
 
 107 .PRECIOUS: $(patsubst test/$(command)/%, \
 
 108                       prof/$(command)/$(commit)/%.$(hC).hp, \
 
 110 .PRECIOUS: $(patsubst test/$(command)/%, \
 
 111                       prof/$(command)/$(commit)/%.$(hC).ps, \
 
 113 prof/$(command)/$(hC)/clean:
 
 115          prof/$(command)/$(commit)/*.$(hC).aux \
 
 116          prof/$(command)/$(commit)/*.$(hC).hp \
 
 117          prof/$(command)/$(commit)/*.$(hC).prof \
 
 118          prof/$(command)/$(commit)/*.$(hC).ps \
 
 119          prof/$(command)/$(commit)/*.$(hC).stats )
 
 121 prof/$(command)/%: prof/$(command)/%/$(hC) \
 
 122                    prof/$(command)/$(commit)/%.$(hC).hs
 
 123 prof/$(command)/%/$(hC): prof/$(command)/$(commit)/%.$(hC).ps
 
 126 prof/$(command)/$(commit)/%.$(hC).prof \
 
 127 prof/$(command)/$(commit)/%.$(hC).hp \
 
 128 prof/$(command)/%.$(command): \
 
 132  | prof/$(command)/$(commit)
 
 134          -$(hC)$$(GHC_PROF_$(hC)) \
 
 135          -i$$(GHC_PROF_RATE) \
 
 136          -L$$(GHC_PROF_CC_LENGTH) \
 
 137          $$(if $$(GHC_PROF_CPUS),-N$$(GHC_PROF_CPUS)) \
 
 138          -tprof/$(command)/$(commit)/$$*.$(hC).stats \
 
 141         $$(TCT_PRINT_PROF) $$(TCT_FLAGS) \
 
 142          $(command) $$(TCT_COMMAND_FLAGS) test/$(command)/$$* \
 
 143          >prof/$(command)/$(commit)/$$*.out
 
 144         mv $(notdir $(TCT_PRINT_PROF)).hp   prof/$(command)/$(commit)/$$*.$(hC).hp
 
 145         mv $(notdir $(TCT_PRINT_PROF)).prof prof/$(command)/$(commit)/$$*.$(hC).prof
 
 147 prof/$(command)/%/$(hC)/clean:
 
 149          prof/$(command)/$(commit)/$$*.$(hC).aux \
 
 150          prof/$(command)/$(commit)/$$*.$(hC).hp \
 
 151          prof/$(command)/$(commit)/$$*.$(hC).prof \
 
 152          prof/$(command)/$(commit)/$$*.$(hC).ps \
 
 153          prof/$(command)/$(commit)/$$*.$(hC).stats )
 
 157 $(foreach command,$(TCT_COMMANDS), \
 
 158  $(eval $(call prof/command)) \
 
 159  $(foreach hC,$(GHC_PROF_CATEGORIES), \
 
 160   $(eval $(call prof/command/hC)) ))
 
 162 %.hC.hp: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).hp)
 
 164 %.hC.ps: $(foreach hC,$(GHC_PROF_CATEGORIES),%.$(hC).ps)
 
 167         (cd $(@D) && hp2ps -b -c -e$(GHC_PROF_PS_WIDTH) -g $(notdir $*.hp))