forked from discoproject/disco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
167 lines (124 loc) · 4.07 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
157
158
159
160
161
162
163
164
165
166
167
DISCO_VERSION = 0.4
DISCO_RELEASE = 0.4
# standard make installation variables
sysconfdir = /etc
prefix = /usr/local
exec_prefix = $(prefix)
localstatedir = $(prefix)/var
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
SHELL = /bin/sh
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_TREE = cp -r
# installation directories
TARGETBIN = $(DESTDIR)$(bindir)
TARGETLIB = $(DESTDIR)$(libdir)/disco
TARGETCFG = $(DESTDIR)$(sysconfdir)/disco
TARGETSRV = $(DESTDIR)$(localstatedir)/disco
# options to python and sphinx for building the lib and docs
PYTHONENVS = DISCO_VERSION=$(DISCO_VERSION) DISCO_RELEASE=$(DISCO_RELEASE)
SPHINXOPTS = "-D version=$(DISCO_VERSION) -D release=$(DISCO_RELEASE)"
# used to choose which conf file will be generated
UNAME = $(shell uname)
# utilities used for building disco
ERL = erl
ERLC = erlc
EOPT = -W
DIALYZER = dialyzer
TYPER = typer
PYTHON = python
PY_INSTALL = $(PYTHONENVS) $(PYTHON) setup.py install --root=$(DESTDIR)/ --prefix=$(prefix)
RE_VERSION = sed -e s/%DISCO_VERSION%/$(DISCO_VERSION)/
WWW = master/www
EBIN = master/ebin
ESRC = master/src
ETEST = master/test
ELIBS = $(ESRC) $(ESRC)/ddfs $(ESRC)/mochiweb
ESOURCES = $(foreach lib,$(ELIBS),$(wildcard $(lib)/*.erl))
EHEADERS = $(foreach lib,$(ELIBS),$(wildcard $(lib)/*.hrl))
EAPPS = $(subst $(ESRC),$(EBIN),$(ELIBS))
EOBJECTS = $(subst $(ESRC),$(EBIN),$(ESOURCES:.erl=.beam))
ETARGETS = $(foreach object,$(EOBJECTS),$(TARGETLIB)/$(object))
ETESTSOURCES = $(wildcard $(ETEST)/*.erl)
ETESTOBJECTS = $(ETESTSOURCES:.erl=.beam)
EPLT = .dialyzer_plt
.PHONY: all master clean distclean doc docclean doctest
.PHONY: install \
install-master \
install-core \
install-node \
install-discodb \
install-discodex \
install-examples \
install-tests
.PHONY: test dialyzer typer
all: master
master: $(EBIN)/disco.app $(EOBJECTS)
clean:
- rm -Rf $(EBIN) $(ETESTOBJECTS)
- rm -Rf lib/build lib/disco.egg-info
- rm -Rf doc/.build
distclean: clean
- rm -Rf $(EPLT)
doc:
(cd doc && $(MAKE) SPHINXOPTS=$(SPHINXOPTS) html)
docclean:
(cd doc && $(MAKE) SPHINXOPTS=$(SPHINXOPTS) clean)
doctest:
(cd doc && $(MAKE) SPHINXOPTS=$(SPHINXOPTS) doctest)
install: install-core install-master install-node
install-core:
(cd lib && $(PY_INSTALL))
install-discodb:
(cd contrib/discodb && $(PY_INSTALL))
install-discodex:
(cd contrib/discodex && $(PY_INSTALL))
install-examples: $(TARGETLIB)/examples
install-master: master \
$(TARGETBIN)/disco $(TARGETBIN)/ddfs \
$(TARGETLIB)/$(WWW) \
$(TARGETCFG)/settings.py \
$(TARGETLIB)/$(EBIN)/disco.app \
$(TARGETSRV)/ddfs
install-node: master $(ETARGETS)
install-tests: $(TARGETLIB)/ext $(TARGETLIB)/tests
uninstall:
- rm -f $(TARGETBIN)/disco $(TARGETBIN)/ddfs
- rm -Rf $(TARGETCFG) $(TARGETLIB) $(TARGETSRV)
test: master $(ETESTOBJECTS)
$(ERL) -noshell -pa $(ETEST) $(EAPPS) -s master_tests main -s init stop
dialyzer: EOPT = -W +debug_info
dialyzer: $(EPLT)
$(DIALYZER) --get_warnings -Wunmatched_returns -Werror_handling -Wbehaviours --plt $(EPLT) --src -r $(ESRC)
typer: $(EPLT)
$(TYPER) --plt $(EPLT) -r $(ESRC)
$(EBIN):
mkdir $(EAPPS)
$(EBIN)/disco.app: $(ESRC)/disco.app | $(EBIN)
- $(RE_VERSION) $< > $@
$(EBIN)/%.beam: $(ESRC)/%.erl $(EHEADERS) | $(EBIN)
$(ERLC) $(EOPT) -o $(dir $@) $<
$(ETEST)/%.beam: $(ETEST)/%.erl
$(ERLC) $(EOPT) -o $(dir $@) $<
$(EPLT):
$(DIALYZER) --build_plt --output_plt $(EPLT) \
--apps stdlib kernel erts mnesia compiler crypto inets xmerl ssl syntax_tools
$(TARGETBIN):
$(INSTALL) -d $(TARGETBIN)
$(TARGETBIN)/%: bin/% | $(TARGETBIN)
$(INSTALL_PROGRAM) $< $@
$(TARGETCFG):
$(INSTALL) -d $(TARGETCFG)
$(TARGETCFG)/settings.py: | $(TARGETCFG)
(TARGETLIB=$(TARGETLIB) TARGETSRV=$(TARGETSRV) \
conf/gen.settings.sys-$(UNAME) > $@ && chmod 644 $@)
$(TARGETLIB):
$(INSTALL) -d $(addprefix $(TARGETLIB)/,$(EAPPS))
$(TARGETLIB)/$(EBIN)/%: $(EBIN)/% | $(TARGETLIB)
$(INSTALL_DATA) $< $@
$(TARGETLIB)/%: % | $(TARGETLIB)
$(INSTALL_TREE) $< $@
$(TARGETSRV)/ddfs:
$(INSTALL) -d $(TARGETSRV)/ddfs