forked from penguin-teal/gnome-openweather
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
144 lines (125 loc) · 5.02 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
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
# Basic Makefile
PKG_NAME = gnome-shell-extension-openweatherrefined
UUID = [email protected]
BASE_MODULES = metadata.json COPYING AUTHORS
SRC_MODULES := $(shell find ./src -maxdepth 1 -type f -printf '%f ')
SRC_FILES := $(addprefix ./src/, $(SRC_MODULES))
PREFS_MODULES := $(shell find ./src/preferences -type f -printf '%f ')
PREFS_FILES := $(addprefix ./src/preferences/, $(PREFS_MODULES))
EXTRA_DIRECTORIES := media
TOLOCALIZE := $(SRC_FILES) $(PREFS_FILES) \
schemas/org.gnome.shell.extensions.openweatherrefined.gschema.xml
MSGSRC := $(wildcard po/*.po)
SCHEMA_XML := ./schemas/org.gnome.shell.extensions.openweatherrefined.gschema.xml
# Packagers: Use DESTDIR for system wide installation
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
# Set a git version for self builds from the latest git tag with the revision
# (a monotonically increasing number that uniquely identifies the source tree)
# and the current short commit SHA1. (Note: not set if VERSION passed)
GIT_VER = $(shell git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')
# The command line passed variable VERSION is used to set the version integer
# in the metadata and in the generated zip file. If no VERSION is passed, we
# won't touch the metadata version and instead use that for the zip file.
ifdef VERSION
FOUNDVERSION := $(VERSION)
else
FOUNDVERSION := $(shell cat metadata.json | sed '/"version"/!d' | sed s/\"version\"://g | sed s/\ //g)
endif
ZIPVER = -v$(FOUNDVERSION)
TARGZ := ./releases/$(PKG_NAME)$(ZIPVER).tar.gz
.PHONY: all clean potfile mergepo install help
.SILENT: help
all: _build
clean:
rm -f ./schemas/gschemas.compiled
rm -f ./po/*.mo
rm -rf ./releases
rm -rf ./_build
./schemas/gschemas.compiled: $(SCHEMA_XML)
glib-compile-schemas --strict ./schemas/
potfile: ./po/openweather.pot
mergepo: potfile
for l in $(MSGSRC); do \
msgmerge -U $$l ./po/openweather.pot; \
done;
./po/openweather.pot: $(TOLOCALIZE)
mkdir -p po
xgettext -k_ -kN_ --from-code utf-8 -o po/openweather.pot --keyword=XGT --package-name $(PKG_NAME) $(TOLOCALIZE)
./po/%.mo: ./po/%.po
msgfmt -c $< -o $@
install: _build
rm -rf $(INSTALLBASE)/$(UUID)
mkdir -p $(INSTALLBASE)/$(UUID)
cp -r ./_build/* $(INSTALLBASE)/$(UUID)/
ifeq ($(INSTALLTYPE),system)
# system-wide settings and locale files
rm -r $(addprefix $(INSTALLBASE)/$(UUID)/, schemas locale COPYING)
mkdir -p $(SHARE_PREFIX)/glib-2.0/schemas \
$(SHARE_PREFIX)/locale \
$(SHARE_PREFIX)/licenses/$(PKG_NAME)
cp -r ./schemas/*gschema.xml $(SHARE_PREFIX)/glib-2.0/schemas
cp -r ./_build/locale/* $(SHARE_PREFIX)/locale
cp -r ./_build/COPYING $(SHARE_PREFIX)/licenses/$(PKG_NAME)
endif
-rm -fR _build
echo done
releases: mergepo _build
printf -- 'NEEDED: zip tar\n'
mkdir -p ./releases
cd ./_build ; \
zip -qr "../$(PKG_NAME)$(ZIPVER).zip" .
mv ./$(PKG_NAME)$(ZIPVER).zip ./releases
cd ./_build ; \
tar -czf "../$(PKG_NAME)$(ZIPVER).tar.gz" .
mv "./$(PKG_NAME)$(ZIPVER).tar.gz" $(TARGZ)
sha256sum $(TARGZ) > $(addsuffix .sha256,$(TARGZ))
cat $(addsuffix .sha256,$(TARGZ))
./_build: ./schemas/gschemas.compiled $(SCHEMA_XML) $(MSGSRC:.po=.mo) $(BASE_MODULES) $(SRC_FILES) $(PREFS_FILES) $(EXTRA_DIRECTORIES)
-rm -fR ./_build
mkdir -p ./_build/preferences
cp $(BASE_MODULES) $(addprefix src/, $(SRC_MODULES)) ./_build
cp $(addprefix src/preferences/, $(PREFS_MODULES)) ./_build/preferences
cp -r $(EXTRA_DIRECTORIES) ./_build
mkdir -p ./_build/schemas
cp $(SCHEMA_XML) ./_build/schemas/
cp ./schemas/gschemas.compiled ./_build/schemas/
mkdir -p ./_build/locale
for l in $(MSGSRC:.po=.mo) ; do \
lf=_build/locale/`basename $$l .mo`; \
mkdir -p $$lf; \
mkdir -p $$lf/LC_MESSAGES; \
cp $$l $$lf/LC_MESSAGES/$(PKG_NAME).mo; \
done;
ifdef VERSION
sed -i 's/"version": .*/"version": $(VERSION)/' ./_build/metadata.json;
else ifneq ($(strip $(GIT_VER)),)
sed -i '/"version": .*/i\ \ "git-version": "$(GIT_VER)",' ./_build/metadata.json;
endif
help:
printf '\n** OpenWeather Refined v%s (%s) **\n' `grep -oP --color=never '(?<="version-name": ")[^"]*' ./metadata.json` "$(GIT_VER)"
printf "Switch git to latest release (recommended if you're just trying to install):\n"
printf '\tgit switch --detach latest\n'
printf 'Build to output directory (./_build) and regenerate translation files:\n'
printf '\tmake\n'
printf 'Install to local user profile (log-out required after):\n'
printf '\tmake install\n'
printf 'Install system-wide (log-out required after):\n'
printf '\tmake install DESTDIR=/usr/share\n'
printf 'Build translations:\n'
printf '\tmake mergepo\n'
printf 'Make Gzip and Zip archives of release build (in ./releases)\n'
printf '\tmake releases\n'
printf 'Clean build files:\n'
printf '\tmake clean\n'
printf 'See changelog:\n'
printf '\tless CHANGELOG.md\n'
printf 'Test in nested GNOME shell:\n'
printf '\t./nest-test.sh\n'
printf '\n'