diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1311fcd --- /dev/null +++ b/Makefile | |||
@@ -0,0 +1,76 @@ | |||
1 | ifdef CEREAL | ||
2 | GHCFLAGS=-Wall -O2 -DCEREAL -fno-warn-name-shadowing -XHaskell98 | ||
3 | else | ||
4 | GHCFLAGS=-Wall -O2 -fno-warn-name-shadowing -XHaskell98 | ||
5 | endif | ||
6 | |||
7 | ifdef TRAVIS | ||
8 | GHCFLAGS+=-Werror | ||
9 | endif | ||
10 | |||
11 | HLINTFLAGS=-u -XHaskell98 -XCPP -i 'Use camelCase' -i 'Use String' -i 'Use string literal' -i 'Use list comprehension' | ||
12 | VERSION=0.6.1 | ||
13 | |||
14 | .PHONY: all clean doc install debian test | ||
15 | |||
16 | all: test report.html doc dist/build/libHSopenpgp-$(VERSION).a dist/openpgp-$(VERSION).tar.gz | ||
17 | |||
18 | install: dist/build/libHSopenpgp-$(VERSION).a | ||
19 | cabal install | ||
20 | |||
21 | debian: debian/control | ||
22 | |||
23 | test: tests/suite | ||
24 | tests/suite | ||
25 | |||
26 | tests/suite: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs Data/OpenPGP/Arbitrary.hs | ||
27 | ghc --make $(GHCFLAGS) -o $@ $^ | ||
28 | |||
29 | Data/OpenPGP/Arbitrary.hs: Data/OpenPGP.hs Arbitrary.patch | ||
30 | derive -d Arbitrary -m Data.OpenPGP.Arbitrary -iData.OpenPGP -iData.OpenPGP.Internal -iTest.QuickCheck -iTest.QuickCheck.Instances -iData.Word -o $@ Data/OpenPGP.hs | ||
31 | patch $@ Arbitrary.patch | ||
32 | |||
33 | report.html: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs | ||
34 | -hlint $(HLINTFLAGS) --report $^ | ||
35 | |||
36 | doc: dist/doc/html/openpgp/index.html README | ||
37 | |||
38 | README: openpgp.cabal | ||
39 | tail -n+$$(( `grep -n ^description: $^ | head -n1 | cut -d: -f1` + 1 )) $^ > .$@ | ||
40 | head -n+$$(( `grep -n ^$$ .$@ | head -n1 | cut -d: -f1` - 1 )) .$@ > $@ | ||
41 | -printf ',s/ //g\n,s/^.$$//g\nw\nq\n' | ed $@ | ||
42 | $(RM) .$@ | ||
43 | |||
44 | # XXX: Is there a way to make this just pass through $(GHCFLAGS) | ||
45 | ifdef CEREAL | ||
46 | dist/doc/html/openpgp/index.html: dist/setup-config Data/OpenPGP.hs Data/OpenPGP/Internal.hs | ||
47 | cabal haddock --hyperlink-source --haddock-options="--optghc=-DCEREAL" | ||
48 | else | ||
49 | dist/doc/html/openpgp/index.html: dist/setup-config Data/OpenPGP.hs Data/OpenPGP/Internal.hs | ||
50 | cabal haddock --hyperlink-source | ||
51 | endif | ||
52 | |||
53 | ifdef CEREAL | ||
54 | dist/setup-config: openpgp.cabal | ||
55 | -printf '1c\nname: openpgp-cereal\n.\n,s/binary >= 0.6.4.0,$$/cereal,/g\nw\nq\n' | ed openpgp.cabal | ||
56 | cabal configure --enable-tests | ||
57 | else | ||
58 | dist/setup-config: openpgp.cabal | ||
59 | cabal configure --enable-tests | ||
60 | endif | ||
61 | |||
62 | clean: | ||
63 | -printf '1c\nname: openpgp\n.\n,s/cereal,$$/binary >= 0.6.4.0,/g\nw\nq\n' | ed openpgp.cabal | ||
64 | find -name '*.o' -o -name '*.hi' | xargs $(RM) | ||
65 | $(RM) sign verify keygen tests/suite Data/OpenPGP/Arbitrary.hs | ||
66 | $(RM) -r dist dist-ghc | ||
67 | |||
68 | debian/control: openpgp.cabal | ||
69 | cabal-debian --update-debianization | ||
70 | |||
71 | dist/build/libHSopenpgp-$(VERSION).a: openpgp.cabal dist/setup-config Data/OpenPGP.hs Data/OpenPGP/Internal.hs | ||
72 | cabal build --ghc-options="$(GHCFLAGS)" | ||
73 | |||
74 | dist/openpgp-$(VERSION).tar.gz: openpgp.cabal dist/setup-config README Data/OpenPGP.hs Data/OpenPGP/Internal.hs | ||
75 | cabal check | ||
76 | cabal sdist | ||