-
Notifications
You must be signed in to change notification settings - Fork 21
/
makefile
54 lines (42 loc) · 1.72 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
CC = c99
CFLAGS = -g -Wall -Wextra -pedantic
OBJS = k.o
PREFIX = /usr/local/share
INSTALLPATH = $(PREFIX)/kfreestyle2d/
GROUP = uinput
GROUPADD_PATH = /usr/sbin/groupadd
kfreestyle2d: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o kfreestyle2d
systemd: kfreestyle2d.service.template
cat kfreestyle2d.service.template | sed 's|<<<PREFIX>>>|$(PREFIX)|g' \
| sed 's|<<<GROUP>>>|$(GROUP)|g' > /etc/systemd/system/kfreestyle2d.service
systemd-uinput: uinput-load.service.template
cat uinput-load.service.template > /etc/systemd/system/uinput-load.service
# Create a copy of the udev rules
udev-rule: ./99-kfreestyle2d.rules.template
cat 99-kfreestyle2d.rules.template | sed 's|<<<GROUP>>>|$(GROUP)|g' \
> /etc/udev/rules.d/99-kfreestyle2d.rules
# Add a uinput user to the system
group:
$(GROUPADD_PATH) -f uinput
id -u uinput > /dev/null 2>&1 || useradd --system --no-create-home --shell /bin/false -g uinput uinput > /dev/null
# Ensure the existence of a directory within the prefix location
directory:
mkdir $(INSTALLPATH) || true # ensure doesn't crash if already exists
# Copy the binary to its new home. Unlink any existing file first in case the
# service is already running.
binary: directory kfreestyle2d
rm -f $(INSTALLPATH)/kfreestyle2d
cp kfreestyle2d $(INSTALLPATH)/kfreestyle2d
chgrp $(GROUP) $(INSTALLPATH)/kfreestyle2d
# Make systemd and udev notice their new configurations
refresh:
systemctl enable uinput-load
systemctl daemon-reload
udevadm control --reload
udevadm trigger
# Insert the uinput kernel module and ensure that it is inserted on startup
module:
grep -e "uinput" /etc/modules > /dev/null 2>&1 || echo "uinput" >> /etc/modules
modprobe uinput
install: group systemd systemd-uinput udev-rule binary module refresh