1 cabal := $(wildcard *.cabal)
 
   2 package := $(notdir ./$(cabal:.cabal=))
 
   3 version := $(shell sed -ne 's/^version: *\(.*\)/\1/p' $(cabal))
 
   4 project := $(patsubst %.cabal,%,$(cabal))
 
   5 cabal_builddir ?= dist-newstyle
 
   7 override REPL_OPTIONS += -ignore-dot-ghci
 
   8 override TEST_OPTIONS += --color=always
 
   9 override GHCID_OPTIONS += --no-height-limit --reverse-errors --color=always --warnings --restart $(cabal)
 
  13         cabal build $(CABAL_BUILD_FLAGS)
 
  17         cabal repl $(CABAL_REPL_FLAGS) $(project)
 
  19         ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
 
  23         cabal test $(CABAL_TEST_FLAGS) \
 
  24          --test-show-details always --test-options "$(TEST_OPTIONS)"
 
  25 tests/prof-time: $(project)-tests.eventlog.json
 
  26 tests/prof-heap: $(project)-tests.eventlog.html
 
  27 .PHONY: $(project)-test.eventlog
 
  28 $(project)-test.eventlog $(project)-test.prof:
 
  29         cabal test $(CABAL_TEST_FLAGS) \
 
  30          --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
 
  31          --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) || true
 
  33         cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) --enable-tests $(project)-tests
 
  35         ghcid $(GHCID_OPTIONS) --command 'cabal repl $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))' \
 
  36           --run=':! ghcid $(GHCID_OPTIONS) --command "cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project):tests" --test ":main $(TEST_OPTIONS)"'
 
  38 .PHONY: benchmarks/time
 
  40         cabal bench $(CABAL_BENCH_FLAGS) time \
 
  41          --benchmark-options "$(BENCHMARKS_TIME_OPTIONS)"
 
  42 .PHONY: benchmarks/weigh
 
  44         cabal bench $(CABAL_BENCH_FLAGS) weigh \
 
  45          --benchmark-options "$(BENCHMARKS_WEIGH_OPTIONS)"
 
  46 benchmarks/weigh/ghcid:
 
  47         ghcid $(GHCID_OPTIONS) --target=relactive --run=':! ghcid $(GHCID_OPTIONS) --target=weigh --run'
 
  49 executables/async/ghcid:
 
  50         ghcid $(GHCID_OPTIONS) --target=relactive --run=':! ghcid $(GHCID_OPTIONS) --target=async --run'
 
  51 executables/fsnotify/ghcid:
 
  52         ghcid $(GHCID_OPTIONS) --target=relactive --run=':! ghcid $(GHCID_OPTIONS) --target=fsnotify --run'
 
  55 %/accept: TEST_OPTIONS += --accept
 
  58 %/cover: CABAL_TEST_FLAGS += --enable-coverage
 
  61 %.eventlog.html: RTS_OPTIONS += -hy -l-au
 
  62 %.eventlog.html: %.eventlog
 
  64 %.eventlog.json: RTS_OPTIONS += -p -l-au
 
  65 %.eventlog.json: %.eventlog
 
  69         cabal haddock --haddock-css ocean --haddock-hyperlink-source
 
  73         ! git tag --merged | grep -Fqx $(package)-$(version)
 
  75         git tag -f $(package)-$(version)
 
  76         git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
 
  80         git tag -d $(package)-$(version)
 
  82         git commit -m 'doc: update `$@`'
 
  83 tag: build ChangeLog.md
 
  84         git tag -s -m $(package)-$(version) $(package)-$(version)
 
  90         cabal haddock --haddock-for-hackage --enable-doc
 
  93         git tag --merged | grep -Fqx $(package)-$(version)
 
  94         git push --follow-tags $(GIT_PUSH_FLAGS)
 
  95         cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
 
  96         cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
 
  97 %/publish: CABAL_UPLOAD_FLAGS+=--publish
 
 100 publish: upload/publish
 
 103 .hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
 
 104         sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
 
 105         echo >>$@ '# BEGIN: generated hints'
 
 106         hlint --find . | grep -- '- fixity:' | sort -u >>$@
 
 107         echo >>$@ '# END: generated hints'
 
 109         if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
 
 110         then rm -f hlint.html; \
 
 111         else sensible-browser ./hlint.html & fi