-
Notifications
You must be signed in to change notification settings - Fork 40
/
Makefile
250 lines (202 loc) · 9.65 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
DEFAULT_GOAL := all
include externals.mk
MANREP= man/
MANSCRIPTREP = $(MANREP)scripts/
MANKAPPAMODELSREP = $(MANREP)examples/
MANIMGREP = $(MANREP)img/
GENIMG = generated_img
MANGENREP = $(MANREP)$(GENIMG)/
RANDOM_NUMBER = $(shell bash -c 'echo $$RANDOM')
SCRIPTSSOURCE = $(wildcard $(MANSCRIPTREP)*.sh)
SCRIPTSWITNESS = $(SCRIPTSSOURCE:.sh=.witness) $(MANGENREP)version.tex
MODELS = $(wildcard $(MANKAPPAMODELSREP)*.ka)
RESOURCES_HTML=$(wildcard gui/shared/*.js) $(wildcard gui/viz/*.js) $(wildcard gui/viz/*.css) gui/favicon.ico gui/package.json
APP_EXT?=cdn
INDEX_HTML=gui/use-$(APP_EXT).html
ifeq ($(APP_EXT),local)
SITE_EXTRAS= build/site/external build/site/external/bootstrap-$(BOOTSTRAP_VERSION)-dist build/site/external/codemirror-$(CODEMIRROR_VERSION) build/site/external/dagre-d3 build/site/external/d3 build/site/external/jquery
else
SITE_EXTRAS=
endif
.PHONY: all agents clean check build-tests doc clean_doc debug
.PHONY: temp-clean-for-ignorant-that-clean-must-be-done-before-fetch
.PHONY: profiling kappalib install-lib
.PHONY: Kappapp Kappapp.tar.gz KappaBin KappaBin.zip Kappapp.app
.PRECIOUS: $(SCRIPTSWITNESS)
$(MANGENREP): $(SCRIPTSSOURCE) $(MODELS)
rm -rf $@
mkdir $@
$(MANGENREP)version.tex: $(MANREP)version.tex.skel $(wildcard .git/refs/heads/*) $(MANGENREP)
sed -e s/'\(.*\)\".*tag: \([^,\"]*\)[,\"].*/\1\"\2\"'/g $< | \
sed -e 's/\$$Format:%D\$$'/"$$(git describe --always --dirty || echo unkown)"/ > $@
build/site: $(RESOURCES_HTML)
mkdir -p $@
cp $^ $@
build/site/external: build/site
mkdir -p $@
build/site/external/bootstrap-$(BOOTSTRAP_VERSION)-dist: externals.mk
mkdir -p build/site/external
FILE=$$(mktemp -t bootstrapXXXX); \
curl -LsS -o $$FILE https://github.com/twbs/bootstrap/releases/download/v$(BOOTSTRAP_VERSION)/bootstrap-$(BOOTSTRAP_VERSION)-dist.zip && \
rm -rf $@ && unzip -d $(dir $@) $$FILE && rm $$FILE
touch $@
build/site/external/codemirror-$(CODEMIRROR_VERSION): externals.mk
mkdir -p build/site/external
FILE=$$(mktemp -t codemirrorXXXX); \
curl -LsS -o $$FILE http://codemirror.net/codemirror-$(CODEMIRROR_VERSION).zip &&\
rm -rf $@ && unzip -d $(dir $@) $$FILE && rm $$FILE
touch $@
build/site/external/d3: externals.mk
mkdir -p $@
curl -LsS -o $@/d3.v4.min.js http://d3js.org/d3.v4.min.js
build/site/external/dagre-d3: externals.mk
mkdir -p $@
curl -LsS -o $@/dagre-d3.min.js https://dagrejs.github.io/project/dagre-d3/latest/dagre-d3.min.js
build/site/external/jquery: externals.mk
mkdir -p $@
curl -LsS -o build/site/external/jquery/jquery.js https://code.jquery.com/jquery-$(JQUERY_VERSION).min.js
curl -LsS -o build/site/external/jquery/jquery-ui.min.js http://code.jquery.com/ui/$(JQUERY_UI_VERSION)/jquery-ui.min.js
%.bc.js: $(filter-out _build/,$(wildcard */*.ml*))
dune build $@
build/site/%.js: _build/default/gui/%.bc.js build/site
mkdir -p build/site
sed 's/.process.argv.length>0/.process.argv.length>1/' $< > $@
build/site/index.html: $(INDEX_HTML) $(SITE_EXTRAS) build/site/JsSim.js build/site/KaSimWorker.js build/site/KaSaWorker.js build/site/KaStorWorker.js build/site/KaMoHaWorker.js
cat $< | sed "s/RANDOM_NUMBER/$(RANDOM_NUMBER)/g" | sed "s/JQUERY_VERSION/$(JQUERY_VERSION)/g" | sed "s/JQUERY_UI_VERSION/$(JQUERY_UI_VERSION)/g" | sed "s/CODEMIRROR_VERSION/$(CODEMIRROR_VERSION)/g" | sed "s/BOOTSTRAP_VERSION/$(BOOTSTRAP_VERSION)/g" > $@
%.pdf: %.tex $(SCRIPTSWITNESS)
cd $(dir $<) && LOG=$$(mktemp -t pdflatexlogXXXX); rm -f *.aux && \
pdflatex -halt-on-error $(notdir $<) > $${LOG} 2>&1 && \
bibtex $(basename $(notdir $<)) >> $${LOG} 2>&1 && \
makeindex $(basename $(notdir $<)).idx >> $${LOG} 2>&1 && \
pdflatex -halt-on-error $(notdir $<) >> $${LOG} 2>&1 && \
pdflatex -halt-on-error $(notdir $<) >> $${LOG} 2>&1 && \
rm $${LOG} || { cat $${LOG}; rm $${LOG}; exit 2; }
%.htm: %.tex %.pdf
cd $(dir $<) && LOG=$$(mktemp -t htlatexlogXXXX); \
for file in *_img/*.pdf ; do pdftoppm $${file} $${file%.pdf} -png -singlefile ; done && \
htlatex $(notdir $<) "nma.cfg,htm,charset=utf-8,p-width" \
" -cunihtf -utf8" "" "-halt-on-error"> $${LOG} 2>&1 && \
rm $${LOG} || { cat $${LOG}; rm $${LOG}; exit 2; }
%.witness: %.sh $(MANGENREP) $(MODELS) %.gplot
cd $(dir $@) && KAPPABIN="$(CURDIR)/_build/install/default/bin/" sh $(notdir $<) > $(notdir $@) 2>&1 \
|| { cat $(notdir $@); rm $(notdir $@); exit 2; }
%.witness: %.sh $(MANGENREP) $(MODELS)
cd $(dir $@) && KAPPABIN="$(CURDIR)/_build/install/default/bin/" sh $(notdir $<) > $(notdir $@) 2>&1 \
|| { cat $(notdir $@); rm $(notdir $@); exit 2; }
doc: $(MANGENREP) man/KaSim_manual.pdf
doc_html: man/KaSim_manual.htm
dune build --only-packages kappa-library,kappa-binaries @doc
profiling:
@+$(MAKE) EXTRAFLAGS="-pkg landmarks.ppx -pkg landmarks" OCAML_LANDMARKS="auto,allocation" all
all:
dune build --only-packages kappa-library,kappa-binaries @install
dune build @install
# Note: removed ./bin symlink used by kappy, as it caused build issues with dune deleting files
mkdir -p bin
cp -f _build/install/default/bin/* bin/
agents:
dune build --only-packages kappa-library,kappa-binaries,kappa-agents @install
clean_ide:
rm -rf build/
rm -rf python/__pycache__/
clean_doc:
find man \( -not -name \*.tex -and -name KaSim_manual.\* \) -delete
find man \( -name \*.htm \) -delete
find man/scripts -name \*.witness -delete
rm -rf $(MANGENREP)
clean: clean_doc clean_ide
rm -rf build
dune clean
find . -name \*~ -delete
+$(MAKE) KAPPABIN="$(CURDIR)/_build/install/default/bin/" -C tests/integration clean
check:
dune runtest
@+$(MAKE) KAPPABIN="$(CURDIR)/_build/install/default/bin/" -C tests/integration clean
@+$(MAKE) KAPPABIN="$(CURDIR)/_build/install/default/bin/" -C tests/integration all
build-tests:
dune promote
@+$(MAKE) KAPPABIN="$(CURDIR)/_build/install/default/bin/" -C tests/integration build
# https://electronjs.org/docs/tutorial/application-distribution
build/Kappapp:
mkdir -p build/Kappapp
+$(MAKE) APP_EXT=local build/site/index.html
dune build --only-packages kappa-library,kappa-binaries,kappa-agents
FILE=$$(mktemp -t electronXXXX); \
curl -LsS -o $$FILE https://github.com/electron/electron/releases/download/v$(ELECTRON_VERSION)/electron-v$(ELECTRON_VERSION)-linux-x64.zip && \
unzip $$FILE -d build/Kappapp
mv build/Kappapp/electron build/Kappapp/kappapp
mv build/site build/Kappapp/resources/app
mkdir build/Kappapp/resources/bin
cp _build/install/default/bin/* build/Kappapp/resources/bin/
Kappapp:
# make clean before to be sure things are rebuilt TODO improve?
+$(MAKE) clean
+$(MAKE) build/Kappapp
build/Kappapp.tar.gz: build/Kappapp
tar czf $@ build/Kappapp
rm -r build/Kappapp
Kappapp.tar.gz: build/Kappapp.tar.gz
build/KappaBin:
mkdir -p build/KappaBin
+$(MAKE) APP_EXT=local build/site/index.html
dune build --only-packages kappa-library,kappa-binaries,kappa-agents
FILE=$$(mktemp -t electronXXXX); \
curl -LsS -o $$FILE https://github.com/electron/electron/releases/download/v$(ELECTRON_VERSION)/electron-v$(ELECTRON_VERSION)-win32-x64.zip && \
unzip $$FILE -d build/KappaBin
mv build/site build/KappaBin/resources/app
mv build/KappaBin/electron.exe build/KappaBin/Kappapp.exe
mkdir build/KappaBin/resources/bin
cp _build/default/core/main/KaSim.exe build/KappaBin/resources/bin/
cp _build/default/core/KaSa_rep/main/KaSa.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KaStor.exe build/KappaBin/resources/bin/
cp _build/default/core/odes/KaDE.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KappaSwitchman.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KaMoHa.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KaSimAgent.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KaSaAgent.exe build/KappaBin/resources/bin/
KappaBin:
# make clean before to be sure things are rebuilt TODO improve?
+$(MAKE) clean
+$(MAKE) build/KappaBin
build/KappaBin.zip: build/KappaBin
zip -y -r $@ build/KappaBin
rm -r build/KappaBin
KappaBin.zip: build/KappaBin.zip
build/Kappapp.app: build/Info.plist build/Kappa.icns
# do not call make clean here or deps will be erased
+$(MAKE) APP_EXT=local build/site/index.html
dune build --only-packages kappa-library,kappa-binaries,kappa-agents
+$(MAKE) build/Kappa.icns build/Info.plist
FILE=$$(mktemp -t electronXXXX); FOLDER=$$(mktemp -t electron_unzipedXXXX); \
curl -LsS -o $$FILE https://github.com/electron/electron/releases/download/v$(ELECTRON_VERSION)/electron-v$(ELECTRON_VERSION)-darwin-x64.zip && \
rm $$FOLDER && mkdir -p $$FOLDER && pushd $$FOLDER && unzip $$FILE && popd && mv $$FOLDER/Electron.app $@ && rm -r $$FOLDER
rm -r $@/Contents/Resources/*.lproj/
mkdir $@/Contents/Resources/bin
cp _build/install/default/bin/* $@/Contents/Resources/bin/
mv build/site $@/Contents/Resources/app/
mv build/Kappa.icns $@/Contents/Resources/
mv build/Info.plist $@/Contents/
Kappapp.app:
# make clean before to be sure things are rebuilt TODO improve?
+$(MAKE) clean
+$(MAKE) build/Kappapp.app
build/Info.plist: gui/Info.plist.skel $(wildcard .git/refs/heads/*)
mkdir -p build
sed -e s/'\(.*\)\".*tag: \([^,\"]*\)[,\"].*/\1\"\2\"'/g $< | \
sed -e 's/\$$Format:%D\$$'/"$$(git describe --always --dirty || echo unkown)"/ > $@
build/Kappa.iconset: gui/Kappa-Logo.png
mkdir -p build
rm -rf $@ && mkdir $@
sips -z 16 16 $< --out $@/icon_16x16.png
sips -z 32 32 $< --out $@/[email protected]
sips -z 32 32 $< --out $@/icon_32x32.png
sips -z 64 64 $< --out $@/[email protected]
sips -z 128 128 $< --out $@/icon_128x128.png
sips -z 256 256 $< --out $@/[email protected]
sips -z 256 256 $< --out $@/icon_256x256.png
sips -z 512 512 $< --out $@/[email protected]
sips -z 512 512 $< --out $@/icon_512x512.png
cp $< $@/[email protected]
build/Kappa.icns: build/Kappa.iconset
mkdir -p build
iconutil -c icns $<