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