summaryrefslogtreecommitdiffstats
path: root/extensions/hibernate-status/Makefile
blob: 3378024bc69ef4835583b6a571f1f7ce3101dde5 (plain)
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
# Basic Makefile

UUID = hibernate-status@dromi
BASE_MODULES = extension.js metadata.json confirmDialog.js LICENSE README.md
EXTRA_MODULES = prefs.js
TOLOCALIZE =  confirmDialog.js prefs.js
PO_FILES := $(wildcard ./locale/*/*/*.po)
MO_FILES := $(PO_FILES:.po=.mo)

ifeq ($(strip $(DESTDIR)),)
	INSTALLTYPE = local
	INSTALLBASE = $(HOME)/.local/share/gnome-shell/extensions
else
	INSTALLTYPE = system
	SHARE_PREFIX = $(DESTDIR)/usr/share
	INSTALLBASE = $(SHARE_PREFIX)/gnome-shell/extensions
endif
INSTALLNAME = hibernate-status@dromi

all: extension

clean:
	rm -f ./schemas/gschemas.compiled
	rm -f ./**/*~
	rm -f ./locale/*/*/*.mo
	rm -f ./locale/hibernate-status-button.pot

extension: ./schemas/gschemas.compiled $(MO_FILES)

./schemas/gschemas.compiled: ./schemas/org.gnome.shell.extensions.hibernate-status-button.gschema.xml
	glib-compile-schemas ./schemas/

potfile: ./locale/hibernate-status-button.pot

mergepo: potfile
	for l in $(PO_FILES); do \
		msgmerge -U $$l ./locale/hibernate-status-button.pot; \
	done;

./locale/hibernate-status-button.pot: $(TOLOCALIZE)
	mkdir -p locale
	xgettext -k --keyword=__ --keyword=N__ --add-comments='Translators:' -o locale/hibernate-status-button.pot --package-name "Hibernate Status Button" $(TOLOCALIZE)

%.mo: %.po
	msgfmt -c $< -o $@

install: install-local

install-local: _build
	rm -rf $(INSTALLBASE)/$(INSTALLNAME)
	mkdir -p $(INSTALLBASE)/$(INSTALLNAME)
	cp -r ./_build/* $(INSTALLBASE)/$(INSTALLNAME)/
ifeq ($(INSTALLTYPE),system)
	# system-wide settings and locale files
	# rm -r $(INSTALLBASE)/$(INSTALLNAME)/schemas
	rm -f $(INSTALLBASE)/$(INSTALLNAME)/schemas/*gschema.xml
	rm -r $(INSTALLBASE)/$(INSTALLNAME)/locale
	mkdir -p $(SHARE_PREFIX)/glib-2.0/schemas $(SHARE_PREFIX)/locale
	cp -r ./schemas/*gschema.* $(SHARE_PREFIX)/glib-2.0/schemas
	cp -r ./_build/locale/* $(SHARE_PREFIX)/locale
endif
	-rm -fR _build
	echo done

zip-file: _build
	cd _build ; zip -qr "$(UUID).zip" . -x '*.po'
	mv _build/$(UUID).zip ./
	-rm -fR _build

_build: all
	-rm -fR ./_build
	mkdir -p _build
	cp $(BASE_MODULES) $(EXTRA_MODULES) _build
	mkdir -p _build/schemas
	cp schemas/*.xml _build/schemas/
	cp schemas/gschemas.compiled _build/schemas/
	cp -r locale/ _build/locale