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