xref: /f-stack/app/micro_thread/Makefile (revision 5af66259)
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),)
23*5af66259Sjfb8856606    FF_PATH=/usr/local
24*5af66259Sjfb8856606    $(warning FF_PATH environment variable not defined, default FF_PATH=/usr/local)
25a9643ea8Slogwangendif
26a9643ea8Slogwang
275ac59bc4Slogwangifeq ($(FF_DPDK),)
28*5af66259Sjfb8856606    FF_DPDK=/usr/local
29*5af66259Sjfb8856606    $(warning FF_DPDK environment variable not defined, default FF_DPDK=/usr/local)
305ac59bc4Slogwangendif
315ac59bc4Slogwang
32a9643ea8SlogwangDEBUG= -g
33a9643ea8SlogwangBINARY = libmt.a
342bfe3f2eSlogwangFF_LIBS+= -L${FF_PATH}/lib -Wl,--whole-archive,-lfstack,--no-whole-archive
352bfe3f2eSlogwangFF_LIBS+= -L${FF_DPDK}/lib -Wl,--whole-archive,-ldpdk,--no-whole-archive
362bfe3f2eSlogwangFF_LIBS+= -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto -lpthread -lnuma
37a9643ea8Slogwang
38a9643ea8Slogwang# Comment the following line if you are not using the gnu c compiler
39a9643ea8Slogwang#C_ARGS = -Wall -g -fPIC -D_DEBUG
40a9643ea8SlogwangC_ARGS = -Wall -g -fPIC -O0 -DMT_REAL_TIME
41a9643ea8Slogwang#.SUFFIXES: .o .cpp
42a9643ea8Slogwang
43a9643ea8Slogwangifeq ($(ARCH),32)
44a9643ea8Slogwang	C_ARGS +=  -march=pentium4 -m32 -DSUS_LINUX -pthread
45a9643ea8Slogwangelse
46a9643ea8Slogwang	C_ARGS +=  -m64 -DSUS_LINUX -pthread
47a9643ea8Slogwangendif
48a9643ea8Slogwang# You might have to change this if your c compiler is not cc
49a9643ea8SlogwangCC = g++
50a9643ea8Slogwang
51a9643ea8Slogwang# You shouldn't need to make any more changes below this line.
52a9643ea8SlogwangINCCOMM=-I./valgrind -I$(FF_PATH)/lib
53a9643ea8Slogwang
54a9643ea8Slogwang#.c.o:
55a9643ea8Slogwang#	$(CC) -c $*.c
56a9643ea8Slogwang
57a9643ea8Slogwangall:	$(BINARY)
58a9643ea8Slogwang
59a9643ea8Slogwang### shell color config
60a9643ea8SlogwangRED = \\e[1m\\e[31m
61a9643ea8SlogwangDARKRED = \\e[31m
62a9643ea8SlogwangGREEN = \\e[1m\\e[32m
63a9643ea8SlogwangDARKGREEN = \\e[32m
64a9643ea8SlogwangBLUE = \\e[1m\\e[34m
65a9643ea8SlogwangDARKBLUE = \\e[34m
66a9643ea8SlogwangYELLOW = \\e[1m\\e[33m
67a9643ea8SlogwangDARKYELLOW = \\e[33m
68a9643ea8SlogwangMAGENTA = \\e[1m\\e[35m
69a9643ea8SlogwangDARKMAGENTA = \\e[35m
70a9643ea8SlogwangCYAN = \\e[1m\\e[36m
71a9643ea8SlogwangDARKCYAN = \\e[36m
72a9643ea8SlogwangRESET = \\e[m
73a9643ea8SlogwangCRESET =  ;echo -ne \\e[m; test -s $@
74a9643ea8Slogwang
75a9643ea8Slogwang%.o: %.cpp
76a9643ea8Slogwang	@echo -e Compiling $(GREEN)$<$(RESET) ...$(RED)
77a9643ea8Slogwang	@$(CC) $(C_ARGS) -c -o $@ $< $(INCCOMM) $(CRESET)
78a9643ea8Slogwang
79a9643ea8Slogwang%.o: %.c
80a9643ea8Slogwang	@echo -e Compiling $(GREEN)$<$(RESET) ...$(RED)
81a9643ea8Slogwang	@$(CC) $(C_ARGS) -c -o $@ $< $(INCCOMM) $(CRESET)
82a9643ea8Slogwang
83a9643ea8Slogwang%.o: %.S
84a9643ea8Slogwang	@echo -e Compiling $(GREEN)$<$(RESET) ...$(RED)
85a9643ea8Slogwang	@$(CC) $(C_ARGS) -c -o $@ $< $(INCCOMM) $(CRESET)
86a9643ea8Slogwang
87a9643ea8Slogwangclean:
88a9643ea8Slogwang	@rm -f $(BINARY) *.a *.o echo
89a9643ea8Slogwang
90a9643ea8Slogwang
91a9643ea8SlogwangLIB_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\
92a9643ea8Slogwang	 mt_connection.o mt_concurrent.o mt_sys_hook.o ff_hook.o heap_timer.o  mt_cache.o  mt_net.o
93a9643ea8Slogwang
94a9643ea8Slogwanglibmt.a: $(LIB_OBJ)
95a9643ea8Slogwang	@echo -e  Linking $(CYAN)$@$(RESET) ...$(RED)
96a9643ea8Slogwang	@-rm -f $@
975ac59bc4Slogwang	@ar crs  $@  $^ $(CRESET)
98a9643ea8Slogwang	@chmod +x $@
99a9643ea8Slogwang
100a9643ea8Slogwangecho: echo.o libmt.a
101a9643ea8Slogwang	@echo -e Compile $(CYAN)$@$(RESET) ...$(RED)
1025ac59bc4Slogwang	@$(CC) -O -gdwarf-2 -o $@ $^ -lstdc++ -ldl -lm $(FF_LIBS) $(CRESET)
103