forked from adoptware/pinball
-
Notifications
You must be signed in to change notification settings - Fork 5
/
helper.mk
executable file
·483 lines (375 loc) · 10 KB
/
helper.mk
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
#!/usr/bin/make -f
# -*- makefile -*-
# ex: set tabstop=4 noexpandtab:
# -*- coding: utf-8 -*
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright: Philippe Coval <https://purl.org/rzr/> - 2020+
#
project?=pinball
version?=0.0.0
V?=1
PINBALL_QUIT?=25000
export PINBALL_QUIT
profile?=${project}
export profile
resolution?=1024x1024
export resolution
sysroot?=${CURDIR}/tmp/sysroot
prefix?=/usr/local
base_libdir?=/lib
base_bindir?=/bin
bindir?=${prefix}/${base_bindir}
libdir?=${prefix}/${base_libdir}
exe?=${bindir}/${project}
# profile=pincab # Or overload arg
config_file?=extra/profile/${profile}/etc/${project}/${project}
config_destdir?=${DESTDIR}/etc/${project}
app_args=
app?=src/${project}
PINBALL_TABLE?=professor
export PINBALL_TABLE
trako_url?=https://github.com/rzr/trako#master
trako_branch?=0.2.0
sudo?=sudo
make?=./helper.mk
tarball?=${CURDIR}/../${project}_${version}.orig.tar.gz
export tarball
topdir?=.
autotools_files+=Makefile
autotools_files+=Makefile.in
autotools_files+=aclocal.m4
autotools_files+=compile
autotools_files+=confdefs.h
autotools_files+=config.status
autotools_files+=configure
autotools_files+=depcomp
autotools_files+=install-sh
autotools_files+=ltmain.sh
autotools_files+=pinconfig.h
autotools_files+=stamp-h1
DESTDIR?=/
default: help all
@echo "# $@: @^"
%:
@ls Makefile || ${make} Makefile
${MAKE} $@
help: helper.mk
@echo "## Usage:"
@echo "# ${<D}/${<F} help # This help"
@echo "# ${<D}/${<F} run # To run app"
@echo "# ${<D}/${<F} debi # To install on debian"
env:
@echo "# DISPLAY='${DISPLAY}'"
@echo "# GALLIUM_HUD='${GALLIUM_HUD}'"
@echo "# LIBGL_DEBUG='${LIBGL_DEBUG}'"
@echo "# LIBGL_DRIVERS_PATH='${LIBGL_DRIVERS_PATH}'"
@echo "# LIBGL_SHOW_FPS='${LIBGL_SHOW_FPS}'"
@echo "# MESA_DEBUG='${MESA_DEBUG}'"
@echo "# PINBALL_QUIT=${PINBALL_QUIT}"
@echo "# PINBALL_RENDER_DRIVER=${PINBALL_RENDER_DRIVER}"
@echo "# PINBALL_SPEED=${PINBALL_SPEED}"
@echo "# PINBALL_TABLE=${PINBALL_TABLE}"
@echo "# SDL_VIDEODRIVER='${SDL_VIDEODRIVER}'"
@echo "# WAYLAND_DEBUG='${WAYLAND_DEBUG}'"
@echo "# WAYLAND_DISPLAY='${WAYLAND_DISPLAY}'"
@echo "# XDG_RUNTIME_DIR='${XDG_RUNTIME_DIR}'"
config/%: %/config
@echo "# log: $@: $<"
test/%: %/test
@echo "# log: $@: $<"
rule/version:
@echo ${version}
-cat /etc/os-release
${CC} --version
${MAKE} --version
libtoolize --version
m4 --version
aclocal --version
autoheader --version
automake --version
autoconf --version
pkg-config --version
-libtool --version
.PHONY: bootstrap
bootstrap: rule/version
${make} clean/autotools
${make} configure
helper/%: Makefile
${MAKE} ${@F}
rule/make: Makefile
${MAKE}
run: ${app}
$< --version
$< --help
$< ${app_args}
run/quit: ${app}
SDL_AUDIODRIVER=null \
$<
start: run
Makefile: configure Makefile.in
@echo "# log: $@: $<"
${<D}/${<F}
stat -c '%y: %n' $^ $@
acinclude.m4:
@echo "# log: $@: $<"
stat -c '%y: %n' $^ $@ || ${make} rule/acinclude.m4
stat -c '%y: %n' $^ $@
rule/acinclude.m4: /usr/share/aclocal/sdl2.m4
@echo "# log: $@: $<"
cat $^ | tee -a ${@F}
/usr/share/aclocal/sdl2.m4:
@echo "# log: $@: $<"
echo "# TODO: $@ not found"
echo "# TODO: Please create acinclude.m4 from"
echo "# https://hg.libsdl.org/SDL/raw-file/d4d66a1891fc/sdl.m4"
config.status configure: acinclude.m4 pinconfig.h.in Makefile.in
@echo "# log: $@: $<"
autoconf --force
stat -c '%y: %n' $^ $@
INSTALL config.guess config.sub depcomp install-sh autom4te.cache: Makefile.am ltmain.sh pinconfig.h.in README
@echo "# log: $@: $^"
automake --add-missing --copy --force
stat -c '%y: %n' $^ $@
README: README.md
@echo "# log: $@: $<"
ls $@ || ln -fs $< $@
stat -c '%y: %n' $^ $@
AUTHORS ChangeLog NEWS: README
@echo "# log: $@: $<"
ls $@ || ln -fs $< $@
rule/autoupdate: configure.ac
@echo "# log: $@: $<"
${@F}
aclocal.m4: libltdl/m4
@echo "# log: $@: $<"
aclocal
stat -c '%y: %n' $^ $@
Makefile.in: Makefile.am INSTALL
automake
stat -c '%y: %n' $^ $@
pinconfig.h.in: aclocal.m4
@echo "# log: $@: $<"
autoheader --force
stat -c '%y: %n' $^ $@
libltdl/m4 compile missing ltmain.sh: configure.ac
@echo "# log: $@: $<"
libtoolize --ltdl --force --copy
stat -c '%y: %n' $^ $@
devel: ${app}
$< || gdb -tui $<
${app}: all
stat -c '%y: %n' $@
all: rule/make
${MAKE} $@
clean/autotools:
rm -rf ${autotools_files}
clean/libs:
find . -iname "lib*.a" -exec rm -v "{}" \;
config/bak:
-mv -f ${HOME}/.emilia/pinball ${HOME}/.emilia/pinball.bak
config/etc/install: ${config_destdir}/${project}
ls $<
config/etc/delete:
${sudo} rm -fv ${config_destdir}/${project}
${config_destdir}/${project}: ${config_file}
${sudo} install -d ${@D}
${sudo} install $< ${@}
config/install: ${config_file} config/bak
install -d ${HOME}/.emilia
install $< ${HOME}/.emilia/
config/test: config/etc/delete config/etc/install config/bak run
@echo "# log: $@: $<"
config/run: config/install run
@echo "# log: $@: $<"
pincab/run:
${make} config/run profile="${@D}"
debian/setup/devel:
${sudo} apt-get update || echo "TODO: fix system for $@"
${sudo} apt-get install -y \
build-essential \
dpkg-dev \
devscripts \
\
autoconf \
automake \
libtool-bin \
g++ \
libtool \
libgl1-mesa-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
make \
pkg-config \
libogg-dev \
libvorbis-dev \
libaa1-dev \
libtiff-dev \
libcppunit-dev \
\
docbook \
docbook-utils \
opensp \
pkg-config \
sgmlspl \
# EOL
debian/setup/x11: /etc/debian_version
${sudo} apt-get update
${sudo} apt-get install -y \
xinit \
x11-xserver-utils
# EOL
debian/setup: /etc/debian_version
${sudo} apt-get update
${sudo} apt-get install -y \
graphicsmagick-imagemagick-compat \
make \
sudo \
# EOL
debian/setup/package: debian/setup/devel
${sudo} apt-get update
${sudo} apt-get install -y \
debhelper \
docbook-utils \
sgmlspl \
# EOL
${tarball}:
tar cvfz "$@" \
--transform "s|^./|${project}-${version}/|" \
--exclude 'debian' --exclude-vcs \
.
@ls -l $@
rule/tarball: ${tarball}
@ls $^
rule/debuild: debian/rules
@which ${@F} || ${make} ${@D}/setup
[ "" != "${tarball}" ] || ${make} ${@D}/tarball
@ls "${tarball}" 2>/dev/null || ${make} ${@D}/tarball
${make} ${@D}/version
${@F} -S -us -uc \
|| echo "# error: Try './helper.mk debian/setup/devel' first"
${@F} -S -us -uc
${@F} -us -uc
rule/debi: rule/debuild
${sudo} ${@F}
ldd /usr/games/${project}
debi: rule/debi
@echo "# log: $@: $^"
setup: /etc/os-release
${make} debian/setup || @echo "TODO: add support for $<"
%.gz: %
gzip -9 $<
${project}.xpm/%: data/splash.png
install -d tmp/${@F}
convert -resize ${@F} -depth 8 -colors 14 $< tmp/${@F}/${@D}
${project}.tga/%: data/splash.png
install -d tmp/${@F}
convert -resize ${@F} -depth 8 -colors 14 + dither $< tmp/${@F}/${@D}
${project}.png/%: data/splash.png
install -d tmp/${@F}
convert -resize ${@F} $< tmp/${@F}/${@D}
${project}.jpg/%: data/splash.png
install -d tmp/${@F}
convert -resize ${@F} $< tmp/${@F}/${@D}
640x480/%:
${make} resolution=${@D} ${F}
tmp/${resolution}/${project}.jpg:
stat -c '%y: %n' $^ $@ || ${make} ${@F}/${resolution}
jpg: tmp/${resolution}/${project}.jpg
file $<
pincab:
${make} resolution=1024x1024 jpg
# https://wiki.debian.org/Grub/SplashImage
grub: extra/${project}.xpm.gz /etc/default/grub
echo "sudo install $<.gz /grub/splashimages/"
echo "splashimage=(hd0,0)/grub/$<"
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\""
/grub/splashimages/${project}.%: tmp/640x480/${project}.png
${sudo} install -d ${@D}
${sudo} install $< $@
grub2: /grub/splashimages/${project}.xpm.gz
ls $<
trako/%:
git clone --recursive --depth 1 ${trako_url} --branch ${trako_branch} trako
@echo "export CXXFLAGS='-DEM_TRAKO=1'"
@echo "rm -rf trako/.git; git add trako ; git commit -am 'WIP: Add trako'"
trako: trako/src/trako/macros.h trako/README.md
@grep TRAKO_VERSION "$<"
@echo "# $@: TODO: Pin version see $<"
trako/remove:
rm -rf trako
release/%: configure.ac
git tag -l "${@F}" \
|| echo "# error: Please run: git tag -d ${@F}"
git tag -l "upstream/${@F}" \
|| echo "error: Please run: git tag -d ${@F}"
sed -e "s|0.0.0|${@F}|g" -i $<
-git commit -sam "Release ${@F}"
git tag -sm "${project}-${@F}" "${@F}"
git archive \
--format=tar \
--prefix="${project}-${@F}/" \
${@F} \
| gzip -9n \
> ${project}-${@F}.tar.gz
sha256sum ${project}-${@F}.tar.gz > ${project}-${@F}.tar.gz.sha256sum
docker: docker-compose.yml
docker-compose up --build
render/%: ${app}
PINBALL_RENDER_DRIVER=${@F} $<
render: render/dummy
@echo "# $@: $^"
weston:
export XDG_RUNTIME_DIR=/run/user/$$(id -u)/
ls $${XDG_RUNTIME_DIR} || mkdir -p $${XDG_RUNTIME_DIR}/tmp
echo $${XDG_RUNTIME_DIR}
openvt -v -w -s -- su root -l -c "XDG_RUNTIME_DIR=$${XDG_RUNTIME_DIR} /usr/bin/weston-launch -- 2>&1 | tee /var/log/weston.log"
cat /var/log/weston.log
run/wayland: ${app}
unset DISPLAY; \
GALLIUM_HUD=fps \
LIBGL_DEBUG=1 \
LIBGL_DEBUG=verbose \
LIBGL_SHOW_FPS=1 \
MESA_DEBUG=1 \
SDL_VIDEODRIVER=${@F} \
WAYLAND_DEBUG=1 \
$<
check: ${app}
echo "# $@: $^";\
PINBALL_TABLE="${PINBALL_TABLE}" \
PINBALL_QUIT=25 \
${<D}/${<F} 2>&1 \
| grep -o '${project}: exit: .*'
pipe/%: ${app}
echo "# $@: $^";\
PINBALL_TABLE="${PINBALL_TABLE}" \
PINBALL_QUIT=25 \
${<D}/${<F} 2>&1 \
| ${@F}
less: pipe/less
echo "# $@: $^";\
configure/release: configure
${<D}/${<F} --without-debug --without-trako ${configure_options}
configure/debug: configure trako
${<D}/${<F} --with-debug --with-trako ${configure_options}
## AppImage
appdir?=${CURDIR}/tmp/AppDir
linux_deploy_url?=https://raw.githubusercontent.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
linux_deploy_file?=${HOME}/Downloads/$(shell basename -- "${linux_deploy_url}")
${appdir}: ./helper.mk
${make} install DESTDIR=$@
${linux_deploy_file}:
x-www-brower -o$@ ${linux_deploy_url}
chmod a+rx ${@}
-${@D}/${@F} --help
tmp/${project}.appimage.desktop: ${project}.desktop
cat $< | sed -e's|Exec=pinball|/usr/local/bin/pinball|g' > $@
appimage: ${linux_deploy_file} ${appdir}
${<D}/${<F} \
--appdir ${appdir} \
--desktop-file=${project}.desktop \
--executable=${appdir}/${exe} \
--icon-file=data/${project}.xpm \
--output appimage \
# EOL