summaryrefslogtreecommitdiff
path: root/Makefile
blob: d88caf74513af560b8f82df6463d0812fe82d796 (plain)
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
# ── umbrella Makefile ─────────────────────────────────────────────────────────

CC      = gcc
CFLAGS  = -Wall -Wextra -Wpedantic -std=c11 -D_GNU_SOURCE \
           -O2 -g
LDFLAGS = -lyaml -lsystemd

DAEMON_SRCS = \
    src/main.c \
    src/daemon.c \
    src/unit.c \
    src/proto.c \
    src/client.c \
    src/log.c \
    src/log_tail.c \
    src/filter.c \
    src/console/rcon.c \
    src/console/a2s.c

CLI_SRCS = clients/umbrella-cli/main.c

DAEMON_OBJS = $(DAEMON_SRCS:.c=.o)
CLI_OBJS    = $(CLI_SRCS:.c=.o)

.PHONY: all clean install

all: umbrella umbrella-cli

umbrella: $(DAEMON_OBJS)
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

umbrella-cli: $(CLI_OBJS)
	$(CC) $(CFLAGS) -o $@ $^

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

# ── Install ───────────────────────────────────────────────────────────────────
PREFIX     ?= /usr/local
CONF_DIR    = /etc/umbrella
UNITS_DIR   = /etc/umbrella/units
FILTER_DIR  = /usr/lib/umbrella/filters
RUN_DIR     = /run/umbrella
LOG_DIR     = /var/log/umbrella

install: all
	install -Dm755 umbrella     $(PREFIX)/sbin/umbrella
	install -Dm755 umbrella-cli $(PREFIX)/bin/umbrella-cli
	install -dm755 $(CONF_DIR)
	install -dm755 $(UNITS_DIR)
	install -dm755 $(RUN_DIR)
	install -dm755 $(LOG_DIR)
	install -dm755 $(FILTER_DIR)
	install -Dm755 filters/source.py    $(FILTER_DIR)/source.py
	install -Dm755 filters/minecraft.py $(FILTER_DIR)/minecraft.py
	install -Dm755 filters/terraria.py  $(FILTER_DIR)/terraria.py
	@if [ ! -f $(CONF_DIR)/umbrella.conf ]; then \
	    install -Dm644 umbrella.conf.example $(CONF_DIR)/umbrella.conf; \
	    echo "Installed default config to $(CONF_DIR)/umbrella.conf"; \
	fi
	@echo "Done. Edit $(CONF_DIR)/umbrella.conf and add unit files to $(UNITS_DIR)/"

clean:
	rm -f $(DAEMON_OBJS) $(CLI_OBJS) umbrella umbrella-cli