]> Git — Sourcephile - haskell/symantic-base.git/blob - Makefile
iface: add interpreter `LetInserter`
[haskell/symantic-base.git] / Makefile
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
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)
10
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.
13
14 all: build
15 build:
16 cabal v1-build $(CABAL_BUILD_FLAGS)
17 clean c:
18 cabal clean
19 repl:
20 cabal v1-repl $(CABAL_REPL_FLAGS) $(project)
21 ghcid:
22 ghcid $(GHCID_OPTIONS) --command 'cabal v1-repl $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
23
24 .PHONY: tests
25 t tests:
26 cabal v1-test $(CABAL_TEST_FLAGS) \
27 --show-details always --test-options "$(TEST_OPTIONS)"
28 t/repl tests/repl:
29 cabal v1-repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project)-tests
30 t/ghcid tests/ghcid:
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)"'
33
34 %/accept: TEST_OPTIONS += --accept
35 %/accept: %
36
37 %/cover: CABAL_TEST_FLAGS += --enable-coverage
38 %/cover: %
39
40
41 doc:
42 cabal haddock --haddock-css ocean --haddock-hyperlink-source
43
44 .PHONY: ChangeLog.md
45 ChangeLog.md:
46 ! git tag --merged | grep -Fqx $(package)-$(version)
47 git diff --exit-code
48 git tag -f $(package)-$(version)
49 git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
50 touch $@
51 cat $@ >>$@.new
52 mv -f $@.new $@
53 git tag -d $(package)-$(version)
54 git add '$@'
55 git commit -m 'doc: update `$@`'
56 tag: build ChangeLog.md
57 git tag -s -m $(package)-$(version) $(package)-$(version)
58
59 tar:
60 git diff --exit-code
61 reuse lint
62 cabal sdist
63 cabal haddock --haddock-for-hackage --enable-doc
64 upload: LANG=C
65 upload: tar
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
71 %/publish: %
72
73 publish: upload/publish
74
75 .PHONY: .hlint.yaml
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'
81 lint: .hlint.yaml
82 if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
83 then rm -f hlint.html; \
84 else sensible-browser ./hlint.html & fi