Makefile revision f0797d13
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
49ifeq ($(filter yes,$(EXTENDED_TESTS)),$(EXTENDED_TESTS))
50VOM_BIN = $(addprefix $(VOM_BINDIR), /vom_test)
51VOM_CPPSRC = $(TEST_EXT_DIR)/vom_test.cpp
52
53$(VOM_BINDIR):
54	@mkdir -p $(VOM_BINDIR)
55
56LIB_VOM = -lvom
57VOM_LIBS = \
58	-L$(VPP_INSTALL_PATH)/vom/lib \
59	-lvom						\
60	-lboost_thread					\
61	-lboost_system					\
62	-lboost_filesystem				\
63	-lboost_unit_test_framework			\
64	$(VAPI_LIBS)
65
66VOM_CPPFLAGS = \
67	-I $(WS_ROOT)/src/vpp-api/ \
68	-DBOOST_LOG_DYN_LINK \
69	$(CPPFLAGS)
70
71$(VOM_BIN): $(VOM_CPPSRC) $(VOM_BINDIR)
72	$(CXX) -o $@ $(VOM_CPPFLAGS) -O0 -g $(VOM_CPPSRC) $(VOM_LIBS) -Wl,-rpath,$(VPP_INSTALL_PATH)/vom/lib
73
74$(VOM_BIN).d: $(VOM_CPPSRC) $(VOM_BINDIR)
75	$(CXX) -o $@ $(VOM_CPPFLAGS) -MM -MT '$(VOM_BIN)' $(VOM_CPPSRC) > $@
76endif
77
78.PHONY: test-apps
79test-apps: $(VAPI_CBIN) $(VAPI_CPPBIN) $(VOM_BIN)
80
81.PHONY: clean
82clean:
83	@rm -rf $(VAPI_BINDIR) $(VOM_BINDIR)
84
85ifneq ($(MAKECMDGOALS),clean)
86-include $(VAPI_CBIN).d
87ifneq ($(VAPI_CPPBIN),)
88-include $(VAPI_CPPBIN).d
89endif
90ifneq ($(VOM_BIN),)
91-include $(VOM_BIN).d
92endif
93endif
94