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