This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (61 loc) · 1.82 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
72
73
74
75
76
77
78
79
80
81
82
83
# OH, HAI! :)
VERSION := 1.8
CC ?= gcc
CFLAGS ?= -Wall -s -march=native -mtune=native -O2 -pipe -fstack-protector-strong
PREFIX ?= /usr/local
SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin/
MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
CONFDIR ?= $(DESTDIR)/etc/
SCDOC8 := $(wildcard man/*.8.md)
MAN8 := $(SCDOC8:.8.md=.8)
ZMAN8 := $(MAN8:.8=.8.gz)
SCDOC5 := $(wildcard man/*.5.md)
MAN5 := $(SCDOC5:.5.md=.5)
ZMAN5 := $(MAN5:.5=.5.gz)
SCDOCS := $(SCDOC8) $(SCDOC5)
MANPAGES := $(MAN8) $(MAN5)
ZMANPAGES := $(ZMAN8) $(ZMAN5)
SRC := $(wildcard src/*.[ch])
BIN := bin/icmplog bin/tcplog
COMMON := src/global.h src/common.h src/common.c
ICMPCONF := /etc/icmplog.conf
TCPCONF := /etc/tcplog.conf
CONFIGS := $(wildcard etc/*.conf)
CONFSTR := -DICMPLOG_CONF='"$(ICMPCONF)"' -DTCPLOG_CONF='"$(TCPCONF)"'
VERSTR := -DVERSION='"$(VERSION)"'
INSTALL ?= install
STRIP ?= strip
SCDOC ?= scdoc
GZIP ?= gzip
.PHONY: all
all: jail $(MANPAGES)
jail: $(BIN)
$(STRIP) $(BIN)
install: $(BIN) $(CONFIGS) $(ZMANPAGES)
@test -d $(SBINDIR) || mkdir -p $(SBINDIR)
$(INSTALL) -s $(BIN) $(SBINDIR)
@test -d $(CONFDIR) || mkdir -p $(CONFDIR)
$(INSTALL) -m 0644 $(CONFIGS) $(CONFDIR)
@test -d $(MANDIR)/man8 || mkdir $(MANDIR)/man8
$(INSTALL) -m 0644 $(ZMAN8) $(MANDIR)/man8/
@test -d $(MANDIR)/man5 || mkdir $(MANDIR)/man5
$(INSTALL) -m 0644 $(ZMAN5) $(MANDIR)/man5/
src/common.o: $(COMMON)
$(CC) $(CFLAGS) -c -o src/common.o src/common.c
bin/%: src/%.c src/%.h src/common.o
$(CC) $(CFLAGS) $(LDFLAGS) $(CONFSTR) $(VERSTR) -o $@ $< src/common.o
man/%.8: man/%.8.md
$(SCDOC) <$< >$@
man/%.8.gz: man/%.8
$(GZIP) -c $< >$@
man/%.5: man/%.5.md
$(SCDOC) <$< >$@
man/%.5.gz: man/%.5
$(GZIP) -c $< >$@
.PHONY: clean
clean:
rm -f $(BIN)
rm -f $(ZMANPAGES)
rm -f src/*.o
rm -f *~ */*~
# EOF