forked from rvaiya/keyd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (102 loc) · 3.1 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
.PHONY: all clean install uninstall debug man compose test-harness
VERSION=2.4.3
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
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)
platform=$(shell uname -s)
ifeq ($(platform), Linux)
COMPAT_FILES=
else
LDFLAGS+=-linotify
COMPAT_FILES=
endif
all:
-mkdir bin
cp scripts/keyd-application-mapper bin/
sed -e 's#@PREFIX@#$(PREFIX)#' keyd.service.in > keyd.service
$(CC) $(CFLAGS) -O3 $(COMPAT_FILES) src/*.c src/vkbd/$(VKBD).c -lpthread -o bin/keyd $(LDFLAGS)
debug:
CFLAGS="-g -Wunused" $(MAKE)
compose:
-mkdir 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 [ -e /run/systemd/system ]; then \
mkdir -p $(DESTDIR)$(PREFIX)/lib/systemd/system/; \
install -Dm644 keyd.service $(DESTDIR)$(PREFIX)/lib/systemd/system/keyd.service; \
else \
echo "NOTE: systemd not found, you will need to manually add keyd to your system's init process."; \
fi
@if [ "$(VKBD)" = "usb-gadget" ]; then \
install -Dm644 src/vkbd/usb-gadget.service $(DESTDIR)$(PREFIX)/lib/systemd/system/keyd-usb-gadget.service; \
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
install -m644 data/*.1.gz $(DESTDIR)$(PREFIX)/share/man/man1/
install -m644 data/keyd.compose $(DESTDIR)$(PREFIX)/share/keyd/
uninstall:
-groupdel keyd
rm -rf $(DESTDIR)$(PREFIX)/lib/systemd/system/keyd.service \
$(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)/lib/systemd/system/keyd-usb-gadget.service \
$(DESTDIR)$(PREFIX)/bin/keyd-usb-gadget.sh \
$(DESTDIR)$(PREFIX)/lib/systemd/system/keyd.service
clean:
-rm -rf bin keyd.service
test:
@cd t; \
for f in *.sh; do \
./$$f; \
done
test-io:
-mkdir bin
$(CC) \
-DDATA_DIR= \
-o bin/test-io \
t/test-io.c \
src/keyboard.c \
src/string.c \
src/macro.c \
src/config.c \
src/log.c \
src/ini.c \
src/keys.c \
src/unicode.c && \
./bin/test-io t/test.conf t/*.t