1 override BENCHMARK_OPTIONS += --output benchmarks/html/$(version).html --match glob $b
 
   2 override GHCID_OPTIONS += --no-height-limit --reverse-errors 
 
   3 override GHC_PROF_OPTIONS += -eventlog -fprof-auto -fprof-cafs
 
   5 override REPL_OPTIONS += -ignore-dot-ghci
 
   6 override RTS_OPTIONS += -L100
 
   7 override TEST_OPTIONS += --color always --size-cutoff 1000000 $(addprefix -p ,$t)
 
   8 override CABAL_TEST_FLAGS += -j
 
  10 cabal := $(wildcard *.cabal)
 
  11 package := $(notdir ./$(cabal:.cabal=))
 
  12 version := $(shell sed -ne 's/^version: *\(.*\)/\1/p' $(cabal))
 
  13 project := $(patsubst %.cabal,%,$(cabal))
 
  14 cabal_builddir ?= dist-newstyle
 
  18         cabal build $(CABAL_BUILD_FLAGS)
 
  22         cabal repl $(CABAL_REPL_FLAGS) $(project)
 
  24         ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
 
  27         cabal build $(CABAL_BUILD_FLAGS) $(project):parsers
 
  29         cabal repl $(CABAL_REPL_FLAGS) $(project):parsers
 
  31         ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project):parsers $(addprefix --repl-options ,$(REPL_OPTIONS))'
 
  33         cabal v2-build lib:$(project) --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) --write-ghc-environment-files=always
 
  34         cabal build $(CABAL_BUILD_FLAGS) $(project):parsers \
 
  35          --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) \
 
  36          --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
 
  40         cabal test $(CABAL_TEST_FLAGS) \
 
  41          --test-show-details always --test-options "$(TEST_OPTIONS)"
 
  42 tests/prof-time: $(project)-test.eventlog.json
 
  43 tests/prof-heap: $(project)-test.eventlog.html
 
  44 .PHONY: $(project)-test.eventlog
 
  45 $(project)-test.eventlog $(project)-test.prof:
 
  46         cabal test $(CABAL_TEST_FLAGS) \
 
  47          --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
 
  48          --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) || true
 
  50         cabal v2-build lib:$(project) --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) --write-ghc-environment-files=always
 
  51         cabal test $(CABAL_TEST_FLAGS) \
 
  52          --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
 
  53          --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) \
 
  54          --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
 
  56         cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) --enable-tests $(project)-test
 
  58         ghcid $(GHCID_OPTIONS) --command 'cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project):tests' --test ":main $(TEST_OPTIONS)"
 
  60 %/accept: TEST_OPTIONS += --accept
 
  63 %/cover: CABAL_TEST_FLAGS += --enable-coverage
 
  66 %.eventlog.html: RTS_OPTIONS += -hy -l-au
 
  67 %.eventlog.html: %.eventlog
 
  69 %.eventlog.json: RTS_OPTIONS += -p -l-au
 
  70 %.eventlog.json: %.eventlog
 
  73 .PHONY: benchmarks/html/$(version).html
 
  74 b benchmarks: benchmarks/html/$(version).html
 
  75 benchmarks/html/$(version).html:
 
  76         mkdir -p benchmarks/html
 
  77         cabal bench $(CABAL_BENCH_FLAGS) --benchmark-options "$(BENCHMARK_OPTIONS)"
 
  79         cabal repl $(CABAL_REPL_FLAGS) --enable-benchmarks $(project)-benchmark
 
  80 benchmarks/prof-time: $(project)-benchmark.eventlog.json
 
  81 benchmarks/prof-heap: $(project)-benchmark.eventlog.html
 
  82 .PHONY: $(project)-benchmark.eventlog
 
  83 $(project)-benchmark.eventlog $(project)-benchmark.prof:
 
  84         @echo "$$(tput setaf 1)WARNING: benchmarking with --enable-profiling can create significant biases$$(tput sgr0)"
 
  85         cabal bench $(CABAL_BENCH_FLAGS) \
 
  86          --benchmark-options "$(BENCHMARK_OPTIONS) +RTS $(RTS_OPTIONS)" \
 
  87          --enable-profiling $(GHC_PROF_OPTIONS)
 
  88 $(project)-benchmark.prof2:
 
  89         cabal v2-build lib:$(project) --enable-profiling $(GHC_PROF_OPTIONS) --write-ghc-environment-files=always
 
  90         cabal bench $(CABAL_BENCH_FLAGS) \
 
  91          --benchmark-options "$(BENCHMARK_OPTIONS)" \
 
  92          --enable-profiling $(GHC_PROF_OPTIONS) \
 
  93          --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
 
  96         cabal haddock --haddock-css ocean --haddock-hyperlink-source
 
 100         ! git tag --merged | grep -Fqx $(package)-$(version)
 
 102         git tag -f $(package)-$(version)
 
 103         git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
 
 107         git tag -d $(package)-$(version)
 
 109         git commit -m 'doc: update `$@`'
 
 111         git tag -s -m $(package)-$(version) $(package)-$(version)
 
 117         cabal haddock --haddock-for-hackage --enable-doc
 
 120         git push --follow-tags $(GIT_PUSH_FLAGS)
 
 121         cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
 
 122         cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
 
 123 %/publish: CABAL_UPLOAD_FLAGS+=--publish
 
 126 publish: upload/publish
 
 128 .hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
 
 129         sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
 
 130         echo >>$@ '# BEGIN: generated hints'
 
 131         hlint --find . | grep -- '- fixity:' | sort -u >>$@
 
 132         echo >>$@ '# END: generated hints'
 
 134         if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
 
 135         then rm -f hlint.html; \
 
 136         else sensible-browser ./hlint.html & fi