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