]> Git — Sourcephile - majurity.git/blob - GNUmakefile
protocol: remove ErrorProve
[majurity.git] / GNUmakefile
1 PKGS := \
2 hjugement \
3 hjugement-protocol
4 hjugement-protocol/test: TEST_FLAGS:=
5 HS = $(shell find . -name '*.hs' -not -name 'HLint.hs')
6 cabal := $(shell find . -name '*.cabal' -print -quit)
7 QUICKCHECK_TESTS = 1000
8 QUICKCHECK_MAXSIZE = 100
9 TEST_FLAGS = --quickcheck-tests $(QUICKCHECK_TESTS) --quickcheck-max-size $(QUICKCHECK_MAXSIZE)
10
11 all: build
12
13 build: $(PKGS:=/build)
14 %/build:
15 cd $* && stack $(STACK_FLAGS) build $(STACK_BUILD_FLAGS)
16 .PHONY: $(PKGS) $(foreach p,$(PKGS),$(eval $p: $p/build))
17
18 .PHONY: $(PKGS:=/test)
19 test: $(PKGS:=/test)
20 define test
21 $p/test:
22 ! grep -q '^Test-Suite\>' $p/$p.cabal || \
23 { cd $p && stack $$(STACK_FLAGS) test --test-arguments "$$(TEST_FLAGS)" $$(STACK_TEST_FLAGS); }
24 endef
25 $(foreach p,$(PKGS),$(eval $(call test)))
26
27 GHCID_TEST_ARGS ?=
28 GHCID_TEST ?= ":main $(GHCID_TEST_ARGS)"
29 ghcid: $(PKGS:=/ghcid)
30 %/ghcid:
31 cd $* && ghcid \
32 --warnings \
33 --command "stack $(STACK_FLAGS) $(GHCID_STACK_FLAGS) ghci $(GHCID_GHCI_FLAGS) \
34 $$(2>&1 stack ide targets | grep -v :test:) \
35 --ghci-options=-fobject-code" \
36 --test $(GHCID_TEST) \
37 $(GHCID_FLAGS)
38
39 clean: $(PKGS:=/clean)
40 cleaner: $(PKGS:=/cleaner)
41 %/clean:
42 cd $* && stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
43 %/cleaner:
44 cd $* && stack $(STACK_FLAGS) clean --full $(STACK_CLEAN_FLAGS)
45
46 %/quickcheck: override QUICKCHECK_TESTS=10000
47 %/quickcheck: override QUICKCHECK_MAXSIZE=1000
48 %/quickcheck: %
49
50 %/fast: override STACK_BUILD_FLAGS+=--fast
51 %/fast: override STACK_HADDOCK_FLAGS+=--fast
52 %/fast: override STACK_TEST_FLAGS+=--fast
53 %/fast: override QUICKCHECK_TESTS=100
54 %/fast: override QUICKCHECK_MAXSIZE=100
55 %/fast: %
56
57
58 %/debug: override STACK_BUILD_FLAGS+=--flag $(cabal:.cabal=):debug
59 %/debug: override STACK_TEST_FLAGS+=--flag $(cabal:.cabal=):debug
60 %/debug: %
61
62
63 %/accept: override STACK_TEST_ARGS+=--accept
64 %/accept: %
65
66
67 doc: $(PKGS:=/doc)
68 %/doc:
69 cd $* && stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
70 %.html: %.md
71 markdown $*.md >$*.html
72 %.html/view: %.html
73 sensible-browser $*.html
74
75 HLint.hs: $(HS)
76 sed -i -e '/^-- BEGIN: generated hints/,/^-- END: Generated by hlint/d' HLint.hs
77 echo '-- BEGIN: generated hints' >> HLint.hs
78 hlint $(foreach p,$(PKGS),--find $p) | grep '^'infix | sort -u >> HLint.hs
79 echo '-- END: generated hints' >> HLint.hs
80
81 lint: $(PKGS:=/lint) $(HS)
82 %/lint: HLint.hs
83 cd $* && if hlint --quiet --report=hlint.html -XNoCPP \
84 $(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$*) $(HLINT_FLAGS) .; \
85 then rm -f hlint.html; \
86 else sensible-browser ./hlint.html & fi
87
88 tag: $(PKGS:=/tag)
89 %/tag:
90 cabal=$*/$*.cabal; \
91 name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$$cabal"); \
92 version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$$cabal"); \
93 git tag --merged | grep -Fqx "$$name-$$version" || \
94 git tag -f -s -m "$$name v$$version" $$name-$$version
95
96 tar: $(PKGS:=/tar)
97 %/tar:
98 cd $* && stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS)
99 upload: $(PKGS:=/upload)
100 %/upload:
101 cd $* && LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) .
102
103 .PHONY: stats
104 stats:
105 gitstats . $@
106 stats/view: stats
107 sensible-browser stats/index.html