-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
148 lines (110 loc) · 3.22 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
MKDIR = mkdir -p
CC = gcc
CXX = g++ -std=c++11
CP = cp
RM = rm -rf
#Name of executable file to generate
APP = probe
#get git version abbrev
GIT_VERSION := $(shell git log --format="%h" -n 1)
VERSION := 1.4.4
ifndef TOP_DIR
#current directory
TOP_DIR := $(shell pwd)
#we need to export this variable for the second call by DPDK, eventually
export TOP_DIR
endif
SRC_DIR := $(TOP_DIR)/src
#installation directory
ifndef MMT_BASE
MMT_BASE := /opt/mmt
NEED_ROOT_PERMISSION := 1
else
$(info Set default folder of MMT to $(MMT_BASE))
endif
INSTALL_DIR := $(MMT_BASE)/probe
# Directory where MMT-Security was installed
MMT_SECURITY_DIR ?= $(MMT_BASE)/security
# Directory where MMT-DPI was installed
MMT_DPI_DIR ?= $(MMT_BASE)/dpi
$(info MMT-Probe version $(VERSION) $(GIT_VERSION) ($(MAKECMDGOALS)))
#build is not a file target,
.PHONY: compile
#default target
.DEFAULT_GOAL := compile
#set of libraries
LIBS := -L$(MMT_DPI_DIR)/lib -lpthread
CFLAGS := -I$(MMT_DPI_DIR)/include -Wall -Wno-unused-variable\
-DVERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DMMT_BASE=\"$(MMT_BASE)\"
CLDFLAGS += -rdynamic
#intermediate targets
#This function will create a dummy target naming by its first parameter, e.g., VERBOSE
# when user call the target, it will set an environment variable having the same name
# Example:
# $(eval $(call EXPORT_TARGET,VERBOSE))
# => when user do: make VERBOSE
# => env variable VERBOSE will be defined to 1
define EXPORT_TARGET
$(1): ;@:
ifneq (,$(findstring $(1),$(MAKECMDGOALS)))
export $(1)=1
endif
endef
# embedded MMT libraries into probe
# we need to explicitly indicate either static or dynamic library
$(eval $(call EXPORT_TARGET,STATIC_LINK))
#always embeddes libconfuse to probe
LIBS += -l:libconfuse.a
ifdef STATIC_LINK
CFLAGS += -DSTATIC_LINK
LIBS += -l:libmmt_tcpip.a -l:libmmt_core.a
else
LIBS += -l:libmmt_core.so
endif
# to print more details of compiling process
$(eval $(call EXPORT_TARGET,VERBOSE))
ifndef VERBOSE
QUIET := @
endif
# to enable debug information, e.g., to be able to used by gdb
$(eval $(call EXPORT_TARGET,DEBUG))
ifdef DEBUG
$(info - Enable DEBUG)
CFLAGS += -g -O0 -DDEBUG_MODE
else
CFLAGS += -O3
endif
#for valgrind check
ifdef VALGRIND
CFLAGS += -DVALGRIND_MODE
endif
# For showing message from debug(...)
ifndef NDEBUG
CFLAGS += -DNDEBUG
endif
-include mk/gperf.mk
-include mk/modules.mk
$(MMT_DPI_DIR):
$(error ERROR: Not found MMT-DPI at folder $(MMT_DPI_DIR))
.PHONY: --check-dpi-folder
# check if there exists the folder of MMT-DPI
--check-dpi-folder: $(MMT_DPI_DIR)
CFLAGS += $(MODULE_FLAGS)
LIBS += $(MODULE_LIBS)
# main source file
MAIN_SRCS := $(SRC_DIR)/main.c
#source files in lib/
LIB_SRCS = $(wildcard $(SRC_DIR)/lib/*.c) \
$(SRC_DIR)/configure.c $(SRC_DIR)/configure_override.c $(SRC_DIR)/worker.c
#all source code
ALL_SRCS := $(LIB_SRCS) $(MODULE_SRCS) $(MAIN_SRCS)
ifdef NEED_DPDK
#use makefiles of dpdk
#we need explicitly TOP_DIR as this line will be called second times from ./build folder by dpdk
-include $(TOP_DIR)/mk/compile-dpdk.mk
else
-include mk/compile-pcap.mk
endif
#other makefiles
-include mk/serial-key.mk
-include mk/install-package.mk