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