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