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