blob: 9c9791b13649cec2fd17901f73291d30079966bd [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)
Klement Sekerabe2c2a82019-09-02 15:19:41 +00005
Damjan Marion164e5f82018-04-25 19:11:15 +02006VAPI_LIBS = \
Klement Sekerab8c72a42018-11-08 11:21:39 +01007 -L$(VPP_INSTALL_PATH)/vpp/lib \
Damjan Marion164e5f82018-04-25 19:11:15 +02008 -lvppinfra -lvlibmemoryclient -lsvm -lpthread -lcheck -lrt -lm -lvapiclient
9
Dave Wallacebc35f462020-09-18 15:35:01 +000010ifneq ($(filter centos,$(OS_ID)),$(OS_ID))
Neale Ranns812ed392017-10-16 04:20:13 -070011VAPI_LIBS += -lsubunit
Marco Varlese5f1231c2017-10-10 16:43:14 +020012endif
Klement Sekeradc15be22017-06-12 06:49:33 +020013
Klement Sekerab8c72a42018-11-08 11:21:39 +010014FLAGS = -g -Wall -lstdc++ -pthread -I$(WS_ROOT)/src -I$(VPP_INSTALL_PATH)/vpp/include -I$(VAPI_BINDIR)
Damjan Marion164e5f82018-04-25 19:11:15 +020015CFLAGS = -std=gnu99 $(FLAGS)
Damjan Marion8c1afb52020-10-16 15:28:47 +020016CPPFLAGS = -std=c++11 $(FLAGS)
Damjan Marion164e5f82018-04-25 19:11:15 +020017
Neale Ranns812ed392017-10-16 04:20:13 -070018$(VAPI_BINDIR):
Dave Wallacef0797d12019-11-15 17:29:15 -050019 @mkdir -p $(VAPI_BINDIR)
Klement Sekera8f2a4ea2017-05-04 06:15:18 +020020
Dave Wallacef0797d12019-11-15 17:29:15 -050021CSRC = $(TEST_EXT_DIR)/vapi_c_test.c
Klement Sekera8f2a4ea2017-05-04 06:15:18 +020022
Neale Ranns812ed392017-10-16 04:20:13 -070023$(VAPI_BINDIR)/fake.api.vapi.h: fake.api.json $(WS_ROOT)/src/vpp-api/vapi/vapi_c_gen.py | $(VAPI_BINDIR)
24 $(WS_ROOT)/src/vpp-api/vapi/vapi_c_gen.py --prefix $(VAPI_BINDIR) $<
Klement Sekeradc15be22017-06-12 06:49:33 +020025
Neale Ranns812ed392017-10-16 04:20:13 -070026$(VAPI_BINDIR)/fake.api.vapi.hpp: fake.api.json $(WS_ROOT)/src/vpp-api/vapi/vapi_cpp_gen.py | $(VAPI_BINDIR)
27 $(WS_ROOT)/src/vpp-api/vapi/vapi_cpp_gen.py --prefix $(VAPI_BINDIR) $<
Klement Sekeradc15be22017-06-12 06:49:33 +020028
Klement Sekerade57ca32020-03-12 12:30:21 +010029$(VAPI_CBIN): $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h | $(VAPI_BINDIR)
Neale Ranns812ed392017-10-16 04:20:13 -070030 $(CC) -o $@ $(CFLAGS) $(CSRC) $(VAPI_LIBS)
Klement Sekeradc15be22017-06-12 06:49:33 +020031
Sirshak Das41141d52018-05-18 13:14:52 -050032$(VAPI_CBIN).d: $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h
Damjan Marion164e5f82018-04-25 19:11:15 +020033 $(CC) -o $@ $(CFLAGS) -MM -MT '$(VAPI_CBIN)' $(CSRC) > $@
34
35
Dave Wallacef0797d12019-11-15 17:29:15 -050036ifeq ($(filter rhel centos,$(OS_ID)),$(OS_ID))
37VAPI_CPPBIN=
38else
39CPPSRC = $(TEST_EXT_DIR)/vapi_cpp_test.cpp
Klement Sekeradc15be22017-06-12 06:49:33 +020040
Klement Sekerade57ca32020-03-12 12:30:21 +010041$(VAPI_CPPBIN): $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp | $(VAPI_BINDIR)
Neale Ranns812ed392017-10-16 04:20:13 -070042 $(CXX) -o $@ $(CPPFLAGS) $(CPPSRC) $(VAPI_LIBS)
43
Sirshak Das41141d52018-05-18 13:14:52 -050044$(VAPI_CPPBIN).d: $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp
Damjan Marion164e5f82018-04-25 19:11:15 +020045 $(CXX) -o $@ $(CPPFLAGS) -MM -MT '$(VAPI_CPPBIN)' $(CPPSRC) > $@
Dave Wallacef0797d12019-11-15 17:29:15 -050046endif
Damjan Marion164e5f82018-04-25 19:11:15 +020047
Dave Wallacef0797d12019-11-15 17:29:15 -050048.PHONY: test-apps
Damjan Marion8c1afb52020-10-16 15:28:47 +020049test-apps: $(VAPI_CBIN) $(VAPI_CPPBIN)
Dave Wallacef0797d12019-11-15 17:29:15 -050050
51.PHONY: clean
52clean:
Damjan Marion8c1afb52020-10-16 15:28:47 +020053 @rm -rf $(VAPI_BINDIR)
Dave Wallacef0797d12019-11-15 17:29:15 -050054
55ifneq ($(MAKECMDGOALS),clean)
56-include $(VAPI_CBIN).d
57ifneq ($(VAPI_CPPBIN),)
58-include $(VAPI_CPPBIN).d
59endif
Dave Wallacef0797d12019-11-15 17:29:15 -050060endif