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