forked from EA31337/EA31337
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
227 lines (180 loc) · 6.49 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
SHELL:=/usr/bin/env bash
.PHONY: all test compile-mql4 compile-mql5 requirements \
set-none set-testing \
set-lite set-advanced set-rider \
set-lite-release set-advanced-release set-rider-release \
set-lite-backtest set-advanced-backtest set-rider-backtest \
set-lite-optimize set-advanced-optimize set-rider-optimize \
clean clean-src clean-releases \
EA Lite Advanced Rider \
Release Lite-Release Advanced-Release Rider-Release \
Backtest Lite-Backtest Advanced-Backtest Rider-Backtest \
Optimize Lite-Optimize Advanced-Optimize Rider-Optimize \
All Lite-All Advanced-All Rider-All
MTE=metaeditor64.exe
MTV=5.0.0.2361
SRC=src
MQL4=$(wildcard $(SRC)/*.mq4)
MQL5=$(wildcard $(SRC)/*.mq5)
EA=EA31337
EX4=$(SRC)/$(EA).ex4
EX5=$(SRC)/$(EA).ex5
VER=v$(shell grep 'define ea_version' $(SRC)/include/common/define.h | grep -o '[0-9].*[0-9]')
FILE=$(lastword $(MAKEFILE_LIST)) # Determine this Makefile's path.
OUT=.
MKFILE=$(abspath $(lastword $(MAKEFILE_LIST)))
CWD=$(notdir $(patsubst %/,%,$(dir $(MKFILE))))
WINEDEBUG=fixme-all
requirements:
type -a git ex wine64 &> /dev/null
Lite: $(OUT)/$(EA)-Lite-%.ex4
Advanced: $(OUT)/$(EA)-Advanced-%.ex4
Rider: $(OUT)/$(EA)-Rider-%.ex4
Lite-Release: $(OUT)/$(EA)-Lite-Release-%.ex4
Advanced-Release: $(OUT)/$(EA)-Advanced-Release-%.ex4
Rider-Release: $(OUT)/$(EA)-Rider-Release-%.ex4
Lite-Backtest: $(OUT)/$(EA)-Lite-Backtest-%.ex4
Advanced-Backtest: $(OUT)/$(EA)-Advanced-Backtest-%.ex4
Rider-Backtest: $(OUT)/$(EA)-Rider-Backtest-%.ex4
Lite-Optimize: $(OUT)/$(EA)-Lite-Optimize-%.ex4
Advanced-Optimize: $(OUT)/$(EA)-Advanced-Optimize-%.ex4
Rider-Optimize: $(OUT)/$(EA)-Rider-Optimize-%.ex4
Lite-All: Lite Lite-Release Lite-Backtest Lite-Optimize
Advanced-All: Advanced Advanced-Release Advanced-Backtest Advanced-Optimize
Rider-All: Rider Rider-Release Rider-Backtest Rider-Optimize
All: requirements $(MTE) Lite-All Advanced-All Rider-All
test: requirements set-mode $(MTE)
wine64 $(MTE) .exe /s /i:$(SRC) /mql4 $(MQL4)
wine64 $(MTE) /s /i:$(SRC) /mql5 $(MQL4)
$(MTE):
curl -LO https://github.com/EA31337/MT-Platforms/releases/download/$(MTV)/mt-$(MTV).zip
unzip -o mt-$(MTV).zip */$(MTE)
cp -v */$(MTE) .
# E.g.: make set-mode MODE="__advanced__"
set-mode:
ifdef MODE
test -w .git && git checkout -- $(SRC)/include/common/mode.h || true
ex +"%s@^\zs.*\ze#define \($(MODE)\)@@g" -scwq! $(SRC)/include/common/mode.h
endif
set-none:
@echo Reverting modes.
test -w .git && git checkout -- $(SRC)/include/common/mode.h || true
test -w $(SRC) && ex +":g@^#define@s@^@//" -scwq! $(SRC)/include/common/mode.h || true
set-lite: set-none
@$(MAKE) -f $(FILE)
set-advanced: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__advanced__"
set-rider: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__rider__"
set-lite-release: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__release__"
set-advanced-release: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__release__\|__advanced__"
set-rider-release: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__release__\|__rider__"
set-lite-backtest: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__backtest__"
set-advanced-backtest: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__backtest__\|__advanced__"
set-rider-backtest: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__backtest__\|__rider__"
set-lite-optimize: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__optimize__"
set-advanced-optimize: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__optimize__\|__advanced__"
set-rider-optimize: set-none
@$(MAKE) -f $(FILE) set-mode MODE="__optimize__\|__rider__"
set-testing:
@$(MAKE) -f $(FILE) set-mode MODE="__testing__"
clean-all: clean-src
clean-src:
@echo Cleaning src...
find $(SRC)/ -maxdepth 1 '(' -name '*.ex4' -or -name '*.ex5' ')' -delete -print
EA: $(MTE) \
clean-all \
$(OUT)/$(EA)-Lite-%.ex4 \
$(OUT)/$(EA)-Advanced-%.ex4 \
$(OUT)/$(EA)-Rider-%.ex4
Release: $(MTE) \
clean-all \
$(OUT)/$(EA)-Lite-Release-%.ex4 \
$(OUT)/$(EA)-Advanced-Release-%.ex4 \
$(OUT)/$(EA)-Rider-Release-%.ex4
Backtest: $(MTE) \
clean-all \
$(OUT)/$(EA)-Lite-Backtest-%.ex4 \
$(OUT)/$(EA)-Advanced-Backtest-%.ex4 \
$(OUT)/$(EA)-Rider-Backtest-%.ex4
Optimize: $(MTE) \
clean-all \
$(OUT)/$(EA)-Lite-Optimize-%.ex4 \
$(OUT)/$(EA)-Advanced-Optimize-%.ex4 \
$(OUT)/$(EA)-Rider-Optimize-%.ex4
compile-mql4: requirements $(MTE) $(SRC)/$(EA).mq4 $(SRC)/include/common/mode.h clean-src
file='$(MQL4)'; wine64 $(MTE) /log:CON /compile:"$${file//\//\\}" /inc:"$(SRC)" || true
test -s $(SRC)/$(EA).ex4 && echo $(MQL4) compiled.
compile-mql5: requirements $(MTE) $(SRC)/$(EA).mq4 $(SRC)/include/common/mode.h clean-src
file='$(MQL5)'; wine64 $(MTE) /log:CON /compile:"$${file//\//\\}" /inc:"$(SRC)" || true
test -s $(SRC)/$(EA).ex5 && @echo $(MQL5) compiled.
$(OUT)/$(EA)-Lite-%.ex4: \
set-lite \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Lite-$(VER).ex4"
$(OUT)/$(EA)-Advanced-%.ex4: \
set-advanced \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Advanced-$(VER).ex4"
$(OUT)/$(EA)-Rider-%.ex4: \
set-rider \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Rider-$(VER).ex4"
$(OUT)/$(EA)-Lite-Release-%.ex4: \
set-lite-release \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Lite-Release-$(VER).ex4"
$(OUT)/$(EA)-Advanced-Release-%.ex4: \
set-advanced-release \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Advanced-Release-$(VER).ex4"
$(OUT)/$(EA)-Rider-Release-%.ex4: \
set-rider-release \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Rider-Release-$(VER).ex4"
$(OUT)/$(EA)-Lite-Backtest-%.ex4: \
set-lite-backtest \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Lite-Backtest-$(VER).ex4"
$(OUT)/$(EA)-Advanced-Backtest-%.ex4: \
set-advanced-backtest \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Advanced-Backtest-$(VER).ex4"
$(OUT)/$(EA)-Rider-Backtest-%.ex4: \
set-rider-backtest \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Rider-Backtest-$(VER).ex4"
$(OUT)/$(EA)-Lite-Optimize-%.ex4: \
set-lite-optimize \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Lite-Optimize-$(VER).ex4"
$(OUT)/$(EA)-Advanced-Optimize-%.ex4: \
set-advanced-optimize \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Advanced-Optimize-$(VER).ex4"
$(OUT)/$(EA)-Rider-Optimize-%.ex4: \
set-rider-optimize \
compile-mql4 \
set-none
cp -v "$(EX4)" "$(OUT)/$(EA)-Rider-Optimize-$(VER).ex4"
mt4-install:
install -v "$(EX4)" "$(shell find ~/.wine -name terminal.exe -execdir pwd ';' -quit)/MQL4/Experts"