-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
495 lines (415 loc) · 12.6 KB
/
Copy pathMakefile
File metadata and controls
495 lines (415 loc) · 12.6 KB
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
484
485
486
487
488
489
490
491
492
493
494
495
# Makefile - maintain libre-bib
# ========================================
SHELL = /bin/bash
include package/ver.mak
# ========================================
mCheck = \
/sbin/mariadbd \
/usr/bin/libreoffice \
/usr/bin/make \
/usr/bin/mysql \
/usr/bin/pandoc \
/usr/bin/perl \
/usr/bin/php \
/usr/bin/pod2markdown \
/usr/bin/pod2pdf \
/usr/bin/sed \
/usr/bin/shellcheck \
/usr/bin/tidy \
/usr/bin/wget \
bin/$(mPhpUnit) \
bin/.phptidy-config.php \
bin/bash-com.inc \
bin/bash-com.test \
bin/bash-fmt \
bin/incver.sh \
bin/org2html.sh \
bin/phptidy.php \
bin/pre-commit \
bin/rm-trailing-sp \
bin/shfmt \
bin/shunit2.1 \
bin/sort-para.sh \
$(mDirLoConf)/biblio.dbf
mCheckProd = \
src/bin/bash-com.inc \
src/bin/bash-com.test \
src/bin/bib \
src/bin/bib-cmd.mak \
src/bin/bib-ref-new.inc \
src/bin/bib-ref-update.inc \
src/bin/bib-ref-update.php \
src/bin/bib-status.inc \
src/bin/bib-status.php \
src/bin/bib-style-save.inc \
src/bin/bib-style-update.inc \
src/bin/bib-style-update.php \
src/bin/convert-lo-2-bib.inc \
src/bin/convert-lo-2-bib.php \
src/bin/db-create.sh \
src/bin/export-lo-2-tcsv.inc \
src/bin/export-lo-2-tcsv.php \
src/bin/export-lo-2-txt.inc \
src/bin/export-lo-2-txt.php \
src/bin/fixup.sed \
src/bin/gen-conf-php.sh \
src/bin/import-tcsv-2-lo-db.inc \
src/bin/import-tcsv-2-lo-db.php \
src/bin/import-txt-2-lo.inc \
src/bin/import-txt-2-lo.php \
src/bin/phpunit \
src/bin/phpunit-10.5.64.phar \
src/bin/phpunit-11.5.56.phar \
src/bin/phpunit-12.5.33.phar \
src/bin/phpunit-13.2.6.phar \
src/bin/phpunit-8.5.53.phar \
src/bin/phpunit-9.6.35.phar \
src/bin/rm-old-files.sh \
src/bin/rm-old-tables.sh \
src/bin/sanity-check.sh \
src/bin/shunit2.1 \
src/bin/sort-para.sh \
src/bin/util.php \
src/bin/valid-conf.sh \
src/doc/example/biblio-note.txt \
src/doc/example/biblio.txt \
src/doc/example/conf.env \
src/doc/example/conf.env \
src/doc/example/example-outline.css \
src/doc/example/example-outline.html \
src/doc/example/example-outline.odt \
src/doc/example/example-outline.org \
src/doc/example/example.odt \
src/doc/example/key.txt \
src/doc/manual/doc.css \
src/doc/manual/libre-bib.html \
src/doc/manual/libre-bib.md \
src/doc/manual/libre-bib.org \
src/etc/bib-style.xml \
src/etc/bib-template.xml \
src/etc/biblio.csv \
src/etc/cite-new.xml \
src/etc/cite-update.xml \
src/etc/conf.env \
src/etc/conf.php \
src/etc/lo-schema.csv \
src/test/BibRefNewTest.php \
src/test/CallsTest.php \
src/test/BibRefUpdateTest.php \
src/test/BibStatusTest.php \
src/test/BibStyleSaveTest.php \
src/test/BibStyleUpdateTest.php \
src/test/ConvertLo2BibTest.php \
src/test/ExportLo2TcsvTest.php \
src/test/ExportLo2TxtTest.php \
src/test/ImportTcsv2LoDbTest.php \
src/test/ImportTxt2LoTest.php \
src/test/UtilTest.php \
src/test/bootstrap.php \
src/test/phpunit.xml \
src/test/sample/bib-cache/.admin.pass \
src/test/sample/bib-cache/.pass.tmp \
src/test/sample/bib-cache/.root.pass \
src/test/sample/bootstrap.sh \
src/test/sample/setup-sample-dir.sh \
src/test/sample/test-doc.odt \
src/test/sample/test-doc.odt.orig
# libreoffice
mDirLoConf = ~/.config/libreoffice/4/user/database/biblio
# libreoffice-flatpak
#mDirLoConf = ~/.var/app/org.libreoffice.LibreOffice/config/libreoffice/4/user/database/biblio"
# ========================================
usage :
@echo 'clean - remove tmp files'
@echo 'dist-clean - cleanup the build area'
@echo 'create-build-env - set up the build env'
@echo 'create-prod-env - generate files'
@echo 'test - run all tests'
@echo 'update - get latest from github'
@echo 'dev-ver - tag a development version'
@echo 'build - creates dist/'
@echo 'install - optional, copy dist/ to /opt/libre-bib/'
@echo 'rel-ver - do this before packaging a stable version'
@echo 'package'
@echo 'release'
# ========================================
.PHONY : clean
clean :
-find . -type f -name '*~' -exec rm {} \;
-find . -type f -name pod2htmd.tmp -exec rm {} \;
.PHONY : dist-clean
dist-clean : clean
-rm -rf dist
# ========================================
.PHONY : create-build-env
create-build-env : clean \
package/ver.mak \
get-dep-pkg \
get-util-prog \
check-php-ini \
.git/hooks/pre-commit \
$(mCheck)
@echo "Next: make create-prod-env"
mBldPkg = \
pod2pdf \
tidy \
wget
.PHONY : get-dep-pkg
get-dep-pkg :
sudo apt-get update
tPkgList=$$(awk '/%requires/ {print $$2}' package/$(ProdOSDist).require); \
for tPkg in $$tPkgList $(mBldPkg); do \
if ! dpkg -l $$tPkg >/dev/null 2>&1; then \
sudo apt-get install -y $$tPkg; \
fi; \
if ! dpkg -l $$tPkg >/dev/null 2>&1; then \
echo "Error: could not install $$tPkg"; \
exit 1; \
fi; \
done
mUtilProgDir = ~/ver/github/app/my-utility-scripts
mUtilProg = \
bin/.phptidy-config.php \
bin/bash-fmt \
bin/incver.sh \
bin/phptidy.php \
bin/pre-commit \
bin/rm-trailing-sp \
bin/shfmt
.PHONY : get-util-prog
get-util-prog : $(mUtilProgDir) $(mUtilProg)
cd $(mUtilProgDir); \
git checkout develop; \
git pull origin develop
$(mUtilProgDir) :
mkdir -p ~/ver/github/app
cd ~/ver/github/app; \
git clone git@github.com:TurtleEngr/my-utility-scripts.git
mPhpIniFile = /etc/php/8.2/cli/php.ini
# /etc/php/7.4/cli/php.ini
mPhpIni = \
'memory_limit = -1' \
'error_reporting = E_ALL' \
'log_errors_max_len = 0' \
'zend.assertions = 1' \
'assert.exception = 1' \
'xdebug.show_exception_trace = 0' \
'variables_order = "EGPCS"'
.PHONY : check-php-ini
check-php-ini : $(mPhpIniFile)
@for tLine in $(mPhpIni); do \
if ! grep -q "^$$tLine" $(mPhpIniFile); then \
echo "Error: $$tLine not found in $(mPhpIniFile)"; \
exit 1; \
fi; \
done
# ========================================
.PHONY : create-prod-env
create-prod-env : create-build-env \
mk-doc \
src/etc/lo-schema.csv \
src/etc/biblio.csv \
src/etc/conf.php \
src/doc/example/conf.env \
$(mCheckProd)
chmod -R a+r src
chmod -R a+rx src/bin
chmod a+rx src/test/*.php
find src -type d -exec chmod a+rx {} \;
@echo "Next: make test or build"
# Use the rules
.PHONY : mk-doc
mk-doc : \
src/doc/manual/libre-bib.html \
src/doc/manual/libre-bib.md \
src/doc/example/example-outline.html
src/etc/lo-schema.csv : src/etc/biblio.csv
head -n 1 $? | sed 's/,C,254//g; s/,M//g' >$@
src/etc/biblio.csv : $(mDirLoConf)/biblio.dbf
libreoffice --headless --convert-to csv $?
mv biblio.csv $@
$(mDirLoConf)/biblio.dbf :
@echo "Error: It looks like Libreoffice is not installed"
exit 1
src/etc/conf.php : src/etc/conf.env
src/bin/gen-conf-php.sh <$? >$@
chmod a+rx $@
src/doc/example/conf.env : src/etc/conf.env
sed 's/^export / #/' <$? >$@
chmod a+rx $@
src/doc/example/example-outline.odt : src/doc/example/example-outline.org
@echo "Manually create"
# ========================================
.PHONY : test
test :
src/bin/bib -T all
src/bin/bib -T com
src/bin/phpunit src/test
@echo "Next: make build"
# ========================================
.PHONY : build
build : clean clean-test create-prod-env
-find dist -type l -exec rm {} \; &>/dev/null
rm -rf dist
mkdir -p dist/opt/libre-bib
rsync -aP LICENSE src/* dist/opt/libre-bib/
find dist -name .gitignore -exec rm {} \;
find dist -type d -exec chmod a+rx {} \;
find dist -type f -exec chmod a+r {} \;
find dist -type f -executable -exec chmod a+rx {} \;
@echo "Next: make install or package"
.PHONY : clean-test
clean-test :
-cd src/test/sample; \
rm -rf backup etc status tmp; \
rm bib-cache/db-create.cmd; \
rm biblio-note.txt conf.env key.txt
# ========================================
.PHONY : install
install : /opt/libre-bib/VERSION
/opt/libre-bib/VERSION : dist/opt/libre-bib/VERSION
sudo mkdir -p /opt/libre-bib
sudo cp -ar dist/opt/libre-bib/* /opt/libre-bib/
sudo find /opt/libre-bib -type d -exec chmod a+rx {} \;
sudo find /opt/libre-bib -type f -exec chmod a+r {} \;
sudo find /opt/libre-bib -type f -executable -exec chmod a+rx {} \;
dist/opt/libre-bib/VERSION : build
# ========================================
# Tag versions
.PHONY : update
update :
git checkout main
git pull origin main
git checkout develop
git pull origin develop
.PHONY : save
dev-ver :
git checkout develop
git commit -am "Updated
git tag -m "Development $$(cat src/VERSION)" $$(echo dev-$$(cat src/VERSION | tr '.' '-'))
git push --tags origin develop
bin/incver.sh -p -f src/VERSION
git commit -am "Updated -p VERSION"
.PHONY : stable
rel-ver : update
bin/incver.sh -m -f src/VERSION
git commit -am "Updated -m VERSION"
git checkout main
git pull origin main
git merge develop
git tag -m "Release $$(cat src/VERSION)" $$(echo stable-$$(cat src/VERSION | tr '.' '-'))
git push --tags origin main
git checkout develop
bin/incver.sh -p -f src/VERSION
git commit -am "Updated -p VERSION"
# ========================================
# Package
.PHONY : package
package : clean dist mk-pkg
@echo "Next: make release"
.PHONY : mk-pkg
mk-pkg : package/ver.sh package/epm.list
-mkdir -p pkg
cd package; . ./ver.env; epm -v -f native -m $$ProdOSDist-$$ProdArch --output-dir ../pkg $(ProdName) ver.epm
cd package; . ./ver.env; epm -v -f portable -m $$ProdOSDist-$$ProdArch --output-dir ../pkg $(ProdName) ver.epm
package/epm.list : dist/opt/libre-bib
cd package; mkepmlist -u root -g root --prefix / ../dist | patch-epm-list -f ./epm.patch >epm.list
package/ver.mak : package/ver.sh
cd package; \
mkver.pl -e 'mak env epm'
package/ver.sh : src/VERSION
touch $@
# ========================================
.PHONY : release-dev
release-dev :
@echo "TBD"
@echo "cp pkg to $(ProdDevDir)/$(ProdOS)"
.PHONY : release-prod
release-prod :
@echo "TBD"
@echo "cp pkg to $(ProdRelDir)/$(ProdOS)"
# ========================================
# Complex Targets
# --------------------
# EPM
mEpmMx=mx19/epm-5.0.2-1-mx19-x86_64.deb
mEpmUbuntu=ubuntu18/epm-5.0.1-2-linux-5.3-x86_64.deb
/usr/local/bin/epm :
if [[ "$(ProdOSDist)" = "mx" ]]; then \
cd tmp; wget $(ProdRelRoot)/released/software/ThirdParty/epm/$(mEpmMx); \
sudo apt-get install -y tmp/$(notdir $(mEpmMx)); \
fi
if [[ "$(ProdOSDist)" = "ubuntu" ]]; then \
cd tmp; wget $(ProdRelRoot)/released/software/ThirdParty/epm/$(mEpmUbuntu); \
sudo apt-get install -y tmp/$(notdir $(mEpmUbuntu)); \
fi
# --------------------
# EPM Helper
mEpmHelper=epm-helper-1.6.1-3-linux-noarch.deb
/usr/local/bin/mkver.pl :
cd tmp; wget $(ProdRelRoot)/released/software/ThirdParty/epm/$(mEpmHelper)
sudo apt-get install -y tmp/$(mEpmHelper)
# --------------------
# Beekeeper
mBeekeeperVer=3.9.17
mBeekeeper=Beekeeper-Studio-$(mBeekeeperVer).AppImage
/usr/local/bin/beekeeper : /usr/local/bin/$(mBeekeeper)
cd /usr/local/bin; sudo ln -sf $(mBeekeeper) beekeeper
/usr/local/bin/$(mBeekeeper) :
cd tmp; wget https://github.com/beekeeper-studio/beekeeper-studio/releases/download/v$(mBeekeeperVer)/$(mBeekeeper)
sudo mv -f tmp/$(mBeekeeper) $@
sudo chmod a+rx $@
# --------------------
# phpunit
mPhpUnit = phpunit-11.5.56.phar
# Version 8.x needs php 7.2.0 phpunit-8.5.53.phar
# Version 9.x needs php 7.3.0 phpunit-9.6.35.phar
# Version 10.x needs php 8.1.0 phpunit-10.5.64.phar
# Version 11.x needs php 8.2.0 phpunit-11.5.56.phar
# Version 12.x needs php 8.3.0 phpunit-12.5.33.phar
# Version 13.x needs php 8.4.0 phpunit-13.2.6.phar
src/bin/$(mPhpUnit) :
rsync -P $(ProdRelServer):/rel/archive/software/ThirdParty/phpunit/*.phar src/bin/
src/bin/phpunit : src/bin/$(mPhpUnit)
cd src/bin; \
ln -sf $(mPhpUnit) phpunit
# ========================================
# Single Targets $(mUtilProg)
# --------------------
# Build Env only
bin/bash-fmt : $(mUtilProgDir)/bin/bash-fmt
cp $? $@
bin/incver.sh : $(mUtilProgDir)/bin/incver.sh
cp $? $@
bin/phptidy.php : $(mUtilProgDir)/bin/phptidy.php
cp $? $@
bin/.phptidy-config.php : $(mUtilProgDir)/bin/.phptidy-config.php
cp $? $@
bin/pre-commit : $(mUtilProgDir)/bin/pre-commit
cp $? $@
.git/hooks/pre-commit : $(mUtilProgDir)/bin/pre-commit
cp $? $@
bin/rm-trailing-sp : $(mUtilProgDir)/bin/rm-trailing-sp
cp $? $@
bin/shfmt : $(mUtilProgDir)/bin/shfmt
cp $? $@
# --------------------
# Build Env and Product
src/bin/bash-com.inc bin/bash-com.inc : $(mUtilProgDir)/bin/bash-com.inc
cp $? $@
src/bin/bash-com.test bin/bash-com.test : $(mUtilProgDir)/bin/bash-com.test
cp $? $@
src/bin/org2html.sh bin/org2html.sh : $(mUtilProgDir)/bin/org2html.sh
cp $? $@
src/bin/shunit2.1 bin/shunit2.1 : $(mUtilProgDir)/bin/shunit2.1
cp $? $@
src/bin/sort-para.sh bin/sort-para.sh : $(mUtilProgDir)/bin/sort-para.sh
cp $? $@
# ========================================
# Rules
%.md : %.html
pandoc -f html -t markdown < $< > $@
%.odt : %.html
libreoffice --headless --convert-to odt $<
%.html : %.org
bin/org2html.sh -s 2 $< $@