-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (69 loc) · 2.47 KB
/
Makefile
File metadata and controls
82 lines (69 loc) · 2.47 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
# --- Settings ---
UUID = hide-cursor@elcste.com
SCHEMA_ID = org.gnome.shell.extensions.hide-cursor-elcste-com
DOMAIN = $(UUID)
# Directories
EXTENSION_DIR = $(HOME)/.local/share/gnome-shell/extensions/$(UUID)
SCHEMAS_DIR = $(HOME)/.local/share/glib-2.0/schemas
LOCALE_DIR = $(HOME)/.local/share/locale
# Files
SCHEMA_XML = schemas/$(SCHEMA_ID).gschema.xml
PO_FILES = $(wildcard po/*.po)
LANGUAGES = $(notdir $(PO_FILES:.po=))
# Commands
GLIB_COMPILE_SCHEMAS = glib-compile-schemas
MSGFMT = msgfmt
.PHONY: all install uninstall schemas local-schemas translations pot clean
# --- Main target ---
all: schemas local-schemas translations
# --- Installation ---
install: schemas local-schemas translations
@echo "Installing extension to $(EXTENSION_DIR)..."
@mkdir -p "$(EXTENSION_DIR)"
@cp -r extension.js metadata.json prefs.js schemas po "$(EXTENSION_DIR)/"
# .mo files already copied by translations → to $(EXTENSION_DIR)/locale/
@echo "✅ Extension installed."
# --- Global schema compilation (required for GNOME 42+) ---
schemas:
@echo "Compiling schema to global directory..."
@mkdir -p "$(SCHEMAS_DIR)"
@cp "$(SCHEMA_XML)" "$(SCHEMAS_DIR)/"
@$(GLIB_COMPILE_SCHEMAS) "$(SCHEMAS_DIR)"
# --- Local schema compilation (in extension folder) ---
local-schemas:
@echo "Compiling schema to extension folder (locally)..."
@$(GLIB_COMPILE_SCHEMAS) schemas/
# --- Translations ---
translations: $(PO_FILES:.po=.mo)
%.mo: %.po
@lang=$$(basename $< .po); \
mkdir -p "$(EXTENSION_DIR)/locale/$$lang/LC_MESSAGES"; \
$(MSGFMT) -o "$(EXTENSION_DIR)/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo" $<
# --- Uninstallation ---
uninstall:
@echo "Removing extension $(UUID)..."
@rm -rf "$(EXTENSION_DIR)"
@echo "Removing global schema..."
@rm -f "$(SCHEMAS_DIR)/$(SCHEMA_ID).gschema.xml"
@$(GLIB_COMPILE_SCHEMAS) "$(SCHEMAS_DIR)" 2>/dev/null || true
@echo "Removing translations..."
@for lang in $(LANGUAGES); do \
if [ -n "$$lang" ]; then \
echo " Removing $$lang..."; \
rm -f "$(LOCALE_DIR)/$$lang/LC_MESSAGES/$(DOMAIN).mo"; \
rmdir "$(LOCALE_DIR)/$$lang/LC_MESSAGES" 2>/dev/null || true; \
rmdir "$(LOCALE_DIR)/$$lang" 2>/dev/null || true; \
fi \
done
@echo "✅ Uninstallation completed."
# --- POT Generation (optional) ---
pot:
@xgettext --from-code=UTF-8 \
--output=po/$(DOMAIN).pot \
--keyword=_ \
--package-name="$(UUID)" \
extension.js prefs.js
# --- Cleaning local .mo files ---
clean:
@rm -f po/*.mo schemas/*.compiled
@echo "Cleaning local .mo files. and compiled schemas"