-
Notifications
You must be signed in to change notification settings - Fork 229
/
Makefile
86 lines (70 loc) · 2.61 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
# Gatekeeper - DDoS protection system.
# Copyright (C) 2016 Digirati LTDA.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
GATEKEEPER := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
APP := gatekeeper
SRCS-y := main/main.c
# Functional blocks.
SRCS-y += config/static.c config/dynamic.c
SRCS-y += cps/main.c cps/kni.c cps/rd.c
SRCS-y += ggu/main.c
SRCS-y += gk/main.c gk/rt.c gk/bpf.c
SRCS-y += gt/main.c gt/lua_lpm.c
SRCS-y += lls/main.c lls/cache.c lls/arp.c lls/nd.c
SRCS-y += sol/main.c
# Libraries.
SRCS-y += lib/mailbox.c lib/net.c lib/flow.c lib/ipip.c \
lib/launch.c lib/rib.c lib/fib.c lib/acl.c lib/varip.c \
lib/l2.c lib/ratelimit.c lib/memblock.c lib/log_ratelimit.c \
lib/coro.c lib/qid.c lib/hash.c
BUILD_DIR := build
OBJS-y := $(SRCS-y:%.c=$(BUILD_DIR)/%.o)
DEPS-y := $(OBJS-y:%.o=%.d)
# Build using pkg-config variables if possible
ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
$(error "no installation of DPDK found")
endif
PKGCONF ?= pkg-config
PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
CFLAGS += -O3 -g $(shell $(PKGCONF) --cflags libdpdk) \
-DALLOW_EXPERIMENTAL_API -DCORO_ASM \
-Wall -Wextra -Wno-packed-not-aligned -Wno-address-of-packed-member \
-Wfatal-errors $(WERROR_FLAGS) \
-I${GATEKEEPER}include -I/usr/local/include/luajit-2.0/
LDLIBS += $(LDIR) -rdynamic -L/usr/local/lib/ -lluajit-5.1 -ldl \
-lm -lmnl -lkmod -lcap -lrte_net_bond
LDFLAGS_SHARED := $(shell $(PKGCONF) --libs libdpdk) $(LDLIBS)
LDFLAGS_STATIC := $(shell $(PKGCONF) --static --libs libdpdk) $(LDLIBS)
LINK = $(CC) -o $@ $(OBJS-y) $(LDFLAGS) $(LDFLAGS_STATIC)
COMPILE = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MMD -c $< -o $@
$(BUILD_DIR)/$(APP): $(OBJS-y) Makefile $(PC_FILE) | $(BUILD_DIR)
@echo "LINK\t$@"
@echo $(LINK) > [email protected]
@$(LINK)
$(BUILD_DIR)/%.o: %.c
@echo "CC\t$@"
@[ -d $(@D) ] || mkdir -p $(@D)
@echo $(COMPILE) > $(patsubst %.o,%.cc,$@)
@$(COMPILE)
$(BUILD_DIR):
@mkdir -p $@
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
.PHONY: cscope
cscope:
cscope -b -R -s.
# Include dependencies on header files.
-include $(DEPS-y)