Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (48 loc) · 2.02 KB
/
Copy pathMakefile
File metadata and controls
57 lines (48 loc) · 2.02 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
# gascroll - build & install the LD_PRELOAD scroll scaler
#
# make build libgascroll.so into build/
# make test build and run the config/self test
# sudo make install-ld put the library in /usr/local/lib (optional)
# make install build + install library, systemd drop-in, GNOME extension
# make uninstall undo the above (session re-login needed to take effect)
#
# NOTE: install.sh does the same thing with more checks and is what the README
# tells users to run. The Makefile is a convenience wrapper.
PREFIX ?= $(HOME)/.local
LIBDIR ?= $(PREFIX)/lib
LIB := libgascroll.so
UUID ?= gascroll@ga
EXTDIR ?= $(HOME)/.local/share/gnome-shell/extensions/$(UUID)
DROPIN ?= $(HOME)/.config/systemd/user/org.gnome.Shell@.service.d/override.conf
all: build/$(LIB)
build/$(LIB): src/gascroll.c
@mkdir -p build
gcc -shared -fPIC -O2 -Wall -Wextra -o $@.tmp $< -ldl -lm
mv -f $@.tmp $@ # atomic rename: safe while gnome-shell maps the old file
test: build/$(LIB)
@mkdir -p build
gcc -o build/selftest tests/selftest.c -ldl
GASCROLL_CONF=build/selftest.conf ./build/selftest build/$(LIB)
install: build/$(LIB)
@mkdir -p $(LIBDIR)
cp -f build/$(LIB) $(LIBDIR)/$(LIB).tmp && mv -f $(LIBDIR)/$(LIB).tmp $(LIBDIR)/$(LIB)
@mkdir -p $(dir $(DROPIN))
printf '[Service]\nEnvironment=LD_PRELOAD=%s/%s\n' "$(LIBDIR)" "$(LIB)" > $(DROPIN)
@mkdir -p $(dir $(EXTDIR))
rm -rf $(EXTDIR)
cp -r extension $(EXTDIR)
systemctl --user daemon-reload || true
@echo "installed. Log out and back in once so gnome-shell picks it up."
uninstall:
rm -f $(DROPIN)
rm -rf $(EXTDIR)
rm -f $(LIBDIR)/$(LIB)
systemctl --user daemon-reload || true
@echo "removed. Log out and back in to fully unload."
clean:
rm -rf build
test-imports: # regression test: correct/incorrect extension resource paths
GI_TYPELIB_PATH=/usr/lib/gnome-shell/girepository-1.0 \
LD_LIBRARY_PATH=/usr/lib/gnome-shell \
gjs -m tests/prefs-import-test.mjs
.PHONY: all test test-imports install uninstall clean