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 +=
9 override GHCID_OPTIONS += --no-height-limit --reverse-errors --color=always --warnings --restart $(cabal)
11 # Note that cabal's v1-* commands are required to use sydtest-discover from $PATH
12 # instead of requiring a cabal update to build it.
16 cabal v1-build $(CABAL_BUILD_FLAGS)
20 cabal v1-repl $(CABAL_REPL_FLAGS) $(project)
22 ghcid $(GHCID_OPTIONS) --command 'cabal v1-repl $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
26 cabal v1-test $(CABAL_TEST_FLAGS) \
27 --show-details always --test-options "$(TEST_OPTIONS)"
29 cabal v1-repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project)-tests
31 ghcid $(GHCID_OPTIONS) --command 'cabal v1-repl $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))' \
32 --run=':! ghcid $(GHCID_OPTIONS) --command "cabal v1-repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project)-tests" --test ":main $(TEST_OPTIONS)"'
34 %/accept: TEST_OPTIONS += --accept
37 %/cover: CABAL_TEST_FLAGS += --enable-coverage
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
76 .hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
77 sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
78 echo >>$@ '# BEGIN: generated hints'
79 hlint --find . | grep -- '- fixity:' | sort -u >>$@
80 echo >>$@ '# END: generated hints'
82 if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
83 then rm -f hlint.html; \
84 else sensible-browser ./hlint.html & fi