]> Git — Sourcephile - haskell/symantic-base.git/blob - GNUmakefile
init
[haskell/symantic-base.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.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
55 sed -i -e '/^# BEGIN: generated hints/,/^# END: Generated by hlint/d' $@
56 echo >>$@ '# BEGIN: generated hints'
57 hlint --find . | sed -ne 's/^- fixity:/- fixity:/p' | sort -u >>$@
58 echo >>$@ '# END: generated hints'
59
60 lint: .hlint.yaml
61 if hlint --quiet --report=hlint.html $(HLINT_FLAGS) .; \
62 then rm -f hlint.html; \
63 else sensible-browser ./hlint.html & fi
64
65 tag:
66 name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$(cabal)"); \
67 version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$(cabal)"); \
68 git tag --merged | grep -Fqx "$$name-$$version" || \
69 git tag -f -s -m "$$name v$$version" $$name-$$version
70
71 tar:
72 stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS)
73 upload:
74 LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) .
75
76 .PHONY: stats
77 stats:
78 gitstats . $@
79 stats/view: stats
80 sensible-browser stats/index.html