forked from aesiniath/http-streams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
156 lines (125 loc) · 3.24 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
all: snippet
#
# The name of the binary(ies) you want to build if `make` is invoked without an
# explicit target - which is so important it gets to go on the first line. On
# to business: the purpose of this Makefile is to let you build Haskell
# programs with a minimum of fuss. You should be able to type
#
# $ make
#
# and have ./stormy be built; this will happen if and only if there is a
# Haskell source file with a lower-cased named and a main in it by that name in
# src/. This also works with lower-cased source files in tests/:
#
# $ make check
#
# will build ./check from tests/check.hs.
#
# As wired, src/ binaries are built tight and tests/ binaries are built with
# profiling enabled.
#
#
# GHC makes a lot of temporary files. Where to put them?
#
BUILDDIR=/tmp/build/http-streams
#
# Haskell compiler and build options. As specified here we always build with
# the full threaded runtime and GHC profiling enabled, 'cause, you need those
# things.
#
GHC=ghc \
-rtsopts \
-O2 \
-threaded \
-Wall \
-fwarn-tabs \
-fno-warn-missing-signatures \
-fno-warn-unused-binds
#
# The rest is all machinery. Here we do the V=1 trick to set verbosity.
#
ifdef V
MAKEFLAGS=-R
else
MAKEFLAGS=-s -R
REDIRECT=2>/dev/null
endif
.PHONY: all test tests config
#
# Source files, main and testing
#
CORE_SOURCES=$(shell find src -name '*.hs' -type f)
TEST_SOURCES=$(shell find tests -name '*.hs' -type f)
%: $(BUILDDIR)/%.bin
@/bin/echo -e "CP\t$@"
cp $< $@
$(BUILDDIR)/%.bin: config.h src/%.hs $(CORE_SOURCES) tags
@if [ ! -d $(BUILDDIR) ] ; then /bin/echo -e "MKDIR\t$(BUILDDIR)" ; mkdir -p $(BUILDDIR) ; fi
@/bin/echo -e "GHC\t$@"
$(GHC) --make \
-outputdir $(BUILDDIR)/$* \
-i"$(BUILDDIR):src" \
-I"." \
-o $@ \
src/$*.hs
@/bin/echo -e "STRIP\t$@"
strip -s $@
tags: $(CORE_SOURCES) $(TEST_SOURCES)
@/bin/echo -e "CTAGS\ttags"
@hothasktags $^ > tags $(REDIRECT)
#
# Build test suite code
#
tests: config check
$(BUILDDIR)/%.bin: config.h tests/%.hs $(CORE_SOURCES) $(TEST_SOURCES) tags
@if [ ! -d $(BUILDDIR) ] ; then /bin/echo -e "MKDIR\t$(BUILDDIR)" ; mkdir -p $(BUILDDIR) ; fi
@/bin/echo -e "GHC\t$@"
$(GHC) --make \
-prof -fprof-auto \
-outputdir $(BUILDDIR)/tests \
-i"$(BUILDDIR):src:tests" \
-I"." \
-o $@ \
tests/$*.hs
@/bin/echo -e "STRIP\t$@"
strip -s $@
#
# Run tests directly. If using inotify, invoke instead as follows:
#
# $ inotifymake tests -- ./check
#
test: config check
@/bin/echo -e "EXEC\tcheck"
./check
#
# Cleanup, etc
#
clean:
@/bin/echo -e "RM\ttempory files"
-rm -f *.hi *.o
-rm -f *.prof
-rm -rf $(BUILDDIR)
-rm -rf dist/
@/bin/echo -e "RM\texecutables"
-ls src tests | grep ^[[:lower:]]*.hs | xargs basename -s .hs -a | xargs rm -f
@if [ -f tags ] ; then /bin/echo -e "RM\ttags" ; rm tags ; fi
-rm -f config.h
format: $(CORE_SOURCES) $(TEST_SOURCES)
stylish-haskell -i $^
#
# Specific to building http-streams
#
config: config.h
config.h: Setup.hs http-streams.cabal
@/bin/echo -e "CABAL\tconfigure"
cabal configure --enable-tests
doc: config.h $(CORE_SOURCES) all
@/bin/echo -e "CABAL\thaddock"
cabal haddock
dist: config.h
cabal sdist
tests/snippet.hs:
@/bin/echo -e "Make a symlink from snippet.hs -> whichever code you wish to run"
@false
install: config.h all
cabal install --force-reinstalls