forked from debreate/debreate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
565 lines (507 loc) · 15.7 KB
/
Makefile.in
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
# This is a template Makefile
# Use "setup.py" to create actual Makefile
# FIXME: "dist" rule compiles gettext locales
# TODO: Organize rules
prefix = <prefix>
TARGET = $(DESTDIR)$(prefix)
PACKAGE = debreate
VERSION = <version>
BINDIR = bin
LIBDIR = lib
DATAROOT = share
DATADIR = $(DATAROOT)/$(PACKAGE)
APPSDIR = $(DATAROOT)/applications
PIXDIR = $(DATAROOT)/pixmaps
DOCDIR = $(DATAROOT)/doc/$(PACKAGE)
LOCALEDIR = $(DATAROOT)/locale
ICONTHEME = <icon-theme>
MIMEDIR = $(DATAROOT)/mime/packages
MIMEICONSDIR = $(ICONTHEME)/scalable/mimetypes
SUBDIRS = \
data
INSTALL_DATA = install -vm 0644
INSTALL_EXEC = install -vm 0755
INSTALL_FOLDER = cp -vR
MKDIR = mkdir -vp
UNINSTALL = rm -vf
UNINSTALL_FOLDER = rmdir -v --ignore-fail-on-non-empty
FILES_executable = \
init.py
FILES_root = \
command_line.py \
main.py
FILES_wiz_bin = wiz_bin/*.py
FILES_wiz_src = wiz_src/*.py
FILES_doc = \
docs/BUGS.txt \
docs/changelog \
docs/release_notes \
docs/TODO.txt \
docs/usage.pdf
FILES_bitmap = bitmaps/*.png
FILES_man = \
man/man1/$(PACKAGE).1
FILES_data = \
data/$(MENU)
PACKAGE_dbr = dbr/*.py
PACKAGE_globals = globals/*.py
DATA_packages = \
$(PACKAGE_dbr) \
$(PACKAGE_globals)
FILES_build = \
$(FILES_executable) \
$(FILES_root) \
$(FILES_wiz_bin) \
$(FILES_wiz_src) \
$(FILES_doc) \
$(FILES_bitmap) \
$(FILES_data)
FILES_dist = \
$(FILES_executable) \
$(FILES_root) \
INFO \
Makefile \
README.md \
setup.py
DIR_locale = locale
DIRS_build = \
templates
DIRS_dist = \
$(DIRS_build) \
$(DIR_locale) \
bitmaps \
data \
dbr \
debian \
docs \
globals \
man \
scripts \
wiz_bin \
wiz_src
PACKAGE_dist = $(PACKAGE)_$(VERSION).tar.xz
MENU = $(PACKAGE).desktop
LOGO = bitmaps/$(PACKAGE)64.png
CHANGELOG = docs/changelog
LICENSE = docs/LICENSE.txt
MIMEFILE = data/mime/$(PACKAGE).xml
DOXYGEN_CONFIG = docs/Doxyfile
INSTALLED = INSTALLED
MIME_prefix = application
MIME_dbp = x-dbp
MIME_dbpz = $(MIME_dbp)z
MIME_icons = \
data/svg/$(MIME_prefix)-$(MIME_dbp).svg \
data/svg/$(MIME_prefix)-$(MIME_dbpz).svg
TEMPLATES_scripts = \
data/postinst.in \
data/postrm.in
all:
@echo "\n\tNothing to be done"; \
echo "\trun one of the following:"; \
echo "\n\t\t`tput bold`make install`tput sgr0` to install Debreate"; \
echo "\t\t`tput bold`make help`tput sgr0` to show a list of options\n"; \
build:
@exec=bin/$(PACKAGE); \
echo "\nprefix set to \"$(prefix)\""; \
\
exec_script=\#"!/bin/sh\n\n$(prefix)/$(DATAROOT)/$(PACKAGE)/init.py \$$@"; \
\
mkdir -vp "bin"; \
echo "Creating executable \"$${exec}\" ..."; \
echo "$${exec_script}\n" > "$${exec}"; \
\
echo "Creating \"$(INSTALLED)\" file ..."; \
echo "prefix=$(prefix)\n" > "$(INSTALLED)"; \
\
echo "\nBuild complete. Now execute `tput bold`make install`tput sgr0`.\n"; \
# FIXME: May need to make adjustments
.PHONY: locale
locale:
@echo "Building gettext locales ..."; \
locale_dir="$$(pwd)/locale"; \
#echo "$${locale_dir}"; \
for f in $$(find "$${locale_dir}" -type f -name "*.po"); do \
lc_dir=$$(dirname "$${f}")/LC_MESSAGES; \
echo "$${lc_dir}"; \
if [ ! -d "$${lc_dir}" ]; then \
$(MKDIR) "$${lc_dir}"; \
fi; \
msgfmt -v "$${f}" -o "$${lc_dir}/$(PACKAGE).mo"; \
done; \
locale-clean:
@find locale -type f -name "*\.mo" -delete; \
find locale -type d -empty -delete; \
install-data: $(INSTALLED)
@target="$(DESTDIR)$(prefix)"; \
data_dir="$${target}/$(DATADIR)"; \
if [ ! -d "$${data_dir}" ]; then \
$(MKDIR) "$${data_dir}"; \
fi; \
$(INSTALL_DATA) "$(INSTALLED)" "$${data_dir}"; \
install: build locale install-packages install-data $(FILES_build) $(DIRS_build) install-doc install-locale install-mime install-man
@exec=bin/$(PACKAGE); \
if [ ! -f "$${exec}" ]; then \
echo "\n\tERROR: ./bin/`tput bold`$(PACKAGE)`tput sgr0` executable not present\n"; \
\
echo "\t- Please run `tput bold`make`tput sgr0`, `tput bold`make build`tput sgr0`, or `tput bold`make all`tput sgr0`"; \
echo "\t to create it, then re-run `tput bold`make install`tput sgr0`\n"; \
exit 1; \
\
else \
target=$(DESTDIR)$(prefix); \
bin_dir=$${target}/$(BINDIR); \
data_dir=$${target}/$(DATADIR); \
apps_dir=$${target}/$(APPSDIR); \
pix_dir=$${target}/$(PIXDIR); \
\
echo "\nprefix set to $(prefix)"; \
echo "Install target set to $${target}\n"; \
\
mkdir -vp "$${target}/$(DATADIR)"; \
for py in $(FILES_executable); do \
$(INSTALL_EXEC) "$${py}" "$${data_dir}"; \
done; \
for py in $(FILES_root); do \
$(INSTALL_DATA) "$${py}" "$${data_dir}"; \
done; \
\
$(MKDIR) "$${data_dir}/wiz_bin"; \
for py in $(FILES_wiz_bin); do \
$(INSTALL_DATA) "$${py}" "$${data_dir}/wiz_bin"; \
done; \
\
$(MKDIR) "$${data_dir}/wiz_src"; \
for py in $(FILES_wiz_src); do \
$(INSTALL_DATA) "$${py}" "$${data_dir}/wiz_src"; \
done; \
\
mkdir -vp "$${data_dir}/bitmaps"; \
for png in $(FILES_bitmap); do \
$(INSTALL_DATA) "$${png}" "$${data_dir}/bitmaps"; \
done; \
\
for d in $(DIRS_build); do \
$(INSTALL_FOLDER) "$${d}" "$${data_dir}"; \
done; \
\
$(MKDIR) "$${bin_dir}"; \
$(INSTALL_EXEC) "$${exec}" "$${bin_dir}"; \
\
$(MKDIR) "$${pix_dir}"; \
$(INSTALL_DATA) "bitmaps/$(PACKAGE)64.png" "$${pix_dir}/$(PACKAGE).png"; \
\
$(MKDIR) "$${apps_dir}"; \
$(INSTALL_EXEC) "data/$(MENU)" "$${apps_dir}"; \
\
fi; \
\
echo "\nInstallation complete"; \
install-packages: $(DATA_packages)
@for f in $(DATA_packages); do \
target="$(TARGET)/$(DATADIR)/$$(dirname $${f})"; \
echo "target=$${target}"; \
if [ ! -d "$${target}" ]; then \
$(MKDIR) "$${target}"; \
fi; \
$(INSTALL_DATA) "$${f}" "$${target}"; \
done; \
install-doc: $(FILES_doc) $(LICENSE)
@target="$(DESTDIR)$(prefix)"; \
doc_dir="$${target}/$(DOCDIR)"; \
\
echo "\nInstalling documentation ..."; \
mkdir -vp "$${doc_dir}"; \
for doc in $(FILES_doc); do \
$(INSTALL_DATA) "$${doc}" "$${doc_dir}"; \
done; \
\
echo "\nCompressing changelog ..."; \
gzip -vf "$${doc_dir}/changelog"; \
\
$(INSTALL_DATA) "$(LICENSE)" "$${doc_dir}/copyright"; \
install-locale: $(DIR_locale)
@target="$(DESTDIR)$(prefix)"; \
locale_dir="$${target}/$(LOCALEDIR)"; \
echo "Installing locale files ..."; \
if [ ! -d "$${locale_dir}" ]; then \
$(MKDIR) "$${locale_dir}"; \
fi; \
for mo in `find $(DIR_locale) -type f -name "*.mo"`; do \
mo=$$(echo "$${mo}" | sed -e 's:^.......::'); \
modir="$${locale_dir}/$$(dirname $${mo})"; \
#td="$${locale_dir}/`dirname \"$${mo}\"`"; \
if [ ! -d "$${modir}" ]; then \
$(MKDIR) "$${modir}"; \
fi; \
$(INSTALL_DATA) "locale/$${mo}" "$${modir}"; \
done; \
install-icons: $(MIME_icons)
@target="$(DESTDIR)$(prefix)"; \
icons_dir="$${target}/$(MIMEICONSDIR)"; \
$(MKDIR) "$${icons_dir}"; \
for i in $(MIME_icons); do \
$(INSTALL_DATA) "$${i}" "$${icons_dir}"; \
done; \
install-mime: $(MIMEFILE) install-icons
@target="$(DESTDIR)$(prefix)"; \
mime_dir="$${target}/$(MIMEDIR)"; \
if [ ! -d "$${mime_dir}" ]; then \
$(MKDIR) "$${mime_dir}"; \
fi; \
$(INSTALL_DATA) "$(MIMEFILE)" "$${mime_dir}"; \
install-man: $(FILES_man)
@target="$(DESTDIR)$(prefix)"; \
data_root="$${target}/$(DATAROOT)"; \
for f in $(FILES_man); do \
filename=$$(basename "$${f}") && mandir="$${data_root}/$$(dirname $${f})"; \
if [ ! -d "$${mandir}" ]; then \
$(MKDIR) "$${mandir}"; \
fi; \
$(INSTALL_DATA) "$${f}" "$${mandir}"; \
gzip -vf9 "$${mandir}/$${filename}"; \
done; \
uninstall-icons:
@target="$(DESTDIR)$(prefix)"; \
icons_dir="$${target}/$(ICONTHEME)"; \
if [ -d "$${icons_dir}" ]; then \
mime_dbp="$(MIME_prefix)-$(MIME_dbp)"; \
#$(UNINSTALL) "$${mime_dbp}.svg" "$${mime_dbp}z.svg"; \
find "$${icons_dir}" -type f -name "$(MIME_prefix)-$(MIME_dbp)*\\.svg" -delete; \
find "$${icons_dir}" -type d -empty -delete; \
fi; \
uninstall-mime: uninstall-icons
@target="$(DESTDIR)$(prefix)"; \
mime_dir="$${target}/$(MIMEDIR)"; \
$(UNINSTALL) "$${mime_dir}/$(PACKAGE).xml"; \
uninstall-man:
@target="$(DESTDIR)$(prefix)"; \
man_dir="$${target}/$(DATAROOT)/man"; \
echo "Manual dir: $${man_dir}"; \
find "$${man_dir}/man1" -type f -name "$(PACKAGE)\.1\.gz" -delete; \
uninstall-doc:
@target="$(DESTDIR)$(prefix)"; \
doc_dir="$${target}/$(DOCDIR)"; \
\
if [ -d "$${doc_dir}" ]; then \
for f in `find "$${doc_dir}" -type f`; do \
$(UNINSTALL) "$${f}"; \
done; \
find "$${doc_dir}" -type d -empty -delete; \
fi; \
uninstall-locale:
@target="$(DESTDIR)$(prefix)"; \
locale_dir="$${target}/$(LOCALEDIR)"; \
echo "Uninstalling locale files ..."; \
find "$${locale_dir}" -type f -name "$(PACKAGE)\.mo" -delete; \
uninstall: uninstall-mime uninstall-man uninstall-doc uninstall-locale
@target="$(DESTDIR)$(prefix)"; \
bin_dir="$${target}/$(BINDIR)"; \
data_dir="$${target}/$(DATADIR)"; \
apps_dir="$${target}/$(APPSDIR)"; \
pix_dir="$${target}/$(PIXDIR)"; \
\
echo "\nprefix set to $(prefix)"; \
echo "Uninstall target set to $${target}\n"; \
\
$(UNINSTALL) "$${apps_dir}/$(MENU)"; \
$(UNINSTALL) "$${pix_dir}/$(PACKAGE).png"; \
$(UNINSTALL) "$${bin_dir}/$(PACKAGE)"; \
\
if [ -d "$${data_dir}" ]; then \
for f in `find "$${data_dir}" -type f`; do \
$(UNINSTALL) "$${f}"; \
done; \
find "$${data_dir}" -type d -empty -delete; \
fi; \
\
#.PHONY: debian
deb-prep: $(CHANGELOG) $(TEMPLATES_scripts)
@echo "Copying changelog to debian directory ..."; \
cp -vf "$(CHANGELOG)" "debian/changelog"; \
\
echo "Creating Debian scripts ..."; \
for f in $(TEMPLATES_scripts); do \
name=$$(echo "$${f}" | sed -e 's:^.....::g' -e 's:...$$::g'); \
echo "Copying data/$${name}.in to debian/$${name} ..."; \
cp -vf "data/$${name}.in" "debian/$${name}"; \
echo "Modifying script debian/$${name} ..."; \
sed -i -e "s|<prefix>|$(prefix)|" "debian/$${name}"; \
chmod -v 0755 "debian/$${name}"; \
done; \
deb-bin: deb-clean deb-prep
@debuild -b -uc -us
deb-bin-signed: deb-clean deb-prep
@debuild -b -sa
deb-src: deb-clean deb-prep
@debuild -S -uc -us
deb-src-signed: deb-clean deb-prep
@debuild -S -sa
debianize: dist
@dh_make -y -n -c mit -e antumdeluge@gmail.com -f "$(PACKAGE_dist)" -p "$(PACKAGE)_$(VERSION)" -i
doc-html: $(DOXYGEN_CONFIG)
@doxygen "$(DOXYGEN_CONFIG)"; \
echo "\nOptimizing Doxygen HTML docs for Python ...\n"; \
find docs/doxygen -type f -exec sed -i -e 's/def //' {} +; \
find docs/doxygen -type f -exec sed -i -e 's/def //' {} +; \
find docs/doxygen -type f -exec sed -i -e 's/class  //' {} +; \
\
# Removes whitespace before parameters \
find docs/doxygen -type f -exec sed -i -e '/<td class="paramtype">/c\' {} +; \
clean: doc-clean locale-clean
@find ./ -type f -name "*.pyc" -print -delete; \
rm -vf "./bin/$(PACKAGE)"; \
if [ -d "./bin" ]; then \
$(UNINSTALL_FOLDER) "./bin"; \
fi; \
#rm -vf "./prefix"; \
rm -vf "$(INSTALLED)"; \
distclean: clean
@echo "Cleaning distribution ..."; \
rm -vf "$(PACKAGE_dist)"; \
deb-clean:
@rm -vrf "debian/$(PACKAGE)"
@DEBUILD_FILES="\
debian/debhelper-build-stamp debian/$(PACKAGE).debhelper.log \
debian/$(PACKAGE).substvars debian/files"; \
rm -vf $${DEBUILD_FILES}; \
for f in preinst postinst prerm postrm; do \
rm -vf "debian/$${f}"; \
done; \
doc-clean:
@rm -vrf docs/doxygen
dist: distclean deb-clean $(FILES_dist) $(DIRS_dist)
@echo "Creating distribution package ..."; \
if [ -f "$(PACKAGE_dist)" ]; then \
rm -v "$(PACKAGE_dist)"; \
fi; \
tar -cJf "$(PACKAGE_dist)" $(FILES_dist) $(DIRS_dist); \
file "$(PACKAGE_dist)"; \
help:
@echo "Usage:"; \
\
echo "\tmake [command]\n"; \
\
echo "Commands:"; \
\
echo "\thelp"; \
echo "\t\t- Show this help dialog\n"; \
\
echo "\tall|build"; \
echo "\t\t- Create `tput bold`$(PACKAGE)`tput sgr0` executable (same as invoking"; \
echo "\t\t `tput bold`make`tput sgr0` with no arguments)\n"; \
\
echo "\tinstall"; \
echo "\t\t- Install `tput bold`$(PACKAGE)`tput sgr0` executable & data files onto"; \
echo "\t\t the system"; \
echo "\t\t- Calls `tput bold`install-doc`tput sgr0`, `tput bold`install-locale`tput sgr0`,"; \
echo "\t\t `tput bold`install-mime`tput sgr0`, & `tput bold`install-man`tput sgr0`\n"; \
\
echo "\tinstall-data"; \
echo "\t\t- Install misc. data files onto the system\n"; \
\
echo "\tinstall-doc"; \
echo "\t\t- Install documentation files\n"; \
\
echo "\tinstall-locale"; \
echo "\t\t- Install gettext locale translations\n"; \
\
echo "\tinstall-mime"; \
echo "\t\t- Register MimeType information for Debreate"; \
echo "\t\t projects"; \
echo "\t\t- Calls `tput bold`install-icons`tput sgr0`\n"; \
\
echo "\tinstall-icons"; \
echo "\t\t- Install icons for Debreate projects MimeType"; \
echo "\t\t registration\n"; \
\
echo "\tinstall-man"; \
echo "\t\t- Install & compress Manpage files\n"; \
\
echo "\tinstall-packages"; \
echo "\t\t- Install Debreate's sub-packages"; \
echo "\t\t- Called by `tput bold`install`tput sgr0`\n"; \
\
echo "\tuninstall"; \
echo "\t\t- Remove all installed Debreate files from"; \
echo "\t\t the system"; \
echo "\t\t- Calls `tput bold`uninstall-mime`tput sgr0`, `tput bold`uninstall-man`tput sgr0`,"; \
echo "\t\t `tput bold`uninstall-doc`tput sgr0`, & `tput bold`uninstall-locale`tput sgr0`\n"; \
\
echo "\tuninstall-mime"; \
echo "\t\t- Unregister Debreate project MimeType"; \
echo "\t\t information"; \
echo "\t\t- Calls `tput bold`uninstall-icons`tput sgr0`\n"; \
\
echo "\tuninstall-icons"; \
echo "\t\t- Remove Debreate MimeType icons from system\n"; \
\
echo "\tuninstall-man"; \
echo "\t\t- Remove Debreate Manpages from system\n"; \
\
echo "\tuninstall-doc"; \
echo "\t\t- Remove Debreate documentation files from"; \
echo "\t\t system\n"; \
\
echo "\tuninstall-locale"; \
echo "\t\t- Remove Gettext translation files from system\n"; \
\
echo "\tdoc-html"; \
echo "\t\t- Build Doxygen HTML files in docs/doxygen"; \
echo "\t\t- Requires `tput bold`doxygen`tput sgr0` command (apt install doxygen)\n"; \
\
echo "\tdist"; \
echo "\t\t- Create a source distribution package\n"; \
\
echo "\tdeb-prep"; \
echo "\t\t- Prepares debian directory for build &"; \
echo "\t\t distribution\n"; \
\
echo "\tdebianize"; \
echo "\t\t- Configure source for building a Debian package"; \
echo "\t\t (not necessary, should already be configured)"; \
echo "\t\t- Uses `tput bold`dh_make`tput sgr0` command (apt install dh-make)\n"; \
\
echo "\tdeb-bin"; \
echo "\t\t- Build a Debian (.deb) package for installation"; \
echo "\t\t- Uses `tput bold`debbuild`tput sgr0` command (apt install devscripts)\n"; \
\
echo "\tdeb-bin-signed"; \
echo "\t\t- Build a Debian (.deb) package for installation"; \
echo "\t\t & sign the .changes file\n"; \
\
echo "\tdeb-src"; \
echo "\t\t- Create a source distribution package with"; \
echo "\t\t Debian .dsc, .build, & .changes files\n"; \
\
echo "\tdeb-src-signed"; \
echo "\t\t- Create a source distribution package & sign"; \
echo "\t\t the .changes file for upload to a repository\n"; \
\
echo "\tclean"; \
echo "\t\t- Delete Debreate binary & any compiled Python"; \
echo "\t\t bytecode (.pyc) from the working directory\n"; \
\
echo "\tdoc-clean"; \
echo "\t\t- Delete Doxygen HTML files from docs/doxygen.\n"; \
\
echo "\tdeb-clean"; \
echo "\t\t- Delete files create by `tput bold`deb-bin`tput sgr0`\n"; \
\
echo "\tdistclean"; \
echo "\t\t- Run `tput bold`clean`tput sgr0` & `tput bold`deb-clean`tput sgr0`\n"; \
\
echo "Environment Variables:"; \
\
echo "\tprefix"; \
echo "\t\t- Target prefix under which files will be installed"; \
echo "\t\t- Default is /usr/local\n"; \
\
echo "\tDESTDIR"; \
echo "\t\t- Prepends a target directory to prefix"; \
echo "\t\t- Files will be installed under DESTDIR\prefix"; \
echo "\t\t- DESTDIR is not written to the `tput bold`$(PACKAGE)`tput sgr0`"; \
echo "\t\t executable so it will not be able to find the"; \
echo "\t\t `tput bold`init.py`tput sgr0` script"; \
echo "\t\t- If used with `tput bold`uninstall`tput sgr0` it must match that of"; \
echo "\t\t the `tput bold`install`tput sgr0` invocation\n"; \