blob: cbb706528e23c6641f7337244f617410340198eb [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
Dave Wallacef0797d12019-11-15 17:29:15 -050030$(VAPI_CBIN): $(VAPI_BINDIR) $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h
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
Dave Wallacef0797d12019-11-15 17:29:15 -050042$(VAPI_CPPBIN): $(VAPI_BINDIR) $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp
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 Wallacef0797d12019-11-15 17:29:15 -050049ifeq ($(filter yes,$(EXTENDED_TESTS)),$(EXTENDED_TESTS))
50VOM_BIN = $(addprefix $(VOM_BINDIR), /vom_test)
51VOM_CPPSRC = $(TEST_EXT_DIR)/vom_test.cpp
Neale Ranns812ed392017-10-16 04:20:13 -070052
53$(VOM_BINDIR):
Dave Wallacef0797d12019-11-15 17:29:15 -050054 @mkdir -p $(VOM_BINDIR)
Neale Ranns812ed392017-10-16 04:20:13 -070055
Damjan Marion164e5f82018-04-25 19:11:15 +020056LIB_VOM = -lvom
57VOM_LIBS = \
Klement Sekerab8c72a42018-11-08 11:21:39 +010058 -L$(VPP_INSTALL_PATH)/vom/lib \
Damjan Marion164e5f82018-04-25 19:11:15 +020059 -lvom \
Neale Ranns812ed392017-10-16 04:20:13 -070060 -lboost_thread \
61 -lboost_system \
62 -lboost_filesystem \
63 -lboost_unit_test_framework \
64 $(VAPI_LIBS)
65
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070066VOM_CPPFLAGS = \
67 -I $(WS_ROOT)/src/vpp-api/ \
Damjan Marion164e5f82018-04-25 19:11:15 +020068 -DBOOST_LOG_DYN_LINK \
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070069 $(CPPFLAGS)
70
Damjan Marion164e5f82018-04-25 19:11:15 +020071$(VOM_BIN): $(VOM_CPPSRC) $(VOM_BINDIR)
Klement Sekerab8c72a42018-11-08 11:21:39 +010072 $(CXX) -o $@ $(VOM_CPPFLAGS) -O0 -g $(VOM_CPPSRC) $(VOM_LIBS) -Wl,-rpath,$(VPP_INSTALL_PATH)/vom/lib
Damjan Marion164e5f82018-04-25 19:11:15 +020073
74$(VOM_BIN).d: $(VOM_CPPSRC) $(VOM_BINDIR)
75 $(CXX) -o $@ $(VOM_CPPFLAGS) -MM -MT '$(VOM_BIN)' $(VOM_CPPSRC) > $@
Damjan Marion164e5f82018-04-25 19:11:15 +020076endif
77
Dave Wallacef0797d12019-11-15 17:29:15 -050078.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