/
core-build.mkf
129 lines (99 loc) · 3.55 KB
/
core-build.mkf
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
## -*- mode: Makefile; fill-column: 75; comment-column: 50; -*-
TEST_EBIN=$(APPDIR)/.eunit
TEST_FLAGS=-pa $(TEST_EBIN)
DEPS_DIR=$(CURDIR)/deps
EBIN_DIRS=$(wildcard $(DEPS_DIR)/*/ebin)
BASE_ERLCFLAGS=$(EBIN_DIRS:%= -pa %)
ERLCFLAGS=$(BASE_ERLCFLAGS) -pa $(BEAMDIR)
ERLFLAGS=-noshell $(ERLCFLAGS)
ASTDIR=$(SRCDIR)/ast
BOOTSTRAP_ERLFLAGS=-noshell -pa $(BEAMDIR) $(BASE_ERLCFLAGS)
COMP= $(ERL) $(ERLFLAGS) $(TEST_FLAGS) -s 'joxa-compiler' main \
-extra
SRCBEAMS = $(BEAMDIR)/joxa-cmp-util.beam \
$(BEAMDIR)/joxa-cmp-path.beam \
$(BEAMDIR)/joxa-cmp-ctx.beam \
$(BEAMDIR)/joxa-cmp-peg.beam \
$(BEAMDIR)/joxa-cmp-lexer.beam \
$(BEAMDIR)/joxa-cmp-ns.beam \
$(BEAMDIR)/joxa-cmp-call.beam \
$(BEAMDIR)/joxa-cmp-literal.beam \
$(BEAMDIR)/joxa-cmp-binary.beam \
$(BEAMDIR)/joxa-cmp-special-forms.beam \
$(BEAMDIR)/joxa-cmp-case.beam \
$(BEAMDIR)/joxa-cmp-spec.beam \
$(BEAMDIR)/joxa-cmp-expr.beam \
$(BEAMDIR)/joxa-cmp-defs.beam \
$(BEAMDIR)/joxa-cmp-joxa-info.beam \
$(BEAMDIR)/joxa-cmp-checks.beam \
$(BEAMDIR)/joxa-cmp-error-format.beam \
$(BEAMDIR)/joxa-cmp-parser.beam \
$(BEAMDIR)/joxa-compiler.beam \
$(BEAMDIR)/joxa-core.beam \
$(BEAMDIR)/joxa-shell.beam \
$(BEAMDIR)/joxa-records.beam \
$(BEAMDIR)/joxa-assert.beam \
$(BEAMDIR)/joxa-eunit.beam \
$(BEAMDIR)/joxa-lists.beam \
$(BEAMDIR)/joxa-otp.beam \
$(BEAMDIR)/joxa-otp-gen-server.beam \
$(BEAMDIR)/joxa-sort-topo.beam \
$(BEAMDIR)/joxa-concurrent-compiler.beam \
$(BEAMDIR)/joxa-cc-wkr.beam \
$(BEAMDIR)/joxa.beam \
$(BEAMDIR)/joxa-build-support.beam \
$(BEAMDIR)/joxa-otp-application.beam \
$(BEAMDIR)/joxa-otp-supervisor.beam
TESTBEAMS = $(TEST_EBIN)/joxa-test-let-match.beam \
$(TEST_EBIN)/joxa-test-multiple-namespaces.beam \
$(TEST_EBIN)/joxa-test-namespace-mutual-recursion.beam \
$(TEST_EBIN)/joxa-test-joxification.beam
.PHONY: all ootstrap clean \
jxa test build get-deps proper eunit \
cucumber shell bare-escript
.PRECIOUS: %/.d
FEATURES=./features/*.feature
all: build
## Build all the directories as task dependencies
%/.d:
@mkdir -p $(@D)
@touch $@
$(BEAMDIR)/%.beam: $(ASTDIR)/%.ast $(BEAMDIR)/jxa_bootstrap.beam $(BEAMDIR)/.d
$(ERL) $(BOOTSTRAP_ERLFLAGS) \
-s jxa_bootstrap do_bootstrap $(BEAMDIR) $< -s init stop
$(BEAMDIR)/%.beam: $(SRCDIR)/%.jxa $(BEAMDIR)/.d $(BEAMDIR)/joxa-compiler.beam
$(COMP) -o $(BEAMDIR) $<
$(TEST_EBIN)/%.beam: $(TESTDIR)/%.erl $(TEST_EBIN)/.d
$(ERLC) $(ERLCFLAGS) $(TEST_FLAGS) -o $(TEST_EBIN) $<
$(TEST_EBIN)/%.beam: $(TESTDIR)/%.jxa $(TEST_EBIN)/.d $(BEAMDIR)/joxa-compiler.beam
$(COMP) -o $(TEST_EBIN) $<
jxa: $(SRCBEAMS)
build:
$(REBAR) compile
get-deps:
$(REBAR) get-deps
shell: build $(TESTBEAMS)
$(ERL) $(ERLFLAGS) -s joxa main -s init stop
jxa-clean:
$(REBAR) skip_deps=true clean
rm -rf $(APPDIR)/joxa
rm -rf $(APPDIR)/.bootstrap
rm -rf $(APPDIR)/_build
rm -rf $(APPDIR)/erl_crash.dump
jxa-distclean: jxa-clean
rm -rf $(APPDIR)/deps
test: build proper eunit cucumber
eunit: $(SRCBEAMS) $(TESTBEAMS)
$(REBAR) skip_deps=true eunit
$(ERL) $(ERLFLAGS) $(TEST_FLAGS) -s 'joxa-build-support' main eunit $(BEAMDIR) -s init stop
$(ERL) $(ERLFLAGS) $(TEST_FLAGS) -s 'joxa-build-support' main eunit $(TEST_EBIN) -s init stop
proper: eunit $(SRCBEAMS) $(TESTBEAMS)
$(ERL) $(ERLFLAGS) $(TEST_FLAGS) -s 'joxa-build-support' main proper $(TEST_EBIN) -s init stop
cucumber: eunit $(SRCBEAMS) $(TESTBEAMS)
$(ERL) $(ERLFLAGS) $(TEST_FLAGS) -s 'joxa-build-support' main cucumberl $(CURDIR) -s init stop
bare-escript:
$(REBAR) skip_deps=true escriptize
escript: build bare-escript
bootstrap:
make -f $(CURDIR)/build-support/bootstrap.mkf
make