Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 1 | TEST_EXT_DIR=$(TEST_DIR)/ext |
| 2 | VAPI_BINDIR = $(TEST_BR)/vapi_test |
| 3 | VAPI_CBIN = $(addprefix $(VAPI_BINDIR), /vapi_c_test) |
| 4 | VAPI_CPPBIN = $(addprefix $(VAPI_BINDIR), /vapi_cpp_test) |
Klement Sekera | be2c2a8 | 2019-09-02 15:19:41 +0000 | [diff] [blame] | 5 | |
Damjan Marion | 164e5f8 | 2018-04-25 19:11:15 +0200 | [diff] [blame] | 6 | VAPI_LIBS = \ |
Klement Sekera | b8c72a4 | 2018-11-08 11:21:39 +0100 | [diff] [blame] | 7 | -L$(VPP_INSTALL_PATH)/vpp/lib \ |
Damjan Marion | 164e5f8 | 2018-04-25 19:11:15 +0200 | [diff] [blame] | 8 | -lvppinfra -lvlibmemoryclient -lsvm -lpthread -lcheck -lrt -lm -lvapiclient |
| 9 | |
Dave Wallace | bc35f46 | 2020-09-18 15:35:01 +0000 | [diff] [blame] | 10 | ifneq ($(filter centos,$(OS_ID)),$(OS_ID)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 11 | VAPI_LIBS += -lsubunit |
Marco Varlese | 5f1231c | 2017-10-10 16:43:14 +0200 | [diff] [blame] | 12 | endif |
Klement Sekera | dc15be2 | 2017-06-12 06:49:33 +0200 | [diff] [blame] | 13 | |
Klement Sekera | b8c72a4 | 2018-11-08 11:21:39 +0100 | [diff] [blame] | 14 | FLAGS = -g -Wall -lstdc++ -pthread -I$(WS_ROOT)/src -I$(VPP_INSTALL_PATH)/vpp/include -I$(VAPI_BINDIR) |
Damjan Marion | 164e5f8 | 2018-04-25 19:11:15 +0200 | [diff] [blame] | 15 | CFLAGS = -std=gnu99 $(FLAGS) |
Damjan Marion | 8c1afb5 | 2020-10-16 15:28:47 +0200 | [diff] [blame] | 16 | CPPFLAGS = -std=c++11 $(FLAGS) |
Damjan Marion | 164e5f8 | 2018-04-25 19:11:15 +0200 | [diff] [blame] | 17 | |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 18 | $(VAPI_BINDIR): |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 19 | @mkdir -p $(VAPI_BINDIR) |
Klement Sekera | 8f2a4ea | 2017-05-04 06:15:18 +0200 | [diff] [blame] | 20 | |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 21 | CSRC = $(TEST_EXT_DIR)/vapi_c_test.c |
Klement Sekera | 8f2a4ea | 2017-05-04 06:15:18 +0200 | [diff] [blame] | 22 | |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 23 | $(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 Sekera | dc15be2 | 2017-06-12 06:49:33 +0200 | [diff] [blame] | 25 | |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 26 | $(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 Sekera | dc15be2 | 2017-06-12 06:49:33 +0200 | [diff] [blame] | 28 | |
Klement Sekera | de57ca3 | 2020-03-12 12:30:21 +0100 | [diff] [blame] | 29 | $(VAPI_CBIN): $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h | $(VAPI_BINDIR) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 30 | $(CC) -o $@ $(CFLAGS) $(CSRC) $(VAPI_LIBS) |
Klement Sekera | dc15be2 | 2017-06-12 06:49:33 +0200 | [diff] [blame] | 31 | |
Sirshak Das | 41141d5 | 2018-05-18 13:14:52 -0500 | [diff] [blame] | 32 | $(VAPI_CBIN).d: $(CSRC) $(VAPI_BINDIR)/fake.api.vapi.h |
Damjan Marion | 164e5f8 | 2018-04-25 19:11:15 +0200 | [diff] [blame] | 33 | $(CC) -o $@ $(CFLAGS) -MM -MT '$(VAPI_CBIN)' $(CSRC) > $@ |
| 34 | |
| 35 | |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 36 | ifeq ($(filter rhel centos,$(OS_ID)),$(OS_ID)) |
| 37 | VAPI_CPPBIN= |
| 38 | else |
| 39 | CPPSRC = $(TEST_EXT_DIR)/vapi_cpp_test.cpp |
Klement Sekera | dc15be2 | 2017-06-12 06:49:33 +0200 | [diff] [blame] | 40 | |
Klement Sekera | de57ca3 | 2020-03-12 12:30:21 +0100 | [diff] [blame] | 41 | $(VAPI_CPPBIN): $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp | $(VAPI_BINDIR) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 42 | $(CXX) -o $@ $(CPPFLAGS) $(CPPSRC) $(VAPI_LIBS) |
| 43 | |
Sirshak Das | 41141d5 | 2018-05-18 13:14:52 -0500 | [diff] [blame] | 44 | $(VAPI_CPPBIN).d: $(CPPSRC) $(VAPI_BINDIR)/fake.api.vapi.hpp |
Damjan Marion | 164e5f8 | 2018-04-25 19:11:15 +0200 | [diff] [blame] | 45 | $(CXX) -o $@ $(CPPFLAGS) -MM -MT '$(VAPI_CPPBIN)' $(CPPSRC) > $@ |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 46 | endif |
Damjan Marion | 164e5f8 | 2018-04-25 19:11:15 +0200 | [diff] [blame] | 47 | |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 48 | .PHONY: test-apps |
Damjan Marion | 8c1afb5 | 2020-10-16 15:28:47 +0200 | [diff] [blame] | 49 | test-apps: $(VAPI_CBIN) $(VAPI_CPPBIN) |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 50 | |
| 51 | .PHONY: clean |
| 52 | clean: |
Damjan Marion | 8c1afb5 | 2020-10-16 15:28:47 +0200 | [diff] [blame] | 53 | @rm -rf $(VAPI_BINDIR) |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 54 | |
| 55 | ifneq ($(MAKECMDGOALS),clean) |
| 56 | -include $(VAPI_CBIN).d |
| 57 | ifneq ($(VAPI_CPPBIN),) |
| 58 | -include $(VAPI_CPPBIN).d |
| 59 | endif |
Dave Wallace | f0797d1 | 2019-11-15 17:29:15 -0500 | [diff] [blame] | 60 | endif |