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