blob: d7acb7bc2b289db0b31dcae7084f1ec75834bb50 [file] [log] [blame]
Dave Wallacef0797d12019-11-15 17:29:15 -05001TEST_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
Klement Sekerabe2c2a82019-09-02 15:19:41 +00006
Damjan Marion164e5f82018-04-25 19:11:15 +02007VAPI_LIBS = \
Klement Sekerab8c72a42018-11-08 11:21:39 +01008 -L$(VPP_INSTALL_PATH)/vpp/lib \
Damjan Marion164e5f82018-04-25 19:11:15 +02009 -lvppinfra -lvlibmemoryclient -lsvm -lpthread -lcheck -lrt -lm -lvapiclient
10
Marco Varlese7220f422018-05-07 15:40:45 +020011ifneq ($(filter centos opensuse opensuse-tumbleweed opensuse-leap,$(OS_ID)),$(OS_ID))
Neale Ranns812ed392017-10-16 04:20:13 -070012VAPI_LIBS += -lsubunit
Marco Varlese5f1231c2017-10-10 16:43:14 +020013endif
Klement Sekeradc15be22017-06-12 06:49:33 +020014
Klement Sekerab8c72a42018-11-08 11:21:39 +010015FLAGS = -g -Wall -lstdc++ -pthread -I$(WS_ROOT)/src -I$(VPP_INSTALL_PATH)/vpp/include -I$(VAPI_BINDIR)
Damjan Marion164e5f82018-04-25 19:11:15 +020016CFLAGS = -std=gnu99 $(FLAGS)
17CPPFLAGS = -std=c++11 $(FLAGS) -I$(WS_ROOT)/extras/vom
18
Neale Ranns812ed392017-10-16 04:20:13 -070019$(VAPI_BINDIR):
Dave Wallacef0797d12019-11-15 17:29:15 -050020 @mkdir -p $(VAPI_BINDIR)
Klement Sekera8f2a4ea2017-05-04 06:15:18 +020021
Dave Wallacef0797d12019-11-15 17:29:15 -050022CSRC = $(TEST_EXT_DIR)/vapi_c_test.c
Klement Sekera8f2a4ea2017-05-04 06:15:18 +020023
Neale Ranns812ed392017-10-16 04:20:13 -070024$(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) $<
Klement Sekeradc15be22017-06-12 06:49:33 +020026
Neale Ranns812ed392017-10-16 04:20:13 -070027$(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) $<
Klement Sekeradc15be22017-06-12 06:49:33 +020029
Klement Sekerade57ca32020-03-12 12:30:21 +010030$(VAPI_CBIN): $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h | $(VAPI_BINDIR)
Neale Ranns812ed392017-10-16 04:20:13 -070031 $(CC) -o $@ $(CFLAGS) $(CSRC) $(VAPI_LIBS)
Klement Sekeradc15be22017-06-12 06:49:33 +020032
Sirshak Das41141d52018-05-18 13:14:52 -050033$(VAPI_CBIN).d: $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h
Damjan Marion164e5f82018-04-25 19:11:15 +020034 $(CC) -o $@ $(CFLAGS) -MM -MT '$(VAPI_CBIN)' $(CSRC) > $@
35
36
Dave Wallacef0797d12019-11-15 17:29:15 -050037ifeq ($(filter rhel centos,$(OS_ID)),$(OS_ID))
38VAPI_CPPBIN=
39else
40CPPSRC = $(TEST_EXT_DIR)/vapi_cpp_test.cpp
Klement Sekeradc15be22017-06-12 06:49:33 +020041
Klement Sekerade57ca32020-03-12 12:30:21 +010042$(VAPI_CPPBIN): $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp | $(VAPI_BINDIR)
Neale Ranns812ed392017-10-16 04:20:13 -070043 $(CXX) -o $@ $(CPPFLAGS) $(CPPSRC) $(VAPI_LIBS)
44
Sirshak Das41141d52018-05-18 13:14:52 -050045$(VAPI_CPPBIN).d: $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp
Damjan Marion164e5f82018-04-25 19:11:15 +020046 $(CXX) -o $@ $(CPPFLAGS) -MM -MT '$(VAPI_CPPBIN)' $(CPPSRC) > $@
Dave Wallacef0797d12019-11-15 17:29:15 -050047endif
Damjan Marion164e5f82018-04-25 19:11:15 +020048
Dave Wallacee89bfe32019-12-04 18:29:39 -050049ifneq ($(EXTENDED_TESTS),)
50ifeq ($(filter yes y 1,$(EXTENDED_TESTS)),$(EXTENDED_TESTS))
Dave Wallacef0797d12019-11-15 17:29:15 -050051VOM_BIN = $(addprefix $(VOM_BINDIR), /vom_test)
52VOM_CPPSRC = $(TEST_EXT_DIR)/vom_test.cpp
Neale Ranns812ed392017-10-16 04:20:13 -070053
54$(VOM_BINDIR):
Dave Wallacef0797d12019-11-15 17:29:15 -050055 @mkdir -p $(VOM_BINDIR)
Neale Ranns812ed392017-10-16 04:20:13 -070056
Damjan Marion164e5f82018-04-25 19:11:15 +020057LIB_VOM = -lvom
58VOM_LIBS = \
Klement Sekerab8c72a42018-11-08 11:21:39 +010059 -L$(VPP_INSTALL_PATH)/vom/lib \
Damjan Marion164e5f82018-04-25 19:11:15 +020060 -lvom \
Neale Ranns812ed392017-10-16 04:20:13 -070061 -lboost_thread \
62 -lboost_system \
63 -lboost_filesystem \
64 -lboost_unit_test_framework \
65 $(VAPI_LIBS)
66
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070067VOM_CPPFLAGS = \
68 -I $(WS_ROOT)/src/vpp-api/ \
Damjan Marion164e5f82018-04-25 19:11:15 +020069 -DBOOST_LOG_DYN_LINK \
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070070 $(CPPFLAGS)
71
Damjan Marion164e5f82018-04-25 19:11:15 +020072$(VOM_BIN): $(VOM_CPPSRC) $(VOM_BINDIR)
Klement Sekerab8c72a42018-11-08 11:21:39 +010073 $(CXX) -o $@ $(VOM_CPPFLAGS) -O0 -g $(VOM_CPPSRC) $(VOM_LIBS) -Wl,-rpath,$(VPP_INSTALL_PATH)/vom/lib
Damjan Marion164e5f82018-04-25 19:11:15 +020074
75$(VOM_BIN).d: $(VOM_CPPSRC) $(VOM_BINDIR)
76 $(CXX) -o $@ $(VOM_CPPFLAGS) -MM -MT '$(VOM_BIN)' $(VOM_CPPSRC) > $@
Damjan Marion164e5f82018-04-25 19:11:15 +020077endif
Dave Wallacee89bfe32019-12-04 18:29:39 -050078endif
Damjan Marion164e5f82018-04-25 19:11:15 +020079
Dave Wallacef0797d12019-11-15 17:29:15 -050080.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