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