-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
287 lines (236 loc) · 11.2 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
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
DESTDIR ?= /
PREFIX ?= /usr
ENABLE_BASH_COMPLETION ?= true
ENABLE_ZSH_COMPLETION ?= true
BUILD_DIR := $(abspath build)
REPO_DIR := $(abspath ./)
INSTALL_ROOT := $(abspath build/install_root)
INSTALL_PREFIX :=$(abspath $(shell echo ${INSTALL_ROOT}/${PREFIX}))
DESTDIR_PREFIX :=$(abspath $(shell echo ${DESTDIR}/${PREFIX}))
DISTRO := $(shell [ -e "/etc/os-release" ] && cat /etc/os-release|sed -n -e 's/^ID="\?\(\w*\)"\?/\1/p' )
ifeq (${ENABLE_BASH_COMPLETION}, true)
ifeq ($(shell pkg-config --exists bash-completion && echo 0), 0)
bashcompletiondir := $(shell pkg-config --variable=completionsdir bash-completion)
endif
endif
ifeq (${ENABLE_ZSH_COMPLETION}, true)
ifeq ($(shell which zsh >/dev/null 2>&1 && echo 0), 0)
zshcompletiondir := /usr/share/zsh/site-functions/
endif
endif
ifdef bashcompletiondir
bashcompletiondir_local := ${INSTALL_ROOT}/${bashcompletiondir}
$(info Bash completion to install at: ${bashcompletiondir})
else
$(info No Bash completion)
endif
ifdef zshcompletiondir
zshcompletiondir_local := ${INSTALL_ROOT}/${zshcompletiondir}
$(info ZSH completion to install at: ${zshcompletiondir})
else
$(info No ZSH completion)
endif
all: build
# Dist and web-greeter directories
build/dist := ${BUILD_DIR}/dist
build/web-greeter := ${BUILD_DIR}/web-greeter
$(build/dist): dist/*
@rm -rf "${BUILD_DIR}/dist"
@rsync -a "${REPO_DIR}/dist" "${BUILD_DIR}"
@cp "${REPO_DIR}/NEWS.md" "${BUILD_DIR}/dist/NEWS.md"
@echo "✔ Dist directory created at ${build/dist}"
$(build/web-greeter): src/*
@rsync -a "${REPO_DIR}/src/" "${BUILD_DIR}/web-greeter" --exclude "dist" --exclude "__pycache__"
@cp "${REPO_DIR}/README.md" "${BUILD_DIR}/web-greeter/"
@echo "✔ Build directory created at ${build/web-greeter}"
# Resources
bundle.js := ${BUILD_DIR}/web-greeter/resources/js/bundle.js
bundle/ThemeUtils := ${REPO_DIR}/src/resources/js/ThemeUtils.js
bundle/GreeterComm := ${REPO_DIR}/src/resources/js/GreeterComm.js
bundle/bootstrap := ${REPO_DIR}/src/resources/js/bootstrap.js
$(bundle.js): $(build/web-greeter) $(bundle/ThemeUtils) $(bundle/bootstrap) $(bundle/GreeterComm)
@cd build/web-greeter/resources/js; \
cat ${bundle/ThemeUtils} ${bundle/bootstrap} ${bundle/GreeterComm} > bundle.js
resources.py := ${BUILD_DIR}/web-greeter/resources.py
$(resources.py): $(bundle.js)
@pyrcc5 -o ${BUILD_DIR}/web-greeter/resources.py\
${BUILD_DIR}/web-greeter/resources/resources.qrc
@cp ${resources.py} src/
@echo "✔ Resources compiled with pyrcc5"
# Install root, where everything will be copied to
$(INSTALL_ROOT):
@for d in man/man1 metainfo doc/web-greeter web-greeter \
xgreeters applications icons/hicolor/scalable/apps; do \
mkdir -p "${INSTALL_PREFIX}/share/$$d"; \
done
@for d in lightdm xdg/lightdm/lightdm.conf.d; do \
mkdir -p "${INSTALL_ROOT}/etc/$$d"; \
done
@for d in lib/web-greeter bin; do \
mkdir -p "${INSTALL_PREFIX}/$$d"; \
done
@echo "✔ Install root created at ${INSTALL_ROOT}"
# ZSH completion install
$(zshcompletiondir_local): $(INSTALL_ROOT)
@if [ -n "${zshcompletiondir}" ]; then \
mkdir -p "${zshcompletiondir_local}"; \
cp "${BUILD_DIR}/dist/web-greeter-zsh" "${zshcompletiondir_local}/_web-greeter"; \
echo " ZSH completion copied"; \
fi
# Bash completion install
$(bashcompletiondir_local): $(INSTALL_ROOT)
@if [ -n "${bashcompletiondir}" ]; then \
mkdir -p "${bashcompletiondir_local}"; \
cp "${BUILD_DIR}/dist/web-greeter-bash" "${bashcompletiondir_local}/web-greeter"; \
echo " Bash completion copied"; \
fi
build_completions: $(zshcompletiondir_local) $(bashcompletiondir_local)
# Theme installation
THEMES_DIR := $(abspath ${DESTDIR_PREFIX}/share/web-greeter/themes)
THEMES_DIR_LOCAL := $(abspath ${INSTALL_PREFIX}/share/web-greeter/themes)
themes/gruvbox := $(abspath ${THEMES_DIR_LOCAL}/gruvbox)
themes/gruvbox/js := $(abspath ${REPO_DIR}/themes/themes/gruvbox/js)
themes/dracula := $(abspath ${THEMES_DIR_LOCAL}/dracula)
themes/dracula/js := $(abspath ${REPO_DIR}/themes/themes/dracula/js)
themes/simple := $(abspath ${THEMES_DIR_LOCAL}/simple)
themes/_vendor := $(abspath ${INSTALL_PREFIX}/share/web-greeter/_vendor)
$(THEMES_DIR_LOCAL): $(INSTALL_ROOT)
@mkdir -p "${THEMES_DIR_LOCAL}"
$(themes/gruvbox/js): themes/themes/gruvbox/ts
@tsc --build themes/themes/gruvbox
@echo " Gruvbox theme compiled"
$(themes/dracula/js): themes/themes/dracula/ts
@tsc --build themes/themes/dracula
@echo " Dracula theme compiled"
$(themes/gruvbox): $(THEMES_DIR_LOCAL) $(themes/gruvbox/js) themes/themes/gruvbox
@if [ -d "${themes/gruvbox}" ]; then \
rm -rf "${themes/gruvbox}"; \
fi
@cp -r "${REPO_DIR}/themes/themes/gruvbox" "${themes/gruvbox}"
@echo " Gruvbox theme copied"
$(themes/dracula): $(THEMES_DIR_LOCAL) $(themes/dracula/js) themes/themes/dracula
@if [ -d "${themes/dracula}" ]; then \
rm -rf "${themes/dracula}"; \
fi
@cp -r "${REPO_DIR}/themes/themes/dracula" "${themes/dracula}"
@echo " Dracula theme copied"
$(themes/simple): $(THEMES_DIR_LOCAL) themes/themes/simple/*
@cp -r "${REPO_DIR}/themes/themes/simple" "${themes/simple}"
@echo " Simple theme copied"
$(themes/_vendor): $(INSTALL_ROOT) themes/themes/_vendor/*
@cp -r "${REPO_DIR}/themes/themes/_vendor" "${themes/_vendor}"
@echo " Theme vendors copied"
build_themes: $(themes/gruvbox) $(themes/dracula) $(themes/simple) $(themes/_vendor)
# Dist files
dist/web-greeter.1 := $(abspath ${DESTDIR_PREFIX}/share/man/man1/web-greeter.1.gz)
dist/news := $(abspath ${DESTDIR_PREFIX}/share/doc/web-greeter/NEWS.gz)
dist/metainfo := $(abspath ${DESTDIR_PREFIX}/share/metainfo/web-greeter.appdata.xml)
dist/xg-desktop := $(abspath ${DESTDIR_PREFIX}/share/xgreeters/web-greeter.desktop)
dist/app-desktop := $(abspath ${DESTDIR_PREFIX}/share/applications/web-greeter.desktop)
dist/app-icon-scalable := $(abspath ${DESTDIR_PREFIX}/share/icons/hicolor/scalable/apps/com.github.jezerm.web-greeter.svg)
dist_local/web-greeter.1 := $(abspath ${INSTALL_PREFIX}/share/man/man1/web-greeter.1.gz)
dist_local/news := $(abspath ${INSTALL_PREFIX}/share/doc/web-greeter/NEWS.gz)
dist_local/metainfo := $(abspath ${INSTALL_PREFIX}/share/metainfo/web-greeter.appdata.xml)
dist_local/xg-desktop := $(abspath ${INSTALL_PREFIX}/share/xgreeters/web-greeter.desktop)
dist_local/app-desktop := $(abspath ${INSTALL_PREFIX}/share/applications/web-greeter.desktop)
dist_local/app-icon-scalable := $(abspath ${INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/com.github.jezerm.web-greeter.svg)
$(dist_local/web-greeter.1): $(build/dist) $(INSTALL_ROOT) ${BUILD_DIR}/dist/web-greeter.1
@gzip -c9 "${BUILD_DIR}/dist/web-greeter.1" > \
"${dist_local/web-greeter.1}"
$(dist_local/news): $(build/dist) $(INSTALL_ROOT) ${BUILD_DIR}/dist/NEWS.md
@gzip -c9 "${BUILD_DIR}/dist/NEWS.md" > \
"${dist_local/news}"
$(dist_local/metainfo): $(build/dist) $(INSTALL_ROOT) ${BUILD_DIR}/dist/web-greeter.appdata.xml
@cp "${BUILD_DIR}/dist/web-greeter.appdata.xml" \
"${dist_local/metainfo}"
$(dist_local/xg-desktop): $(build/dist) $(INSTALL_ROOT) ${BUILD_DIR}/dist/web-xgreeter.desktop
@cp "${BUILD_DIR}/dist/web-xgreeter.desktop" \
"${dist_local/xg-desktop}"
$(dist_local/app-desktop): $(build/dist) $(INSTALL_ROOT) ${BUILD_DIR}/dist/web-greeter.desktop
@cp "${BUILD_DIR}/dist/web-greeter.desktop" \
"${dist_local/app-desktop}"
$(dist_local/app-icon-scalable): $(build/dist) $(INSTALL_ROOT) ${BUILD_DIR}/dist/com.github.jezerm.web-greeter.svg
@cp "${BUILD_DIR}/dist/com.github.jezerm.web-greeter.svg" \
"${dist_local/app-icon-scalable}"
build_dist_files: $(dist_local/web-greeter.1) $(dist_local/news) $(dist_local/metainfo) $(dist_local/xg-desktop) $(dist_local/app-desktop) $(dist_local/app-icon-scalable)
@echo "✔ Dist files copied"
# Config files
config/web-greeter := $(abspath ${DESTDIR}/etc/lightdm/web-greeter.yml)
config/lightdm-wrapper := $(abspath ${DESTDIR}/etc/xdg/lightdm/lightdm.conf.d/90-greeter-wrapper.conf)
config/Xgreeter := $(abspath ${DESTDIR}/etc/lightdm/Xgreeter)
config_local/web-greeter := $(abspath ${INSTALL_ROOT}/etc/lightdm/web-greeter.yml)
config_local/lightdm-wrapper := $(abspath ${INSTALL_ROOT}/etc/xdg/lightdm/lightdm.conf.d/90-greeter-wrapper.conf)
config_local/Xgreeter := $(abspath ${INSTALL_ROOT}/etc/lightdm/Xgreeter)
$(config_local/web-greeter): $(INSTALL_ROOT) ${BUILD_DIR}/dist/web-greeter.yml
@cp "${BUILD_DIR}/dist/web-greeter.yml" "${config_local/web-greeter}"
$(config_local/lightdm-wrapper): $(INSTALL_ROOT) ${BUILD_DIR}/dist/90-greeter-wrapper.conf
@cp "${BUILD_DIR}/dist/90-greeter-wrapper.conf" "${config_local/lightdm-wrapper}"
$(config_local/Xgreeter): $(INSTALL_ROOT) ${BUILD_DIR}/dist/Xgreeter ${BUILD_DIR}/Xgreeter.patch /etc/os-release
@install -Dm755 "${BUILD_DIR}/dist/Xgreeter" "${config_local/Xgreeter}"
@case "${DISTRO}" in \
fedora) \
patch -bN "${config_local/Xgreeter}" "${BUILD_DIR}/Xgreeter.patch"; \
;; \
esac
build_config: $(config_local/web-greeter) $(config_local/lightdm-wrapper) $(config_local/Xgreeter)
@echo "✔ Config copied"
build_install_root: $(INSTALL_ROOT) build_dist_files build_config build_themes build_completions
# Binaries
bin/web-greeter := $(abspath ${DESTDIR}/bin/web-greeter)
bin_local/web-greeter := $(abspath ${INSTALL_PREFIX}/bin/web-greeter)
bin/screensaver.so := ${BUILD_DIR}/web-greeter/bindings/_screensaver.so
bin/screensaver.c := ${BUILD_DIR}/web-greeter/bindings/screensaver.c
$(bin/screensaver.so): $(build/web-greeter)
@gcc ${bin/screensaver.c} -o ${bin/screensaver.so} -shared -lX11 -lxcb
@cp ${bin/screensaver.so} src/bindings/
@echo "✔ Screensaver.so compiled"
$(bin_local/web-greeter): build_install_root $(resources.py) $(bin/screensaver.so)
@rm -rf "${INSTALL_PREFIX}/lib/web-greeter/*"
@cp -R "${BUILD_DIR}/web-greeter"/* "${INSTALL_PREFIX}/lib/web-greeter"
@printf "#!/usr/bin/env bash\npython3 ${DESTDIR_PREFIX}/lib/web-greeter \$$@" > \
"${bin_local/web-greeter}"
@chmod +x "${bin_local/web-greeter}"
@echo "✔ web-greeter binary copied"
# Useful rules
.PHONY: build
build: $(bin_local/web-greeter)
@echo "✔ Build succeeded"
.PHONY: install
install: build
[ -e "${DESTDIR}" ] || mkdir -p "${DESTDIR}"
cp -R "${INSTALL_ROOT}"/* "${DESTDIR}"
@echo "✔ Install succeeded"
# Uninstall everything except themes and web-greeter.yml
uninstall_preserve:
@rm -rf "${DESTDIR_PREFIX}/lib/web-greeter/"
@rm -f "${dist/web-greeter.1}"
@rm -f "${dist/app-desktop}"
@rm -f "${dist/xg-desktop}"
@rm -f "${dist/metainfo}"
@rm -f "${dist/news}"
@rm -f "${dist/app-icon-scalable}"
@rm -f "${config/lightdm-wrapper}"
@rm -f "${config/Xgreeter}"
@rm -f "${bin/web-greeter}"
@if [ -n "${bashcompletiondir}" ]; then \
rm -f "${bashcompletiondir}/web-greeter"; \
fi
@if [ -n "${zshcompletiondir}" ]; then \
rm -f "${zshcompletiondir}/_web-greeter"; \
fi
# Uninstall everything
uninstall_all: uninstall_preserve
@rm -rf "${DESTDIR_PREFIX}/share/web-greeter/"
@rm -f "${config/web-greeter}"
.PHONY: uninstall
uninstall: uninstall_preserve
@echo -e " Themes are not uninstalled. Remove them manually or use \`make uninstall_all\`:\
\n${DESTDIR_PREFIX}/share/web-greeter"
@echo -e " web-greeter config was not uninstalled. Remove it manually or use \`make uninstall_all\`:\
\n${config/web-greeter}"
run: $(resources.py)
python3 src
run_debug: $(resources.py)
python3 src --debug
clean:
rm -rf ${INSTALL_ROOT} ${BUILD_DIR}/dist ${BUILD_DIR}/web-greeter