]> Git — Sourcephile - haskell/literate-web.git/blob - Makefile
init
[haskell/literate-web.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 += --color=always
9 override GHCID_OPTIONS += --no-height-limit --reverse-errors --color=always --warnings --restart $(cabal)
10
11 all: build
12 build:
13 cabal build $(CABAL_BUILD_FLAGS)
14 clean c:
15 cabal clean
16 repl:
17 cabal repl $(CABAL_REPL_FLAGS) $(project)
18 ghcid:
19 ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
20
21 .PHONY: tests
22 t tests:
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
32 t/repl tests/repl:
33 cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) --enable-tests $(project)-tests
34 t/ghcid tests/ghcid:
35 ghcid $(GHCID_OPTIONS) --command 'cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project):tests' --test ":main $(TEST_OPTIONS)"
36
37 .PHONY: benchmarks/time
38 bt benchmarks/time:
39 cabal bench $(CABAL_BENCH_FLAGS) time \
40 --benchmark-options "$(BENCHMARKS_TIME_OPTIONS)"
41 .PHONY: benchmarks/weigh
42 bw 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'
47
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'
52
53
54 %/accept: TEST_OPTIONS += --accept
55 %/accept: %
56
57 %/cover: CABAL_TEST_FLAGS += --enable-coverage
58 %/cover: %
59
60 %.eventlog.html: RTS_OPTIONS += -hy -l-au
61 %.eventlog.html: %.eventlog
62 eventlog2html $<
63 %.eventlog.json: RTS_OPTIONS += -p -l-au
64 %.eventlog.json: %.eventlog
65 hs-speedscope $<
66
67 doc:
68 cabal haddock --haddock-css ocean --haddock-hyperlink-source
69
70 .PHONY: ChangeLog.md
71 ChangeLog.md:
72 ! git tag --merged | grep -Fqx $(package)-$(version)
73 git diff --exit-code
74 git tag -f $(package)-$(version)
75 git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
76 touch $@
77 cat $@ >>$@.new
78 mv -f $@.new $@
79 git tag -d $(package)-$(version)
80 git add '$@'
81 git commit -m 'doc: update `$@`'
82 tag: build ChangeLog.md
83 git tag -s -m $(package)-$(version) $(package)-$(version)
84
85 tar:
86 git diff --exit-code
87 reuse lint
88 cabal sdist
89 cabal haddock --haddock-for-hackage --enable-doc
90 upload: LANG=C
91 upload: tar
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
97 %/publish: %
98
99 publish: upload/publish
100
101 .PHONY: .hlint.yaml
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'
107 lint: .hlint.yaml
108 if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
109 then rm -f hlint.html; \
110 else sensible-browser ./hlint.html & fi