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) $(CABAL_TEST_FLAGS) $(project):tests' --test ":main $(TEST_OPTIONS)"
37 .PHONY: benchmarks/time
39 cabal bench $(CABAL_BENCH_FLAGS) time \
40 --benchmark-options "$(BENCHMARKS_TIME_OPTIONS)"
41 .PHONY: benchmarks/weigh
43 cabal bench $(CABAL_BENCH_FLAGS) weigh \
44 --benchmark-options "$(BENCHMARKS_WEIGH_OPTIONS)"
45 benchmarks/weigh/ghcid:
46 ghcid $(GHCID_OPTIONS) --target=relactive --run=':! ghcid $(GHCID_OPTIONS) --target=weigh --run'
48 executables/async/ghcid:
49 ghcid $(GHCID_OPTIONS) --target=relactive --run=':! ghcid $(GHCID_OPTIONS) --target=async --run'
50 executables/fsnotify/ghcid:
51 ghcid $(GHCID_OPTIONS) --target=relactive --run=':! ghcid $(GHCID_OPTIONS) --target=fsnotify --run'
54 %/accept: TEST_OPTIONS += --accept
57 %/cover: CABAL_TEST_FLAGS += --enable-coverage
60 %.eventlog.html: RTS_OPTIONS += -hy -l-au
61 %.eventlog.html: %.eventlog
63 %.eventlog.json: RTS_OPTIONS += -p -l-au
64 %.eventlog.json: %.eventlog
68 cabal haddock --haddock-css ocean --haddock-hyperlink-source
72 ! git tag --merged | grep -Fqx $(package)-$(version)
74 git tag -f $(package)-$(version)
75 git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
79 git tag -d $(package)-$(version)
81 git commit -m 'doc: update `$@`'
82 tag: build ChangeLog.md
83 git tag -s -m $(package)-$(version) $(package)-$(version)
89 cabal haddock --haddock-for-hackage --enable-doc
92 git tag --merged | grep -Fqx $(package)-$(version)
93 git push --follow-tags $(GIT_PUSH_FLAGS)
94 cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
95 cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
96 %/publish: CABAL_UPLOAD_FLAGS+=--publish
99 publish: upload/publish
102 .hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
103 sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
104 echo >>$@ '# BEGIN: generated hints'
105 hlint --find . | grep -- '- fixity:' | sort -u >>$@
106 echo >>$@ '# END: generated hints'
108 if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
109 then rm -f hlint.html; \
110 else sensible-browser ./hlint.html & fi