-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
439 lines (359 loc) · 18 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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
.PHONY : default
default : help
MVN_WORKSPACE := .maven-workspace
MVN_CACHE := .maven-cache
# -----------------------------------
MVN_SETTINGS := settings.xml
MVN_PROPERTIES := -Dorg.ops4j.pax.url.mvn.localRepository="$(CURDIR)/$(MVN_WORKSPACE)" \
-Dorg.ops4j.pax.url.mvn.settings="$(CURDIR)/settings.xml"
MVN_RELEASE_CACHE_REPO := $(MVN_CACHE)
ifneq ($(MAKECMDGOALS),)
ifneq ($(MAKECMDGOALS), help)
ifneq ($(MAKECMDGOALS), dump-maven-cmd)
ifneq ($(MAKECMDGOALS), dump-gradle-cmd)
ifneq ($(MAKECMDGOALS), clean-website)
include .make/main.mk
assembly/BASEDIR := assembly
assembly/SOURCES : assembly/.compile-dependencies
include assembly/deps.mk
-include webui/.deps.mk
else
.SILENT: clean-website
endif
else
.SILENT: dump-gradle-cmd
endif
else
.SILENT: dump-maven-cmd
endif
else
.SILENT: help
endif
else
.SILENT: help
endif
USER_HOME := $(shell echo ~)
# instead of passing system properties "workspace" and "cache" we substitute them in the settings.xml file
# this is required for org.ops4j.pax.url.mvn.settings
settings.xml : settings.xml.in
cat $< | sed -e "s|\$${workspace}|$(CURDIR)/$(MVN_WORKSPACE)|g" \
-e "s|\$${cache}|$(CURDIR)/$(MVN_CACHE)|g" \
-e "s|\$${user\.home}|$(USER_HOME)|g" \
>$@
# -----------------------------------
.PHONY : dist-zip-linux
dist-zip-linux : pipeline2-$(assembly/VERSION)_linux.zip
.PHONY : dist-zip-mac
dist-zip-mac : pipeline2-$(assembly/VERSION)_mac.zip
.PHONY : dist-zip-win
dist-zip-win : pipeline2-$(assembly/VERSION)_windows.zip
.PHONY : dist-zip-minimal
dist-zip-minimal : pipeline2-$(assembly/VERSION)_minimal.zip
.PHONY : dist-deb
dist-deb : pipeline2-$(assembly/VERSION)_debian.deb
.PHONY : dist-rpm
dist-rpm : pipeline2-$(assembly/VERSION)_redhat.rpm
.PHONY : dist-docker-image
dist-docker-image : assembly/.compile-dependencies | .maven-init .group-eval
+$(EVAL) 'bash -c "unset MAKECMDGOALS && $(MAKE) -C assembly docker"'
# FIXME: $(cli/VERSION) does not always match version in assembly/pom.xml
.PHONY : dist-cli-deb
dist-cli-deb : cli-$(cli/VERSION)-linux_386.deb
.PHONY : dist-webui-zip
dist-webui-zip : assembly/.compile-dependencies
# see webui README for instructions on how to make a signed package for distribution
cd webui && \
./activator -Dmvn.settings.localRepository="file:$(CURDIR)/$(MVN_WORKSPACE)" clean universal:packageBin | $(MVN_LOG)
mv webui/target/universal/*zip .
.PHONY : dist-webui-deb
dist-webui-deb : assembly/.compile-dependencies
# see webui README for instructions on how to make a signed package for distribution
cd webui && \
./activator -Dmvn.settings.localRepository="file:$(CURDIR)/$(MVN_WORKSPACE)" clean debian:packageBin | $(MVN_LOG)
mv webui/target/*deb .
.PHONY : dist-webui-rpm
dist-webui-rpm : assembly/.compile-dependencies
# see webui README for instructions on how to make a signed package for distribution
cd webui && \
./activator -Dmvn.settings.localRepository="file:$(CURDIR)/$(MVN_WORKSPACE)" clean rpm:packageBin
mv webui/target/rpm/RPMS/noarch/*.rpm .
dev_launcher := assembly/target/dev-launcher/pipeline2
ifeq ($(shell uname), Darwin)
ifeq ($(shell uname -m),arm64)
dp2 := cli/build/bin/darwin_arm64/dp2
else
dp2 := cli/build/bin/darwin_amd64/dp2
endif
else
dp2 := cli/build/bin/linux_386/dp2
endif
.PHONY : dp2
dp2 : $(dp2)
.PHONY : run
run : $(dev_launcher)
$< local
.PHONY : run-with-osgi
run-with-osgi : $(dev_launcher)
$< local osgi shell
.PHONY : run-cli
run-cli :
echo "dp2 () { test -e $(dp2) || make $(dp2) && curl http://localhost:8181/ws/alive >/dev/null 2>/dev/null || make $(dev_launcher) && $(dp2) --debug false --starting true --exec_line $(CURDIR)/$(dev_launcher) --ws_timeup 30 \"\$$@\"; }"
echo '# Run this command to configure your shell: '
echo '# eval $$(make $@)'
.PHONY : run-webui
run-webui : webui/.compile-dependencies
if [ ! -d webui/dp2webui ]; then cp -r webui/dp2webui-cleandb webui/dp2webui ; fi
cd webui && \
./activator -Dmvn.settings.localRepository="file:$(CURDIR)/$(MVN_WORKSPACE)" run
.PHONY : run-docker
run-docker : dist-docker-image
docker run \
-e PIPELINE2_WS_HOST=0.0.0.0 \
-e PIPELINE2_WS_AUTHENTICATION=false \
-p 8181:8181 daisyorg/pipeline:latest-snapshot
.PHONY : run-docker-detached
run-docker-detached : dist-docker-image
docker run --name pipeline --detach \
-e PIPELINE2_WS_HOST=0.0.0.0 \
-e PIPELINE2_WS_AUTHENTICATION=false \
-p 8181:8181 daisyorg/pipeline:latest-snapshot
SCRIPTS := $(filter modules/scripts/%,$(MAVEN_MODULES)) \
modules/scripts-utils/daisy202-utils \
modules/scripts-utils/daisy3-utils \
modules/scripts-utils/dtbook-utils
.PHONY : $(addprefix run-,$(SCRIPTS))
$(addprefix run-,$(SCRIPTS)) : run-% : %/.compile-dependencies %/.test-dependencies
# not using -f because that causes log file to be saved at the wrong location
cd $(patsubst run-%,%,$@) && \
$(MVN) clean test -Prun-script-webserver
.PHONY : check
.PHONY : check-clientlib/go
check-clientlib/go :
$(MAKE) -C clientlib/go check
.PHONY : release
release : assembly/.release
.PHONY : $(addprefix check-,$(MODULES) $(MAVEN_AGGREGATORS))
$(addprefix check-,$(MODULES) $(MAVEN_AGGREGATORS)) : check-% : %/.last-tested
pipeline2-$(assembly/VERSION)_linux.zip \
: $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/assembly/$(assembly/VERSION)/assembly-$(assembly/VERSION)-linux.zip \
| .group-eval
+$(EVAL) cp $< $@
pipeline2-$(assembly/VERSION)_mac.zip \
: $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/assembly/$(assembly/VERSION)/assembly-$(assembly/VERSION)-mac.zip \
| .group-eval
+$(EVAL) cp $< $@
pipeline2-$(assembly/VERSION)_windows.zip \
: $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/assembly/$(assembly/VERSION)/assembly-$(assembly/VERSION)-win.zip \
| .group-eval
+$(EVAL) cp $< $@
pipeline2-$(assembly/VERSION)_minimal.zip \
: $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/assembly/$(assembly/VERSION)/assembly-$(assembly/VERSION)-minimal.zip \
| .group-eval
+$(EVAL) cp $< $@
pipeline2-$(assembly/VERSION)_debian.deb \
: $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/assembly/$(assembly/VERSION)/assembly-$(assembly/VERSION).deb \
| .group-eval
+$(EVAL) cp $< $@
pipeline2-$(assembly/VERSION)_redhat.rpm \
: $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/assembly/$(assembly/VERSION)/assembly-$(assembly/VERSION).rpm \
| .group-eval
+$(EVAL) cp $< $@
cli-$(cli/VERSION)-linux_386.deb \
: $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/assembly/$(assembly/VERSION)/assembly-$(assembly/VERSION)-cli.deb \
| .group-eval
+$(EVAL) cp $< $@
$(dev_launcher) : assembly/.compile-dependencies | .maven-init .group-eval
+$(call eval-for-host-platform,./assembly-make.sh,dev-launcher -- --without-persistence)
.SECONDARY : assembly/.install.deb
assembly/.install.deb : | .maven-init .group-eval
+$(call eval-for-host-platform,./assembly-make.sh,deb)
.SECONDARY : assembly/.install.rpm
assembly/.install.rpm : | .maven-init .group-eval
+$(call eval-for-host-platform,./assembly-make.sh,rpm)
.SECONDARY : assembly/.install-linux.zip
assembly/.install-linux.zip : | .maven-init .group-eval
+$(call eval-for-host-platform,./assembly-make.sh,zip-linux)
.SECONDARY : assembly/.install-minimal.zip
assembly/.install-minimal.zip : | .maven-init .group-eval
+$(call eval-for-host-platform,./assembly-make.sh,zip-minimal)
.SECONDARY : assembly/.install-mac.zip
assembly/.install-mac.zip : | .maven-init .group-eval
+$(call eval-for-host-platform,./assembly-make.sh,zip-mac)
.SECONDARY : assembly/.install-win.zip
assembly/.install-win.zip : | .maven-init .group-eval
+$(call eval-for-host-platform,./assembly-make.sh,zip-win)
.SECONDARY : assembly/.install-cli.deb
assembly/.install-cli.deb : | .maven-init .group-eval
+$(call eval-for-host-platform,./assembly-make.sh,deb-cli)
webui/.deps.mk : webui/build.sbt
if ! bash .make/make-webui-deps.mk.sh >$@; then \
echo "\$$(error $@ could not be generated)" >$@; \
fi
clean : clean-webui-deps
.PHONY : clean-webui-deps
clean-webui-deps :
rm -f webui/.deps.mk
# FIXME: hard code dependency because unpack-cli-{mac,win,linux} are inside profiles
# assembly/.compile-dependencies : \
# $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/cli/2.1.5-SNAPSHOT/cli-2.1.5-SNAPSHOT-darwin_amd64.zip \
# $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/cli/2.1.5-SNAPSHOT/cli-2.1.5-SNAPSHOT-linux_386.zip \
# $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/cli/2.1.5-SNAPSHOT/cli-2.1.5-SNAPSHOT-windows_386.zip
# assembly/.release : \
# $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/cli/2.1.5/cli-2.1.5-darwin_amd64.zip \
# $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/cli/2.1.5/cli-2.1.5-linux_386.zip \
# $(MVN_LOCAL_REPOSITORY)/org/daisy/pipeline/cli/2.1.5/cli-2.1.5-windows_386.zip
cli/build/bin/darwin_amd64/dp2 cli/build/bin/darwin_arm64/dp2 cli/build/bin/linux_386/dp2 : cli/.install
cli/.install : $(call rwildcard,cli/cli/,*.go) $(call rwildcard,cli/cli/,*.go.in) $(call rwildcard,cli/dp2/,*.go) $(call rwildcard,clientlib/go/,*.go)
.SECONDARY : cli/.install-darwin_amd64.zip cli/.install-linux_386.zip cli/.install-windows_386.zip
cli/.install-darwin_amd64.zip cli/.install-linux_386.zip cli/.install-windows_386.zip : cli/.install
.SECONDARY : cli/.install
cli/.install : | .maven-init .group-eval
+$(call eval-for-host-platform,.make/mvn-install.sh,$$(dirname $@))
updater/.install : $(call rwildcard,updater/,*)
.SECONDARY : updater/.install-darwin_amd64.zip updater/.install-linux_386.zip updater/.install-windows_386.zip
updater/.install-darwin_amd64.zip updater/.install-linux_386.zip updater/.install-windows_386.zip : updater/.install
.SECONDARY : libs/jstyleparser/.install-sources.jar
libs/jstyleparser/.install-sources.jar : libs/jstyleparser/.install
modules/scripts/dtbook-to-odt/.install-doc.jar : $(call rwildcard,modules/scripts/dtbook-to-odt/src/test/,*)
.SECONDARY : \
modules/braille/liblouis-utils/.install-mac.jar \
modules/braille/liblouis-utils/.install-linux.jar \
modules/braille/liblouis-utils/.install-windows.jar
modules/braille/liblouis-utils/.install-mac.jar \
modules/braille/liblouis-utils/.install-linux.jar \
modules/braille/liblouis-utils/.install-windows.jar: \
modules/braille/liblouis-utils/.install
.SECONDARY : \
modules/braille/libhyphen-utils/.install-mac.jar \
modules/braille/libhyphen-utils/.install-linux.jar \
modules/braille/libhyphen-utils/.install-windows.jar
modules/braille/libhyphen-utils/.install-mac.jar \
modules/braille/libhyphen-utils/.install-linux.jar \
modules/braille/libhyphen-utils/.install-windows.jar: \
modules/braille/libhyphen-utils/.install
.maven-init : | $(MVN_WORKSPACE)
# the purpose of the test is for making "make -B" not affect this rule (to speed thing up)
$(MVN_WORKSPACE) :
if ! [ -e $(MVN_WORKSPACE) ]; then \
mkdir -p $(MVN_CACHE) && \
cp -r $(MVN_CACHE) $@; \
fi
.PHONY : cache
cache :
if [ -e $(MVN_WORKSPACE) ]; then \
echo "Caching downloaded artifacts..." >&2 && \
rm -rf $(MVN_CACHE) && \
rsync -mr --exclude "*-SNAPSHOT" --exclude "maven-metadata-*.xml" $(MVN_WORKSPACE)/ $(MVN_CACHE); \
fi
clean : cache clean-workspace clean-old clean-website clean-dist clean-webui
.PHONY : clean-workspace
clean-workspace :
rm -rf $(MVN_WORKSPACE)
.PHONY : clean-dist
clean-dist :
rm -f *.zip *.deb *.rpm
# FIXME: run-webui should not store anything in USER_HOME !!
.PHONY : clean-webui
clean-webui :
rm -rf webui/target webui/dp2webui $(USER_HOME)/Library/Application\ Support/DAISY\ Pipeline\ 2\ Web\ UI
# clean files generated by previous versions of this Makefile
.PHONY : clean-old
clean-old :
rm -f .maven-modules
rm -f .effective-pom.xml
rm -f .gradle-pom.xml
rm -f .maven-build.mk
find . -name .deps.mk -exec rm -r "{}" \;
find . -name .build.mk -exec rm -r "{}" \;
find * -name .maven-to-install -exec rm -r "{}" \;
find * -name .maven-to-test -exec rm -r "{}" \;
find * -name .maven-to-test-dependents -exec rm -r "{}" \;
find * -name .maven-snapshot-dependencies -exec rm -r "{}" \;
find * -name .maven-effective-pom.xml -exec rm -r "{}" \;
find * -name .maven-dependencies-to-install -exec rm -r "{}" \;
find * -name .maven-dependencies-to-test -exec rm -r "{}" \;
find * -name .maven-dependencies-to-test-dependents -exec rm -r "{}" \;
find * -name .gradle-to-test -exec rm -r "{}" \;
find * -name .gradle-snapshot-dependencies -exec rm -r "{}" \;
find * -name .gradle-dependencies-to-install -exec rm -r "{}" \;
find * -name .gradle-dependencies-to-test -exec rm -r "{}" \;
.PHONY : gradle-clean
gradle-clean :
$(GRADLE) clean
TEMP_REPOS := modules/scripts/dtbook-to-daisy3/target/test/local-repo
.PHONY : go-offline
go-offline :
if [ -e $(MVN_WORKSPACE) ]; then \
for repo in $(TEMP_REPOS); do \
if [ -e $$repo ]; then \
rsync -mr --exclude "*-SNAPSHOT" --exclude "maven-metadata-*.xml" $$repo/ $(MVN_WORKSPACE); \
fi \
done \
fi
.PHONY : checked
checked :
touch $(addsuffix /.last-tested,$(MODULES))
poms : website/target/maven/pom.xml
website/target/maven/pom.xml : $(addprefix website/src/_data/,modules.yml api.yml versions.yml)
if which bundle >/dev/null || ! [ -f $@ ]; then \
$(MAKE) -C website target/maven/pom.xml; \
fi
.PHONY : website
website :
$(MAKE) -C website
.PHONY : serve-website publish-website clean-website
serve-website publish-website clean-website :
target=$@ && \
$(MAKE) -C website $${target%-website}
# this dependency is also defined in website/Makefile, but we need to repeat it here to enable the transitive dependency below
website serve-website publish-website : | $(addprefix website/target/maven/,javadoc doc sources xprocdoc)
$(addprefix website/target/maven/,javadoc doc sources xprocdoc) : website/target/maven/.compile-dependencies
rm -rf $@
target=$@ && \
$(MAKE) -C website $${target#website/}
.PHONY : dump-maven-cmd
dump-maven-cmd :
echo "mvn () { $(shell dirname "$$(which mvn)")/mvn --settings \"$(CURDIR)/$(MVN_SETTINGS)\" $(MVN_PROPERTIES) \"\$$@\"; }"
echo '# Run this command to configure your shell: '
echo '# eval $$(make $@)'
.PHONY : dump-gradle-cmd
dump-gradle-cmd :
echo M2_HOME=$(CURDIR)/$(TARGET_DIR)/.gradle-settings $(GRADLE) $(MVN_PROPERTIES)
.PHONY : help
help :
echo "make help:" >&2
echo " Print list of commands" >&2
echo "make check:" >&2
echo " Incrementally compile and test code" >&2
echo "make dist-deb:" >&2
echo " Incrementally compile code and package into a DEB" >&2
echo "make dist-rpm:" >&2
echo " Incrementally compile code and package into a RPM" >&2
echo "make dist-zip-linux:" >&2
echo " Incrementally compile code and package into a ZIP for Linux" >&2
echo "make dist-zip-mac:" >&2
echo " Incrementally compile code and package into a ZIP for MacOS" >&2
echo "make dist-zip-win:" >&2
echo " Incrementally compile code and package into a ZIP for Windows" >&2
echo "make dist-docker-image:" >&2
echo " Incrementally compile code and package into a Docker image" >&2
echo "make dist-cli-deb:" >&2
echo " Compile CLI and package into a DEB" >&2
echo "make dist-webui-deb:" >&2
echo " Compile Web UI and package into a DEB" >&2
echo "make dist-webui-rpm:" >&2
echo " Compile Web UI and package into a RPM" >&2
echo "make run:" >&2
echo " Incrementally compile code and run a server locally" >&2
echo "make run-webui:" >&2
echo " Compile and run web UI locally" >&2
echo "make run-cli:" >&2
echo " Get the command for compiling and running CLI locally" >&2
echo "make run-docker:" >&2
echo " Incrementally compile code and run a server inside a Docker container" >&2
echo "make run-modules/scripts/[SCRIPT]:" >&2
echo " Incrementally compile code and run a server with a single script" >&2
echo "make website:" >&2
echo " Build the website" >&2
echo "make dump-maven-cmd:" >&2
echo ' Get the Maven command used. To configure your shell: eval $$(make dump-maven-cmd)' >&2