9b1341d4da7b4a11e3de49fd7db501d7c4c5eb17
[tldk.git] / test / gtest / Makefile
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
14 ifeq ($(RTE_SDK),)
15 $(error "Please define RTE_SDK environment variable")
16 endif
17
18 ifeq ($(GTEST_DIR),)
19 all:
20         @echo "GTEST_DIR is not setup properly. Skipping gtest"
21
22 %::
23         @echo "GTEST_DIR is not setup properly. Skipping gtest"
24
25 else
26
27 # Default target, can be overridden by command line or environment
28 RTE_TARGET ?= x86_64-native-linuxapp-gcc
29
30 include $(RTE_SDK)/mk/rte.vars.mk
31
32 CUR_SUBDIR ?= .
33
34 # we must create the output dir first and recall the same Makefile
35 # from this directory
36 ifeq ($(NOT_FIRST_CALL),)
37
38 NOT_FIRST_CALL = 1
39 export NOT_FIRST_CALL
40
41
42 BDIR := $(RTE_OUTPUT)/build/$(CUR_SUBDIR)
43
44 all:
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
57 else
58
59 #
60 # building object
61 #
62
63 ifeq ($(X),obj)
64 include $(TLDK_ROOT)/mk/tle.cpp-vars.mk
65
66 # binary name
67 OBJ = gtest-rfc.o
68
69 # all source are stored in SRCS-y
70 SRCS-y += main.cpp
71 SRCS-y += test_common.cpp
72 SRCS-y += test_tle_dring.cpp
73 SRCS-y += test_tle_ctx.cpp
74 #SRCS-y += test_tle_udp_dev.cpp
75 SRCS-y += test_tle_udp_destroy.cpp
76 SRCS-y += test_tle_udp_event.cpp
77 #SRCS-y += test_tle_udp_stream.cpp
78 SRCS-y += test_tle_udp_stream_gen.cpp
79 #SRCS-y += test_tle_tcp_stream.cpp
80 #SRCS-y += test_tle_tcp_stream_gen.cpp
81
82 SYMLINK-y-app += test_scapy_gen.py
83
84 CXXFLAGS += -std=c++11
85
86 ifeq ($(shell test $(GCC_VERSION) -lt 50 && echo 1), 1)
87 CXXFLAGS += -D __STDC_FORMAT_MACROS
88 endif
89
90 CXXFLAGS += -I$(GTEST_DIR)/include
91 CXXFLAGS += -I$(GMOCK_DIR)/include
92 CXXFLAGS += -I$(RTE_OUTPUT)/include
93
94 LDFLAGS += -lstdc++
95 LDFLAGS += -L$(GMOCK_DIR) -lgmock
96 LDLIBS += -whole-archive -ltle_l4p -ltle_dring
97
98 include $(TLDK_ROOT)/mk/tle.cpp-obj.mk
99 endif
100
101 #
102 # building app
103 #
104
105 ifeq ($(X),app)
106
107 # binary name
108 APP = gtest-rfc
109
110 # all source are stored in SRCS-y
111
112 CFLAGS += -O3
113
114 ifeq ($(shell test $(GCC_VERSION) -lt 50 && echo 1), 1)
115 CFLAGS += -D __STDC_FORMAT_MACROS
116 endif
117
118 CFLAGS += $(WERROR_FLAGS)
119
120 LDLIBS += gtest-rfc.o
121
122 LDLIBS += -lstdc++
123 LDLIBS += -L$(GMOCK_DIR) -lgmock
124 LDLIBS += -L$(RTE_OUTPUT)/lib
125 LDLIBS += -whole-archive -ltle_l4p -ltle_dring -ltle_timer
126
127 include $(TLDK_ROOT)/mk/tle.app.mk
128 endif
129
130 endif
131 endif