-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
93 lines (80 loc) · 2.89 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
# Basic Makefile
EXTNAME = gnome-shell-extension-cast-to-tv
UUID = [email protected]
GETTEXT = cast-to-tv
PACKAGE = "Cast to TV"
TOLOCALIZE = extension.js widget.js playlist.js file-chooser.js prefs.js node_scripts/messages.js
MSGSRC = $(wildcard ./po/cast-to-tv/*.po)
POTFILE = ./po/cast-to-tv/cast-to-tv.pot
ZIPFILES = *.js *.json node_scripts webplayer schemas locale appIcon nautilus COPYING README.md
INSTALLPATH = ~/.local/share/gnome-shell/extensions
# Add-ons translations #
POFOLDERS = $(wildcard ./po/cast-to-tv-*-addon)
# Compile schemas #
glib-schemas:
glib-compile-schemas ./schemas/
# Create/update potfile #
potfile:
mkdir -p ./po
xgettext -o $(POTFILE) --language=JavaScript --add-comments=TRANSLATORS: --package-name $(PACKAGE) $(TOLOCALIZE)
# Update '.po' from 'potfile' #
mergepo:
for i in $(MSGSRC); do \
msgmerge -U $$i $(POTFILE); \
done;
# Compile all .mo files #
compilemo: compilemo-base compilemo-addons
# Compile extension .mo files #
compilemo-base:
for i in $(MSGSRC); do \
msggrep $$i -T -e "" | grep -q "" \
&& mkdir -p ./locale/`basename $$i .po`/LC_MESSAGES \
&& msgfmt -o ./locale/`basename $$i .po`/LC_MESSAGES/$(GETTEXT).mo $$i; \
done;
# Compile addons .mo files #
compilemo-addons:
for i in $(POFOLDERS); do \
for j in $$i/*.po; do \
msggrep $$j -T -e "" | grep -q "" \
&& mkdir -p ./locale_addons/`basename $$i`/`basename $$j .po`/LC_MESSAGES \
&& msgfmt -o ./locale_addons/`basename $$i`/`basename $$j .po`/LC_MESSAGES/`basename $$i`.mo $$j; \
done; \
done;
# Create release zip #
zip-file: _build
zip -qr $(UUID).zip $(ZIPFILES)
# Update metadata #
metadata:
ifeq ($(CUSTOMPATH),)
ifeq ($(PKGDIR),)
LASTCOMMIT=$(shell git rev-parse --short HEAD); \
grep -q '"git":' metadata.json \
&& sed -i "/\"git\":/c \ \ \"git\": \"$$LASTCOMMIT\"," metadata.json \
|| sed -i "/uuid/a \ \ \"git\": \"$$LASTCOMMIT\"," metadata.json
else
grep -q '"custom-install":' metadata.json \
|| sed -i "/uuid/a \ \ \"custom-install\": true," metadata.json
endif
endif
# Build and install #
install: compilemo-base metadata
ifeq ($(CUSTOMPATH),)
glib-compile-schemas ./schemas/
mkdir -p $(INSTALLPATH)/$(UUID)
cp -r $(ZIPFILES) $(INSTALLPATH)/$(UUID)
else
mkdir -p $(CUSTOMPATH)/$(UUID)
cp -r $(filter-out schemas locale README.md COPYING, $(ZIPFILES)) $(CUSTOMPATH)/$(UUID)
mkdir -p $(PKGDIR)/usr/share/glib-2.0/schemas
cp -r ./schemas/*.gschema.* $(PKGDIR)/usr/share/glib-2.0/schemas/
glib-compile-schemas $(PKGDIR)/usr/share/glib-2.0/schemas 2>/dev/null
mkdir -p $(PKGDIR)/usr/share/locale
cp -r ./locale/* $(PKGDIR)/usr/share/locale/
mkdir -p $(PKGDIR)/usr/share/doc/$(EXTNAME)
cp ./README.md $(PKGDIR)/usr/share/doc/$(EXTNAME)/
mkdir -p $(PKGDIR)/usr/share/licenses/$(EXTNAME)
cp ./COPYING $(PKGDIR)/usr/share/licenses/$(EXTNAME)/
mkdir -p $(CUSTOMPATH)/$(UUID)/node_modules
chmod 777 $(CUSTOMPATH)/$(UUID)/node_modules
endif
_build: glib-schemas compilemo-base