summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile76
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 @@
1ifdef CEREAL
2GHCFLAGS=-Wall -O2 -DCEREAL -fno-warn-name-shadowing -XHaskell98
3else
4GHCFLAGS=-Wall -O2 -fno-warn-name-shadowing -XHaskell98
5endif
6
7ifdef TRAVIS
8GHCFLAGS+=-Werror
9endif
10
11HLINTFLAGS=-u -XHaskell98 -XCPP -i 'Use camelCase' -i 'Use String' -i 'Use string literal' -i 'Use list comprehension'
12VERSION=0.6.1
13
14.PHONY: all clean doc install debian test
15
16all: test report.html doc dist/build/libHSopenpgp-$(VERSION).a dist/openpgp-$(VERSION).tar.gz
17
18install: dist/build/libHSopenpgp-$(VERSION).a
19 cabal install
20
21debian: debian/control
22
23test: tests/suite
24 tests/suite
25
26tests/suite: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs Data/OpenPGP/Arbitrary.hs
27 ghc --make $(GHCFLAGS) -o $@ $^
28
29Data/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
33report.html: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs
34 -hlint $(HLINTFLAGS) --report $^
35
36doc: dist/doc/html/openpgp/index.html README
37
38README: 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)
45ifdef CEREAL
46dist/doc/html/openpgp/index.html: dist/setup-config Data/OpenPGP.hs Data/OpenPGP/Internal.hs
47 cabal haddock --hyperlink-source --haddock-options="--optghc=-DCEREAL"
48else
49dist/doc/html/openpgp/index.html: dist/setup-config Data/OpenPGP.hs Data/OpenPGP/Internal.hs
50 cabal haddock --hyperlink-source
51endif
52
53ifdef CEREAL
54dist/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
57else
58dist/setup-config: openpgp.cabal
59 cabal configure --enable-tests
60endif
61
62clean:
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
68debian/control: openpgp.cabal
69 cabal-debian --update-debianization
70
71dist/build/libHSopenpgp-$(VERSION).a: openpgp.cabal dist/setup-config Data/OpenPGP.hs Data/OpenPGP/Internal.hs
72 cabal build --ghc-options="$(GHCFLAGS)"
73
74dist/openpgp-$(VERSION).tar.gz: openpgp.cabal dist/setup-config README Data/OpenPGP.hs Data/OpenPGP/Internal.hs
75 cabal check
76 cabal sdist