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