Makefile revision b8f1ef2b
1# Copyright (c) 2016 Intel Corporation.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at:
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14ifeq ($(RTE_SDK),)
15$(error "Please define RTE_SDK environment variable")
16endif
17
18ifeq ($(GTEST_DIR),)
19all:
20	@echo "GTEST_DIR is not setup properly. Skipping gtest"
21
22%::
23	@echo "GTEST_DIR is not setup properly. Skipping gtest"
24
25else
26
27# Default target, can be overridden by command line or environment
28RTE_TARGET ?= x86_64-native-linuxapp-gcc
29
30include $(RTE_SDK)/mk/rte.vars.mk
31
32CUR_SUBDIR ?= .
33
34# we must create the output dir first and recall the same Makefile
35# from this directory
36ifeq ($(NOT_FIRST_CALL),)
37
38NOT_FIRST_CALL = 1
39export NOT_FIRST_CALL
40
41
42BDIR := $(RTE_OUTPUT)/build/$(CUR_SUBDIR)
43
44all:
45	$(Q)mkdir -p $(BDIR)
46	$(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \
47		S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) X=obj
48	$(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \
49		S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) X=app
50
51%::
52	$(Q)mkdir -p $(BDIR)
53	$(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) $@ \
54		S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) X=obj
55	$(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) $@ \
56		S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR) X=app
57else
58
59#
60# building object
61#
62
63ifeq ($(X),obj)
64include $(TLDK_ROOT)/mk/tle.cpp-vars.mk
65
66# binary name
67OBJ = gtest-rfc.o
68
69# all source are stored in SRCS-y
70SRCS-y += main.cpp
71SRCS-y += test_common.cpp
72SRCS-y += test_tle_dring.cpp
73SRCS-y += test_tle_ctx.cpp
74#SRCS-y += test_tle_udp_dev.cpp
75SRCS-y += test_tle_udp_destroy.cpp
76SRCS-y += test_tle_udp_event.cpp
77#SRCS-y += test_tle_udp_stream.cpp
78SRCS-y += test_tle_udp_stream_gen.cpp
79SRCS-y += test_tle_tcp_stream.cpp
80#SRCS-y += test_tle_tcp_stream_gen.cpp
81
82SYMLINK-y-app += test_scapy_gen.py
83
84CXXFLAGS += -std=c++11
85
86ifeq ($(shell test $(GCC_VERSION) -lt 50 && echo 1), 1)
87CXXFLAGS += -D __STDC_FORMAT_MACROS
88endif
89
90CXXFLAGS += -I$(GTEST_DIR)/include
91CXXFLAGS += -I$(GMOCK_DIR)/include
92CXXFLAGS += -I$(RTE_OUTPUT)/include
93
94CXXFLAGS += $(EXTRA_CFLAGS)
95
96LDFLAGS += -lstdc++
97LDFLAGS += -L$(GMOCK_DIR) -L$(GMOCK_DIR)/../lib -lgmock
98LDLIBS += -whole-archive -ltle_l4p -ltle_dring
99
100include $(TLDK_ROOT)/mk/tle.cpp-obj.mk
101endif
102
103#
104# building app
105#
106
107ifeq ($(X),app)
108
109# binary name
110APP = gtest-rfc
111
112# all source are stored in SRCS-y
113
114CFLAGS += -O3
115
116ifeq ($(shell test $(GCC_VERSION) -lt 50 && echo 1), 1)
117CFLAGS += -D __STDC_FORMAT_MACROS
118endif
119
120CFLAGS += $(WERROR_FLAGS)
121
122LDLIBS += gtest-rfc.o
123
124LDLIBS += -lstdc++
125LDLIBS += -L$(GMOCK_DIR) -L$(GMOCK_DIR)/../lib -lgmock
126LDLIBS += -L$(GMOCK_DIR)/gtest -L$(GMOCK_DIR)/../lib -lgtest
127LDLIBS += -L$(RTE_OUTPUT)/lib
128LDLIBS += -whole-archive -ltle_l4p -ltle_dring -ltle_memtank -ltle_timer
129
130include $(TLDK_ROOT)/mk/tle.app.mk
131endif
132
133endif
134endif
135