-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
62 lines (47 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
CC = gcc
CFLAGS = -I${DIR_INC} -Wall -O2
CFLAGS_DEBUG = -I${DIR_INC} -Wall -O0 -g
LDLIBS = -pthread
PREFIX = /usr/local
DIR_SRC = src
DIR_INC = src
DIR_OBJ = objs
SRCS = $(wildcard ${DIR_SRC}/*.c)
INCS = $(wildcard $(DIR_INC)/*.h)
OBJS = $(patsubst %.c, ${DIR_OBJ}/%.o, $(notdir ${SRCS}))
TARGET = umicat
.PHONY: all clean install uninstall test debug run install-docker
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
$(DIR_OBJ)/%.o: $(DIR_SRC)/%.c | $(DIR_OBJ)
$(CC) $(CFLAGS) -o $@ -c $<
$(DIR_OBJ):
mkdir -p $@
install:
install -Dm755 "umicat" "$(PREFIX)/bin/umicat"
test -d '/etc/umicat' || mkdir -p "/etc/umicat"
cat "conf/umicat.conf" > "/etc/umicat/umicat.conf"
test -d '/var/log/umicat' || mkdir -p "/var/log/umicat"
cat "systemd/umicat.service" > "/lib/systemd/system/umicat.service"
systemctl daemon-reload
uninstall:
-systemctl disable --now "umicat.service"
rm -f "/lib/systemd/system/umicat.service"
systemctl daemon-reload
rm -f "$(PREFIX)/bin/umicat"
rm -rf "/etc/umicat"
rm -rf "/var/log/umicat"
install-docker:
install -Dm755 "umicat" "$(PREFIX)/bin/umicat"
test -d '/etc/umicat' || mkdir -p "/etc/umicat"
cat "conf/umicat.conf" > "/etc/umicat/umicat.conf"
test -d '/var/log/umicat' || mkdir -p "/var/log/umicat"
run: all
./umicat -c conf/umicat.conf -l umicat.log
test: debug
./umicat -c conf/umicat.conf -l umicat.log
debug: $(SRCS)
$(CC) ${CFLAGS_DEBUG} $(LDLIBS) -o $(TARGET) $^
clean:
rm -rf $(DIR_OBJ) $(TARGET) umicat.log