Makefile revision e89bfe33
1TEST_EXT_DIR=$(TEST_DIR)/ext
2VAPI_BINDIR = $(TEST_BR)/vapi_test
3VAPI_CBIN = $(addprefix $(VAPI_BINDIR), /vapi_c_test)
4VAPI_CPPBIN = $(addprefix $(VAPI_BINDIR), /vapi_cpp_test)
5VOM_BINDIR = $(TEST_BR)/vom_test
6
7VAPI_LIBS = \
8  -L$(VPP_INSTALL_PATH)/vpp/lib \
9  -lvppinfra -lvlibmemoryclient -lsvm -lpthread -lcheck -lrt -lm -lvapiclient
10
11ifneq ($(filter centos opensuse opensuse-tumbleweed opensuse-leap,$(OS_ID)),$(OS_ID))
12VAPI_LIBS += -lsubunit
13endif
14
15FLAGS = -g -Wall -lstdc++ -pthread -I$(WS_ROOT)/src -I$(VPP_INSTALL_PATH)/vpp/include -I$(VAPI_BINDIR)
16CFLAGS = -std=gnu99 $(FLAGS)
17CPPFLAGS = -std=c++11 $(FLAGS) -I$(WS_ROOT)/extras/vom
18
19$(VAPI_BINDIR):
20	@mkdir -p $(VAPI_BINDIR)
21
22CSRC = $(TEST_EXT_DIR)/vapi_c_test.c
23
24$(VAPI_BINDIR)/fake.api.vapi.h: fake.api.json $(WS_ROOT)/src/vpp-api/vapi/vapi_c_gen.py | $(VAPI_BINDIR)
25	$(WS_ROOT)/src/vpp-api/vapi/vapi_c_gen.py --prefix $(VAPI_BINDIR) $<
26
27$(VAPI_BINDIR)/fake.api.vapi.hpp: fake.api.json $(WS_ROOT)/src/vpp-api/vapi/vapi_cpp_gen.py | $(VAPI_BINDIR)
28	$(WS_ROOT)/src/vpp-api/vapi/vapi_cpp_gen.py --prefix $(VAPI_BINDIR) $<
29
30$(VAPI_CBIN): $(VAPI_BINDIR) $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h
31	$(CC) -o $@ $(CFLAGS) $(CSRC) $(VAPI_LIBS)
32
33$(VAPI_CBIN).d: $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h
34	$(CC) -o $@ $(CFLAGS) -MM -MT '$(VAPI_CBIN)' $(CSRC) > $@
35
36
37ifeq ($(filter rhel centos,$(OS_ID)),$(OS_ID))
38VAPI_CPPBIN=
39else
40CPPSRC = $(TEST_EXT_DIR)/vapi_cpp_test.cpp
41
42$(VAPI_CPPBIN): $(VAPI_BINDIR) $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp
43	$(CXX) -o $@ $(CPPFLAGS) $(CPPSRC) $(VAPI_LIBS)
44
45$(VAPI_CPPBIN).d: $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp
46	$(CXX) -o $@ $(CPPFLAGS) -MM -MT '$(VAPI_CPPBIN)' $(CPPSRC) > $@
47endif
48
49ifneq ($(EXTENDED_TESTS),)
50ifeq ($(filter yes y 1,$(EXTENDED_TESTS)),$(EXTENDED_TESTS))
51VOM_BIN = $(addprefix $(VOM_BINDIR), /vom_test)
52VOM_CPPSRC = $(TEST_EXT_DIR)/vom_test.cpp
53
54$(VOM_BINDIR):
55	@mkdir -p $(VOM_BINDIR)
56
57LIB_VOM = -lvom
58VOM_LIBS = \
59	-L$(VPP_INSTALL_PATH)/vom/lib \
60	-lvom						\
61	-lboost_thread					\
62	-lboost_system					\
63	-lboost_filesystem				\
64	-lboost_unit_test_framework			\
65	$(VAPI_LIBS)
66
67VOM_CPPFLAGS = \
68	-I $(WS_ROOT)/src/vpp-api/ \
69	-DBOOST_LOG_DYN_LINK \
70	$(CPPFLAGS)
71
72$(VOM_BIN): $(VOM_CPPSRC) $(VOM_BINDIR)
73	$(CXX) -o $@ $(VOM_CPPFLAGS) -O0 -g $(VOM_CPPSRC) $(VOM_LIBS) -Wl,-rpath,$(VPP_INSTALL_PATH)/vom/lib
74
75$(VOM_BIN).d: $(VOM_CPPSRC) $(VOM_BINDIR)
76	$(CXX) -o $@ $(VOM_CPPFLAGS) -MM -MT '$(VOM_BIN)' $(VOM_CPPSRC) > $@
77endif
78endif
79
80.PHONY: test-apps
81test-apps: $(VAPI_CBIN) $(VAPI_CPPBIN) $(VOM_BIN)
82
83.PHONY: clean
84clean:
85	@rm -rf $(VAPI_BINDIR) $(VOM_BINDIR)
86
87ifneq ($(MAKECMDGOALS),clean)
88-include $(VAPI_CBIN).d
89ifneq ($(VAPI_CPPBIN),)
90-include $(VAPI_CPPBIN).d
91endif
92ifneq ($(VOM_BIN),)
93-include $(VOM_BIN).d
94endif
95endif
96