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
 
   6 sourceDirs := $(wildcard src tests)
 
   8 override REPL_OPTIONS += -ignore-dot-ghci
 
   9 override GHCID_OPTIONS += --no-height-limit --reverse-errors --color=always --restart $(cabal) --warning
 
  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))'
 
  25         cabal test $(CABAL_TEST_FLAGS) \
 
  26          --test-show-details always --test-options "$(TEST_OPTIONS)"
 
  28         cabal repl -fno-code $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project)-tests
 
  30         ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))' \
 
  31           --run=':! ghcid $(GHCID_OPTIONS) --command "cabal repl -fno-code $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project)-tests" --test ":main $(TEST_OPTIONS)"'
 
  33 %/accept: TEST_OPTIONS += --golden-start
 
  37 %/reset: TEST_OPTIONS += --golden-reset
 
  42         cabal haddock --haddock-css ocean --haddock-hyperlink-source
 
  46         ! git tag --merged | grep -Fqx $(package)-$(version)
 
  48         git tag -f $(package)-$(version)
 
  49         git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
 
  53         git tag -d $(package)-$(version)
 
  55         git commit -m 'doc: update `$@`'
 
  56 tag: build ChangeLog.md
 
  57         git tag -s -m $(package)-$(version) $(package)-$(version)
 
  63         cabal haddock --haddock-for-hackage --enable-doc
 
  66         git tag --merged | grep -Fqx $(package)-$(version)
 
  67         git push --follow-tags $(GIT_PUSH_FLAGS)
 
  68         cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
 
  69         cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
 
  70 %/publish: CABAL_UPLOAD_FLAGS+=--publish
 
  73 publish: upload/publish
 
  77         sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
 
  78         echo >>$@ '# BEGIN: generated hints'
 
  79         find $(sourceDirs) -name "*.hs" | xargs -P $(shell nproc) -I {} \
 
  80           hlint --find {} | grep -- '- fixity:' | sort -u >>$@
 
  81         echo >>$@ '# END: generated hints'
 
  83         if hlint --quiet --report=hlint.html $(HLINT_FLAGS) $(sourceDirs); \
 
  84         then rm -f hlint.html; \
 
  85         else sensible-browser ./hlint.html & fi
 
  86 lint/apply: .hlint.yaml
 
  87         find $(sourceDirs) -name "*.hs" | xargs -P $(shell nproc) -I {} \
 
  88           hlint --refactor-options="-i" --refactor {}
 
  91         find $(sourceDirs) -name "*.hs" | xargs -P $(shell nproc) -I {} \
 
  92           fourmolu -q -o -XImportQualifiedPost --mode inplace {}