forked from keyd-project/keyd-fork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
136 lines (124 loc) · 3.86 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
.PHONY: all clean install uninstall debug man compose test-harness
VERSION=2.5.0
COMMIT=$(shell git describe --no-match --always --abbrev=7 --dirty)
VKBD=uinput
PREFIX?=/usr/local
CONFIG_DIR?=/etc/keyd
SOCKET_PATH=/var/run/keyd.socket
# If this variable is set to the empty string, no systemd unit files will be
# installed.
SYSTEMD_SYSTEM_DIR = /usr/lib/systemd/system
CFLAGS:=-DVERSION=\"v$(VERSION)\ \($(COMMIT)\)\" \
-I/usr/local/include \
-L/usr/local/lib \
-Wall \
-Wextra \
-Wno-unused \
-std=c11 \
-DSOCKET_PATH=\"$(SOCKET_PATH)\" \
-DCONFIG_DIR=\"$(CONFIG_DIR)\" \
-DDATA_DIR=\"$(PREFIX)/share/keyd\" \
-D_FORTIFY_SOURCE=2 \
-D_DEFAULT_SOURCE \
-Werror=format-security \
$(CFLAGS)
CXXFLAGS:=-DVERSION=\"v$(VERSION)\ \($(COMMIT)\)\" \
-I/usr/local/include \
-L/usr/local/lib \
-Wall \
-Wextra \
-Wno-unused \
-std=c++20 \
-DSOCKET_PATH=\"$(SOCKET_PATH)\" \
-DCONFIG_DIR=\"$(CONFIG_DIR)\" \
-DDATA_DIR=\"$(PREFIX)/share/keyd\" \
-D_FORTIFY_SOURCE=2 \
-D_DEFAULT_SOURCE \
-Werror=format-security \
-fdata-sections -ffunction-sections \
-static-libgcc -static-libstdc++\
$(CXXFLAGS)
platform=$(shell uname -s)
ifeq ($(platform), Linux)
COMPAT_FILES=
else
LDFLAGS+=-linotify
COMPAT_FILES=
endif
all: compose man
mkdir -p bin
cp scripts/keyd-application-mapper bin/
$(CXX) $(CXXFLAGS) -O3 $(COMPAT_FILES) src/*.cpp src/vkbd/$(VKBD).cpp -lpthread -Wl,--gc-sections -o bin/keyd $(LDFLAGS)
debug:
CFLAGS="-g -fsanitize=address -Wunused" $(MAKE)
compose:
mkdir -p data
./scripts/generate_xcompose
man:
for f in docs/*.scdoc; do \
target=$${f%%.scdoc}.1.gz; \
target=data/$${target##*/}; \
scdoc < "$$f" | gzip > "$$target"; \
done
install:
@if [ -n '$(SYSTEMD_SYSTEM_DIR)' ]; then \
sed -e 's#@PREFIX@#$(PREFIX)#' keyd.service.in > keyd.service; \
mkdir -p '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)'; \
install -Dm644 keyd.service '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd.service'; \
fi
@if [ "$(VKBD)" = "usb-gadget" ]; then \
if [ -n '$(SYSTEMD_SYSTEM_DIR)' ]; then \
sed -e 's#@PREFIX@#$(PREFIX)#' src/vkbd/usb-gadget.service.in > src/vkbd/usb-gadget.service; \
install -Dm644 src/vkbd/usb-gadget.service '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd-usb-gadget.service'; \
fi; \
install -Dm755 src/vkbd/usb-gadget.sh $(DESTDIR)$(PREFIX)/bin/keyd-usb-gadget.sh; \
fi
mkdir -p $(DESTDIR)$(CONFIG_DIR)
mkdir -p $(DESTDIR)$(PREFIX)/bin/
mkdir -p $(DESTDIR)$(PREFIX)/share/keyd/
mkdir -p $(DESTDIR)$(PREFIX)/share/keyd/layouts/
mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1/
mkdir -p $(DESTDIR)$(PREFIX)/share/doc/keyd/
mkdir -p $(DESTDIR)$(PREFIX)/share/doc/keyd/examples/
-groupadd keyd
install -m755 bin/* $(DESTDIR)$(PREFIX)/bin/
install -m644 docs/*.md $(DESTDIR)$(PREFIX)/share/doc/keyd/
install -m644 examples/* $(DESTDIR)$(PREFIX)/share/doc/keyd/examples/
install -m644 layouts/* $(DESTDIR)$(PREFIX)/share/keyd/layouts
cp -r data/gnome-* $(DESTDIR)$(PREFIX)/share/keyd
install -m644 data/*.1.gz $(DESTDIR)$(PREFIX)/share/man/man1/
install -m644 data/keyd.compose $(DESTDIR)$(PREFIX)/share/keyd/
uninstall:
-groupdel keyd
[ -z '$(SYSTEMD_SYSTEM_DIR)' ] || rm -f \
'$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd.service' \
'$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd-usb-gadget.service'
rm -rf $(DESTDIR)$(PREFIX)/bin/keyd \
$(DESTDIR)$(PREFIX)/bin/keyd-application-mapper \
$(DESTDIR)$(PREFIX)/share/doc/keyd/ \
$(DESTDIR)$(PREFIX)/share/man/man1/keyd*.gz \
$(DESTDIR)$(PREFIX)/share/keyd/ \
$(DESTDIR)$(PREFIX)/bin/keyd-usb-gadget.sh
clean:
rm -rf bin data/*.1.gz data/keyd.compose keyd.service src/unicode.cpp src/vkbd/usb-gadget.service
test:
@cd t; \
for f in *.sh; do \
./$$f; \
done
test-io:
mkdir -p bin
$(CXX) \
-std=c++20 \
-DDATA_DIR= \
-o bin/test-io \
t/test-io.cpp \
src/keyboard.cpp \
src/string.cpp \
src/macro.cpp \
src/config.cpp \
src/log.cpp \
src/ini.cpp \
src/keys.cpp \
src/unicode.cpp && \
./bin/test-io t/test.conf t/*.t