forked from netfilter-top/nftop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
96 lines (74 loc) · 2.63 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
84
85
86
87
88
89
90
91
92
93
94
95
96
CC := gcc
CFLAGS += -Wall -Wextra -pedantic -O3
CPPFLAGS += -D __FILENAME__='"$(subst $(PWD)/,,$(abspath $<))"'
BIN := $(PWD)/build/bin
SRC := $(PWD)/src
LIBRARIES := -lnetfilter_conntrack
ifeq ($(strip $(PREFIX)),)
PREFIX := /usr
endif
ifneq ($(strip $(NCURSES)),)
CFLAGS += -DENABLE_NCURSES
LIBRARIES += -l:libncurses.so.5 -l:libtinfo.so.5
endif
EXECUTABLE := nftop
SOURCES := $(wildcard $(patsubst %,%/*.c, $(SRC)))
OBJECTS := $(SOURCES:.c=.o)
TESTS := $(wildcard $(patsubst %,%/*.c, tests))
TESTS_OBJ := $(TESTS:.c=.o)
all: $(BIN)/$(EXECUTABLE)
.ONESHELL:
.PHONY: clean debug install deb-pkg
clean:
-$(RM) -r build/*
-$(RM) $(TESTS_OBJ)
-$(RM) $(OBJECTS)
-$(RM) -r debian/nftop
-$(RM) debian/nftop.debhelper.log
-$(RM) debian/nftop.substvars
-$(RM) debian/files
-$(RM) debian/debhelper-build-stamp
-$(RM) -r build/packages
debug: CFLAGS += -DDEBUG -g -ggdb3 -pg -O0
debug: $(BIN)/$(EXECUTABLE)
dump: $(BIN)/dump
$(info SOURCES: $(TESTS) OBJECTS: $(TESTS_OBJ) INCLUDES: $(CINCLUDES))
$(BIN)/dump: tests/dump.o
$(info SOURCES: $(TESTS) OBJECTS: $(TESTS_OBJ) INCLUDES: $(CINCLUDES))
$(CC) $(CFLAGS) $(CINCLUDES) $(CLIBS) $^ -o $@ $(LIBRARIES)
dump_only: $(BIN)/dump_only
$(info SOURCES: $(TESTS) OBJECTS: $(TESTS_OBJ) INCLUDES: $(CINCLUDES))
$(BIN)/dump_only: tests/dump_only.o
$(info SOURCES: $(TESTS) OBJECTS: $(TESTS_OBJ) INCLUDES: $(CINCLUDES))
$(CC) $(CFLAGS) $(CINCLUDES) $(CLIBS) $^ -o $@ $(LIBRARIES)
query_route: $(BIN)/query_route
$(info SOURCES: $(TESTS) OBJECTS: $(TESTS_OBJ) INCLUDES: $(CINCLUDES))
$(BIN)/query_route: tests/query_route.o
$(info SOURCES: $(TESTS) OBJECTS: $(TESTS_OBJ) INCLUDES: $(CINCLUDES))
$(CC) $(CFLAGS) $(CINCLUDES) $(CLIBS) $^ -o $@ $(LIBRARIES)
run: all
$(BIN)/$(EXECUTABLE)
$(BIN)/$(EXECUTABLE): $(OBJECTS)
$(info PREFIX: $(PREFIX)
SOURCES: $(SOURCES) OBJECTS: $(OBJECTS) INCLUDES: $(CINCLUDES)
CLIBS: $(CLIBS) $(LIBRARIES)
CFLAGS: $(CFLAGS))
install -d -D $(BIN)
$(CC) $(CFLAGS) $(CINCLUDES) $(CLIBS) $^ -o $@ $(LIBRARIES)
gzip -c $(SRC)/nftop.8 > $(BIN)/nftop.8.gz
install: $(BIN)/$(EXECUTABLE)
install -d $(DESTDIR)$(PREFIX)/share/man/man8
install -d $(DESTDIR)$(PREFIX)/sbin
install $(BIN)/nftop.8.gz $(DESTDIR)$(PREFIX)/share/man/man8/
install --strip $(BIN)/$(EXECUTABLE) $(DESTDIR)$(PREFIX)/sbin/
uninstall:
-$(RM) $(DESTDIR)$(PREFIX)/share/man/man8/nftop.8.gz
-$(RM) $(DESTDIR)$(PREFIX)/sbin/nftop
deb-pkg:
install -D -d build/packages
ln -s $(PWD)/Makefile build/packages/
ln -s $(PWD)/src build/packages/
ln -s $(PWD)/build/bin build/packages/
ln -s $(PWD)/debian build/packages/
cd build/packages
PREFIX=$(PREFIX) dpkg-buildpackage -rfakeroot -uc -B