]> Git — Sourcephile - majurity.git/blob - GNUmakefile
Improve documentation.
[majurity.git] / GNUmakefile
1 cabal := $(shell find . -name '*.cabal' -print -quit)
2 package := $(notdir ./$(cabal:.cabal=))
3 QUICKCHECK_TESTS = 1000
4 QUICKCHECK_MAXSIZE = 100
5 TEST_FLAGS = --quickcheck-tests $(QUICKCHECK_TESTS) --quickcheck-max-size $(QUICKCHECK_MAXSIZE)
6
7 all: build
8
9 build:
10 stack $(STACK_FLAGS) build $(STACK_BUILD_FLAGS)
11
12 .PHONY: test
13 test:
14 ! grep -q '^Test-Suite\>' $(cabal) || \
15 { stack $(STACK_FLAGS) test --test-arguments "$(TEST_FLAGS)" $(STACK_TEST_FLAGS); }
16
17 %/quickcheck: override QUICKCHECK_TESTS=10000
18 %/quickcheck: override QUICKCHECK_MAXSIZE=1000
19 %/quickcheck: %
20
21
22 GHCID_TEST ?= System.Environment.withArgs (words "--color always") main `Control.Exception.finally` putStrLn "\x1b[m"
23 ghcid:
24 ghcid \
25 --warnings \
26 --command "stack ghci \
27 $(package):lib \
28 $(package):$(package)-test \
29 --ghci-options=-fobject-code" \
30 --test '$(GHCID_TEST)'
31
32 clean:
33 stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
34 cleaner:
35 stack $(STACK_FLAGS) clean --full $(STACK_CLEAN_FLAGS)
36
37 %/fast: override STACK_BUILD_FLAGS+=--fast
38 %/fast: override STACK_HADDOCK_FLAGS+=--fast
39 %/fast: override STACK_TEST_FLAGS+=--fast
40 %/fast: override QUICKCHECK_TESTS=100
41 %/fast: override QUICKCHECK_MAXSIZE=100
42 %/fast: %
43
44
45 doc:
46 stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
47 %.html: %.md
48 markdown $*.md >$*.html
49 %.html/view: %.html
50 sensible-browser $*.html
51
52 HLint.hs: $(shell find . -name '*.hs' -not -name 'HLint.hs')
53 sed -i -e '/^-- BEGIN: generated hints/,/^-- END: Generated by hlint/d' HLint.hs
54 echo '-- BEGIN: generated hints' >> HLint.hs
55 hlint --find . | grep '^'infix | sort -u >> HLint.hs
56 echo '-- END: generated hints' >> HLint.hs
57
58 lint: HLint.hs
59 if hlint --quiet --report=hlint.html -XNoCPP \
60 $(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$(cabal)) $(HLINT_FLAGS) .; \
61 then rm -f hlint.html; \
62 else sensible-browser hlint.html & fi
63
64 tag:
65 name=$$(sed -ne 's/^name: *\(.*\)/\1/p' $(cabal)); \
66 version=$$(sed -ne 's/^version: *\(.*\)/\1/p' $(cabal)); \
67 git tag --merged | grep -Fqx "$$name-$$version" || \
68 git tag -f -s -m "$$name v$$version" $$name-$$version
69
70 tar:
71 stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS)
72 upload:
73 LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) .
74
75 .PHONY: stats
76 stats:
77 gitstats . $@
78 stats/view: stats
79 sensible-browser stats/index.html