-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (55 loc) · 1.47 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
NAME = fbwb
CC = gcc
CPPFLAGS = -Wall -Wextra -Werror
CPPFLAGS = -MMD -MP
CPPFLAGS += -I.
CP = cp
IF = if
RM = rm
SED = sed
CHMOD = chmod
CHOWN = chown
SYSTEMCTL = systemctl
SRCS = fbwb.c
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)
SERVICE_NAME = $(NAME).service
SERVICE_USER = root
SERVICE_PATH = /etc/systemd/system
INSTALL_PATH = /usr/local/sbin
FRAMEBUFFER_PATH= /dev/fb1
%.o: %.c
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(NAME): $(OBJS)
$(LINK.c) $^ $(LOADLIBS) $(LDLIBS) $(OUTPUT_OPTION)
-include $(DEPS)
.PHONY: all clean fclean re install uninstall
all: $(NAME)
clean:
$(RM) -r $(OBJS) $(DEPS)
fclean:
$(RM) -rf $(OBJS) $(DEPS) $(NAME)
re: fclean
$(MAKE) all
install: all
$(IF) [ -z "$(FRAMEBUFFER_PATH)" ]; then \
echo "Error: FRAMEBUFFER_PATH required for install"; \
exit 1; \
fi
$(CP) $(NAME) $(INSTALL_PATH)
$(CHOWN) $(SERVICE_USER):$(SERVICE_USER) $(INSTALL_PATH)/$(NAME)
$(CP) $(SERVICE_NAME) $(SERVICE_PATH)
$(SED) -i 's|^ExecStart=.*|ExecStart=$(INSTALL_PATH)/$(NAME) $(FRAMEBUFFER_PATH)|' $(SERVICE_PATH)/$(SERVICE_NAME)
$(CHOWN) $(SERVICE_USER):$(SERVICE_USER) $(SERVICE_PATH)/$(SERVICE_NAME)
$(CHMOD) 644 $(SERVICE_PATH)/$(SERVICE_NAME)
$(SYSTEMCTL) daemon-reload
$(SYSTEMCTL) enable $(NAME)
$(SYSTEMCTL) start $(NAME)
$(SYSTEMCTL) status $(NAME) --no-pager
uninstall:
$(SYSTEMCTL) stop $(NAME)
$(SYSTEMCTL) disable $(NAME)
$(RM) $(SERVICE_PATH)/$(SERVICE_NAME)
$(SYSTEMCTL) daemon-reload
$(SYSTEMCTL) reset-failed
$(RM) $(INSTALL_PATH)/$(NAME)