-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
50 lines (43 loc) · 1.37 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
# Configuration
SHELL = /bin/sh
MKDIR_P = mkdir -p
SYSTEMCTL = systemctl
# Check if './configure' has been run
CONFIGURED = 0
ifneq ("$(wildcard build/70-close_lid.conf)","")
ifneq ("$(wildcard build/suspend.service)","")
CONFIGURED = 1
endif
endif
all:
@echo "Type 'make install' or 'make uninstall'"
@echo
@echo "make install"
@echo " Will copy files to /var/lib/systemd"
@echo " enable services and reload systemd."
@echo ""
@echo "make uninstall"
@echo " Will remove files from /var/lib/systemd"
@echo " disable services and reload systemd."
install:
ifeq ($(CONFIGURED),0)
$(error Not configured, run ./configure)
endif
@# root check
@[ `id -u` = 0 ] || { echo "Must be run as root or with sudo"; exit 1; }
@# Create dir
${MKDIR_P} /usr/lib/systemd/system
${MKDIR_P} /usr/lib/systemd/logind.conf.d/
@# Copy files
install -m 0644 build/suspend.service /usr/lib/systemd/system/suspend.service
install -m 0644 build/70-close_lid.conf /usr/lib/systemd/logind.conf.d/70-close_lid.conf
${SYSTEMCTL} enable suspend.service
${SYSTEMCTL} daemon-reload
uninstall:
@# root check
@[ `id -u` = 0 ] || { echo "Must be run as root or with sudo"; exit 1; }
@# Remove files
${SYSTEMCTL} disable suspend.service 2>/dev/null || true
rm -f /usr/lib/systemd/system/suspend.service
rm -f /usr/lib/systemd/logind.conf.d/70-close_lid.conf
${SYSTEMCTL} daemon-reload