1 2# 3# Tencent is pleased to support the open source community by making MSEC available. 4# 5# Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 6# 7# Licensed under the GNU General Public License, Version 2.0 (the "License"); 8# you may not use this file except in compliance with the License. You may 9# obtain a copy of the License at 10# 11# https://opensource.org/licenses/GPL-2.0 12# 13# Unless required by applicable law or agreed to in writing, software distributed under the 14# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15# either express or implied. See the License for the specific language governing permissions 16# and limitations under the License. 17# 18 19 20########MAKEFILE########## 21 22ifeq ($(FF_PATH),) 23 FF_PATH=/usr/local 24 $(warning FF_PATH environment variable not defined, default FF_PATH=/usr/local) 25endif 26 27ifneq ($(shell pkg-config --exists libdpdk && echo 0),0) 28$(error "no installation of DPDK found, maybe you shuld export environment variable `PKG_CONFIG_PATH`") 29endif 30 31PKGCONF ?= pkg-config 32 33DEBUG= -g 34BINARY = libmt.a 35FF_LIBS+= $(shell $(PKGCONF) --static --libs libdpdk) 36FF_LIBS+= -L${FF_PATH}/lib -Wl,--whole-archive,-lfstack,--no-whole-archive 37FF_LIBS+= -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto -lpthread -lnuma 38 39# Comment the following line if you are not using the gnu c compiler 40#C_ARGS = -Wall -g -fPIC -D_DEBUG 41C_ARGS = -Wall -g -fPIC -O0 -DMT_REAL_TIME 42#.SUFFIXES: .o .cpp 43 44ifeq ($(ARCH),32) 45 C_ARGS += -march=pentium4 -m32 -DSUS_LINUX -pthread 46else 47 C_ARGS += -m64 -DSUS_LINUX -pthread 48endif 49# You might have to change this if your c compiler is not cc 50CC = g++ 51 52# You shouldn't need to make any more changes below this line. 53INCCOMM=-I./valgrind -I$(FF_PATH)/lib 54 55#.c.o: 56# $(CC) -c $*.c 57 58all: $(BINARY) 59 60### shell color config 61RED = \\e[1m\\e[31m 62DARKRED = \\e[31m 63GREEN = \\e[1m\\e[32m 64DARKGREEN = \\e[32m 65BLUE = \\e[1m\\e[34m 66DARKBLUE = \\e[34m 67YELLOW = \\e[1m\\e[33m 68DARKYELLOW = \\e[33m 69MAGENTA = \\e[1m\\e[35m 70DARKMAGENTA = \\e[35m 71CYAN = \\e[1m\\e[36m 72DARKCYAN = \\e[36m 73RESET = \\e[m 74CRESET = ;echo -ne \\e[m; test -s $@ 75 76%.o: %.cpp 77 @echo -e Compiling $(GREEN)$<$(RESET) ...$(RED) 78 @$(CC) $(C_ARGS) -c -o $@ $< $(INCCOMM) $(CRESET) 79 80%.o: %.c 81 @echo -e Compiling $(GREEN)$<$(RESET) ...$(RED) 82 @$(CC) $(C_ARGS) -c -o $@ $< $(INCCOMM) $(CRESET) 83 84%.o: %.S 85 @echo -e Compiling $(GREEN)$<$(RESET) ...$(RED) 86 @$(CC) $(C_ARGS) -c -o $@ $< $(INCCOMM) $(CRESET) 87 88clean: 89 @rm -f $(BINARY) *.a *.o echo 90 91 92LIB_OBJ = micro_thread.o kqueue_proxy.o arch_ctx.o mt_session.o mt_notify.o mt_action.o mt_mbuf_pool.o mt_api.o\ 93 mt_connection.o mt_concurrent.o mt_sys_hook.o ff_hook.o heap_timer.o mt_cache.o mt_net.o 94 95libmt.a: $(LIB_OBJ) 96 @echo -e Linking $(CYAN)$@$(RESET) ...$(RED) 97 @-rm -f $@ 98 @ar crs $@ $^ $(CRESET) 99 @chmod +x $@ 100 101echo: echo.o libmt.a 102 @echo -e Compile $(CYAN)$@$(RESET) ...$(RED) 103 @$(CC) -O -gdwarf-2 -o $@ $^ -lstdc++ -ldl -lm $(FF_LIBS) $(CRESET) 104