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)
 
  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)"
 
  26         cabal repl -fno-code $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project)-tests
 
  28         ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))' \
 
  29           --run=':! ghcid $(GHCID_OPTIONS) --command "cabal repl -fno-code $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project)-tests" --test ":main $(TEST_OPTIONS)"'
 
  31 %/accept: TEST_OPTIONS += --golden-start
 
  36         cabal haddock --haddock-css ocean --haddock-hyperlink-source
 
  40         ! git tag --merged | grep -Fqx $(package)-$(version)
 
  42         git tag -f $(package)-$(version)
 
  43         git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
 
  47         git tag -d $(package)-$(version)
 
  49         git commit -m 'doc: update `$@`'
 
  50 tag: build ChangeLog.md
 
  51         git tag -s -m $(package)-$(version) $(package)-$(version)
 
  57         cabal haddock --haddock-for-hackage --enable-doc
 
  60         git tag --merged | grep -Fqx $(package)-$(version)
 
  61         git push --follow-tags $(GIT_PUSH_FLAGS)
 
  62         cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
 
  63         cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
 
  64 %/publish: CABAL_UPLOAD_FLAGS+=--publish
 
  67 publish: upload/publish
 
  71         sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
 
  72         echo >>$@ '# BEGIN: generated hints'
 
  73         find $(sourceDirs) -name "*.hs" | xargs -P $(shell nproc) -I {} \
 
  74           hlint --find {} | grep -- '- fixity:' | sort -u >>$@
 
  75         echo >>$@ '# END: generated hints'
 
  77         if hlint --quiet --report=hlint.html $(HLINT_FLAGS) $(sourceDirs); \
 
  78         then rm -f hlint.html; \
 
  79         else sensible-browser ./hlint.html & fi
 
  80 lint/apply: .hlint.yaml
 
  81         find $(sourceDirs) -name "*.hs" | xargs -P $(shell nproc) -I {} \
 
  82           hlint --refactor-options="-i" --refactor {}
 
  85         find $(sourceDirs) -name "*.hs" | xargs -P $(shell nproc) -I {} \
 
  86           fourmolu -q -o -XImportQualifiedPost --mode inplace {}