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 $(error variable FF_PATH is not set) 24endif 25 26DEBUG= -g 27BINARY = libmt.a 28FF_LIB=$(FF_PATH)/libfstack.a 29DPDK_LIBS = $(shell pkg-config --define-variable=TOPDIR=${FF_PATH} --libs f-stack.pc) 30 31# Comment the following line if you are not using the gnu c compiler 32#C_ARGS = -Wall -g -fPIC -D_DEBUG 33C_ARGS = -Wall -g -fPIC -O0 -DMT_REAL_TIME 34#.SUFFIXES: .o .cpp 35 36ifeq ($(ARCH),32) 37 C_ARGS += -march=pentium4 -m32 -DSUS_LINUX -pthread 38else 39 C_ARGS += -m64 -DSUS_LINUX -pthread 40endif 41# You might have to change this if your c compiler is not cc 42CC = g++ 43 44# You shouldn't need to make any more changes below this line. 45INCCOMM=-I./valgrind -I$(FF_PATH)/lib 46 47#.c.o: 48# $(CC) -c $*.c 49 50all: $(BINARY) 51 52### shell color config 53RED = \\e[1m\\e[31m 54DARKRED = \\e[31m 55GREEN = \\e[1m\\e[32m 56DARKGREEN = \\e[32m 57BLUE = \\e[1m\\e[34m 58DARKBLUE = \\e[34m 59YELLOW = \\e[1m\\e[33m 60DARKYELLOW = \\e[33m 61MAGENTA = \\e[1m\\e[35m 62DARKMAGENTA = \\e[35m 63CYAN = \\e[1m\\e[36m 64DARKCYAN = \\e[36m 65RESET = \\e[m 66CRESET = ;echo -ne \\e[m; test -s $@ 67 68%.o: %.cpp 69 @echo -e Compiling $(GREEN)$<$(RESET) ...$(RED) 70 @$(CC) $(C_ARGS) -c -o $@ $< $(INCCOMM) $(CRESET) 71 72%.o: %.c 73 @echo -e Compiling $(GREEN)$<$(RESET) ...$(RED) 74 @$(CC) $(C_ARGS) -c -o $@ $< $(INCCOMM) $(CRESET) 75 76%.o: %.S 77 @echo -e Compiling $(GREEN)$<$(RESET) ...$(RED) 78 @$(CC) $(C_ARGS) -c -o $@ $< $(INCCOMM) $(CRESET) 79 80clean: 81 @rm -f $(BINARY) *.a *.o echo 82 83 84LIB_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\ 85 mt_connection.o mt_concurrent.o mt_sys_hook.o ff_hook.o heap_timer.o mt_cache.o mt_net.o 86 87libmt.a: $(LIB_OBJ) 88 @echo -e Linking $(CYAN)$@$(RESET) ...$(RED) 89 @-rm -f $@ 90 @ar crs $@ $^ $(FST_LIB) $(CRESET) 91 @chmod +x $@ 92 93echo: echo.o libmt.a 94 @echo -e Compile $(CYAN)$@$(RESET) ...$(RED) 95 @$(CC) -O -gdwarf-2 -o $@ $^ -lstdc++ -ldl -lm $(DPDK_LIBS) $(CRESET) 96