master Makefile
 1CC  = cc
 2VER = 10.26
 3
 4GIT_VER   != git describe --always --tags 2>/dev/null || echo unknown
 5POSIX_DEF != test `uname` != OpenBSD && echo -D_POSIX_C_SOURCE=200809L || :
 6
 7CPPFLAGS = $(POSIX_DEF) -DGIT_VER=\"$(GIT_VER)\" -DVERSION=\"$(VER)\" $(POSIX_FLAGS)
 8CFLAGS   = -std=c99 -Wall -Wextra -Iserver/include -pthread
 9
10SRC = server/config.c \
11      server/http.c \
12      server/json.c \
13      server/parados.c \
14      server/scan.c \
15      server/users.c \
16      server/utils.c
17HDR = server/include/config.h \
18      server/include/http.h \
19      server/include/json.h \
20      server/include/log.h \
21      server/include/scan.h \
22      server/include/users.h \
23      server/include/utils.h
24OUT = parados
25
26ETCDIR  = /etc
27PREFIX  = /usr/local
28BINDIR  = $(PREFIX)/bin
29MANDIR  = $(PREFIX)/man
30MAN1DIR = $(MANDIR)/man1
31MAN5DIR = $(MANDIR)/man5
32MAN7DIR = $(MANDIR)/man7
33
34all: parados
35
36release: $(OUT)
37
38$(OUT): $(SRC) $(HDR)
39	$(CC) $(CPPFLAGS) -DNDEBUG $(CFLAGS) -O2 $(SRC) -o $(OUT)
40
41debug: $(SRC) $(HDR)
42	$(CC) $(CPPFLAGS) -DDEBUG $(CFLAGS) -g $(SRC) -o $(OUT)
43
44clean:
45	rm -f $(OUT)
46
47install: all
48	mkdir -p $(DESTDIR)$(BINDIR)
49	cp $(OUT) $(DESTDIR)$(BINDIR)/$(OUT)
50	chmod 755 $(DESTDIR)$(BINDIR)/$(OUT)
51
52	mkdir -p $(DESTDIR)$(MAN1DIR)
53	mkdir -p $(DESTDIR)$(MAN5DIR)
54	mkdir -p $(DESTDIR)$(MAN7DIR)
55
56	cp docs/parados.1 $(DESTDIR)$(MAN1DIR)/parados.1
57	cp docs/parados.conf.5 $(DESTDIR)$(MAN5DIR)/parados.conf.5
58	cp docs/parados.7 $(DESTDIR)$(MAN7DIR)/parados.7
59
60	chmod 644 $(DESTDIR)$(MAN1DIR)/parados.1
61	chmod 644 $(DESTDIR)$(MAN5DIR)/parados.conf.5
62	chmod 644 $(DESTDIR)$(MAN7DIR)/parados.7
63
64install-conf:
65	mkdir -p $(DESTDIR)$(ETCDIR)
66	cp parados.conf $(DESTDIR)$(ETCDIR)/parados.conf
67	chmod 644 $(DESTDIR)$(ETCDIR)/parados.conf
68
69install-rcctl:
70	install -m 0555 scripts/openbsd-parados.sh /etc/rc.d/parados
71
72install-openrc:
73	install -m 0555 scripts/openrc-parados /etc/init.d/parados
74
75uninstall:
76	rm -f $(DESTDIR)$(BINDIR)/$(OUT)
77	rm -f $(DESTDIR)$(MAN1DIR)/parados.1
78	rm -f $(DESTDIR)$(MAN5DIR)/parados.conf.5
79	rm -f $(DESTDIR)$(MAN7DIR)/parados.7
80
81compile_flags:
82	rm -f compile_flags.txt
83	for f in ${CPPFLAGS} ${CFLAGS}; do echo $$f >> compile_flags.txt; done
84
85.PHONY: all release debug clean install install-conf install-rcctl install-openrc uninstall compile_flags
86