xref: /btstack/test/mesh/Makefile (revision 1d3bd1e51ca491d6783233c8d7431c44f06daa5a)
11fbe4564SMatthias Ringwald # Makefile for libusb based examples
21fbe4564SMatthias RingwaldBTSTACK_ROOT = ../..
31fbe4564SMatthias Ringwald
4752b29f3SMilanka RingwaldATT  += \
5752b29f3SMilanka Ringwald	att_dispatch.c       	    \
6752b29f3SMilanka Ringwald	att_db.c 				 	\
7752b29f3SMilanka Ringwald	att_server.c        	    \
8752b29f3SMilanka Ringwald	gatt_bearer.c               \
9752b29f3SMilanka Ringwald	mesh_proxy_service_server.c \
10752b29f3SMilanka Ringwald
111fbe4564SMatthias RingwaldCORE += \
121fbe4564SMatthias Ringwald	adv_bearer.c \
131fbe4564SMatthias Ringwald	beacon.c \
141fbe4564SMatthias Ringwald	btstack_link_key_db_fs.c \
151fbe4564SMatthias Ringwald	btstack_run_loop_posix.c \
161fbe4564SMatthias Ringwald	btstack_stdin_posix.c \
17f8da99a8SMatthias Ringwald	btstack_uart_posix_pty.c \
181fbe4564SMatthias Ringwald	hci_transport_h2_libusb.c \
191fbe4564SMatthias Ringwald	hci_transport_h4.c \
201fbe4564SMatthias Ringwald	btstack_tlv_posix.c \
2104875b11SMatthias Ringwald	mesh_iv_index_seq_number.c \
220e329b41SMatthias Ringwald	mesh_node.c \
231fbe4564SMatthias Ringwald	le_device_db_fs.c \
241fbe4564SMatthias Ringwald	l2cap.c \
251fbe4564SMatthias Ringwald	uECC.c \
261fbe4564SMatthias Ringwald	rijndael.c \
2731437b52SMatthias Ringwald	hci_dump_posix_fs.c \
281fbe4564SMatthias Ringwald
2939018edaSMilanka Ringwald
301fbe4564SMatthias Ringwald# examples
311fbe4564SMatthias Ringwaldinclude ${BTSTACK_ROOT}/example/Makefile.inc
32777f7d8dSMilanka Ringwaldinclude ${BTSTACK_ROOT}/src/ble/gatt-service/Makefile.inc
331fbe4564SMatthias Ringwald
3439018edaSMilanka Ringwald
3526ecb624SMilanka RingwaldCFLAGS  += -g -DUNIT_TEST -Wall \
361fbe4564SMatthias Ringwald	-I$(BTSTACK_ROOT)/platform/embedded \
371fbe4564SMatthias Ringwald	-I$(BTSTACK_ROOT)/platform/posix \
381fbe4564SMatthias Ringwald	-I$(BTSTACK_ROOT)/3rd-party/tinydir \
39f13fc290SMatthias Ringwald	-I$(BTSTACK_ROOT)/3rd-party/rijndael \
401fbe4564SMatthias Ringwald
4113753703SMatthias RingwaldCFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wunused-parameter -Wredundant-decls -Wsign-compare
42497cc682SMatthias Ringwald
43f13fc290SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
4477ba3d3fSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/mesh
451fbe4564SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/classic
461fbe4564SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix
471fbe4564SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/embedded
481fbe4564SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/libusb
49777f7d8dSMilanka RingwaldVPATH += ${BTSTACK_ROOT}/src/ble/gatt-service
501fbe4564SMatthias Ringwald
511fbe4564SMatthias Ringwald# libusb
521fbe4564SMatthias RingwaldCFLAGS  += $(shell pkg-config libusb-1.0 --cflags)
531fbe4564SMatthias RingwaldLDFLAGS += $(shell pkg-config libusb-1.0 --libs)
541fbe4564SMatthias Ringwald
55cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
5671d52576SMatthias RingwaldCFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
57cd56fb44SMatthias Ringwald
58c956179dSMatthias Ringwald# cppUTest
59c956179dSMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt
60c956179dSMatthias Ringwald
61cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
62cd56fb44SMatthias RingwaldLDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
63c956179dSMatthias Ringwald
64cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE      = $(addprefix build-coverage/,$(COMMON_OBJ))
65cd56fb44SMatthias RingwaldCORE_OBJ_COVERAGE        = $(addprefix build-coverage/,$(CORE_OBJ))
66cd56fb44SMatthias RingwaldATT_OBJ_COVERAGE         = $(addprefix build-coverage/,$(ATT_OBJ))
67cd56fb44SMatthias RingwaldGATT_SERVER_OBJ_COVERAGE = $(addprefix build-coverage/,$(GATT_SERVER_OBJ))
68cd56fb44SMatthias RingwaldSM_OB_COVERAGE           = $(addprefix build-coverage/,$(SM_OB))
69cd56fb44SMatthias RingwaldMESH_OBJ_COVERAGE        = $(addprefix build-coverage/,$(MESH_OBJ))
701fbe4564SMatthias Ringwald
71cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN          = $(addprefix build-asan/,$(COMMON_OBJ))
72cd56fb44SMatthias RingwaldCORE_OBJ_ASAN            = $(addprefix build-asan/,$(CORE_OBJ))
73cd56fb44SMatthias RingwaldATT_OBJ_ASAN             = $(addprefix build-asan/,$(ATT_OBJ))
74cd56fb44SMatthias RingwaldGATT_SERVER_OBJ_ASAN     = $(addprefix build-asan/,$(GATT_SERVER_OBJ))
75cd56fb44SMatthias RingwaldSM_OB_ASAN               = $(addprefix build-asan/,$(SM_OB))
76cd56fb44SMatthias RingwaldMESH_OBJ_ASAN            = $(addprefix build-asan/,$(MESH_OBJ))
77777f7d8dSMilanka Ringwald
783d87570fSMatthias RingwaldTESTS_SRCS = mesh_message_test provisioning_device_test provisioning_provisioner_test mesh_configuration_composition_data_message_test
793d87570fSMatthias RingwaldEXAMPLES =   mesh_pts provisioner sniffer
801fbe4564SMatthias Ringwald
81cd56fb44SMatthias Ringwald
82cd56fb44SMatthias Ringwaldall:   $(addprefix build-asan/,$(EXAMPLES))
83cd56fb44SMatthias Ringwaldtests: $(addprefix build-asan/,$(TESTS_SRCS))
84cd56fb44SMatthias Ringwald
85cd56fb44SMatthias Ringwaldbuild-%:
86cd56fb44SMatthias Ringwald	mkdir -p $@
87cd56fb44SMatthias Ringwald
881fbe4564SMatthias Ringwald
893d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage
90cd56fb44SMatthias Ringwald	${CC} -c $(CFLAGS_COVERAGE) ${CPPFLAGS} $< -o $@
913d87570fSMatthias Ringwald
923d87570fSMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage
93*1d3bd1e5SMatthias Ringwald	${CXX} -c $(CFLAGS_COVERAGE) ${CPPFLAGS} $< -o $@
943d87570fSMatthias Ringwald
95cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan
96cd56fb44SMatthias Ringwald	${CC} -c $(CFLAGS_ASAN) ${CPPFLAGS} $< -o $@
97cd56fb44SMatthias Ringwald
98cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan
99*1d3bd1e5SMatthias Ringwald	${CXX} -c $(CFLAGS_ASAN) ${CPPFLAGS} $< -o $@
100cd56fb44SMatthias Ringwald
101cd56fb44SMatthias Ringwald
102cd56fb44SMatthias Ringwaldbuild-asan/mesh_pts: mesh_pts.h ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${GATT_SERVER_OBJ_ASAN} ${SM_OBJ_ASAN} ${MESH_OBJ_ASAN} build-asan/main.o build-asan/mesh_pts.o
103cd56fb44SMatthias Ringwald	${CC} $(filter-out mesh_pts.h,$^) ${LDFLAGS_ASAN} -o $@
104cd56fb44SMatthias Ringwald
105cd56fb44SMatthias Ringwaldbuild-asan/provisioner: ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${SM_OBJ_ASAN} build-asan/main.o build-asan/pb_adv.o build-asan/mesh_crypto.o build-asan/provisioning_provisioner.o build-asan/mesh_keys.o build-asan/mesh_foundation.o build-asan/mesh_network.o build-asan/provisioner.o
106cd56fb44SMatthias Ringwald	${CC} $^ ${LDFLAGS_ASAN} -o $@
107cd56fb44SMatthias Ringwald
108cd56fb44SMatthias Ringwaldbuild-asan/sniffer: ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${SM_OBJ_ASAN} build-asan/main.o build-asan/mesh_keys.o build-asan/mesh_network.o build-asan/mesh_foundation.o build-asan/sniffer.o
109cd56fb44SMatthias Ringwald	${CC} $^ ${LDFLAGS_ASAN} -o $@
110cd56fb44SMatthias Ringwald
111cd56fb44SMatthias Ringwald
11231437b52SMatthias Ringwaldbuild-asan/mesh_message_test: $(addprefix build-asan/, mesh_message_test.o mesh_foundation.o mesh_node.o  mesh_iv_index_seq_number.o mesh_network.o mesh_peer.o mesh_lower_transport.o mesh_upper_transport.o mesh_virtual_addresses.o  mesh_keys.o  mesh_crypto.o btstack_memory.o btstack_memory_pool.o btstack_util.o btstack_crypto.o btstack_linked_list.o hci_dump.o uECC.o mock.o rijndael.o hci_cmd.o hci_dump_posix_fs.o) | build-asan
113*1d3bd1e5SMatthias Ringwald	${CXX} $^ ${CFLAGS} ${LDFLAGS_ASAN} -o $@
114cd56fb44SMatthias Ringwald
11531437b52SMatthias Ringwaldbuild-asan/provisioning_device_test:  $(addprefix build-asan/, provisioning_device_test.o uECC.o mesh_crypto.o provisioning_device.o btstack_crypto.o btstack_util.o btstack_linked_list.o  mesh_node.o mock.o rijndael.o hci_cmd.o hci_dump.o hci_dump_posix_fs.o) | build-asan
116*1d3bd1e5SMatthias Ringwald	${CXX} ${LDFLAGS_ASAN} $^ -lCppUTest -lCppUTestExt -o $@
117cd56fb44SMatthias Ringwald
11831437b52SMatthias Ringwaldbuild-asan/provisioning_provisioner_test:  $(addprefix build-asan/, provisioning_provisioner_test.o uECC.o mesh_crypto.o provisioning_provisioner.o btstack_crypto.o btstack_util.o btstack_linked_list.o mock.o rijndael.o hci_cmd.o hci_dump.o hci_dump_posix_fs.o) | build-asan
119*1d3bd1e5SMatthias Ringwald	${CXX} ${LDFLAGS_ASAN} $^ -lCppUTest -lCppUTestExt -o $@
120cd56fb44SMatthias Ringwald
121cd56fb44SMatthias Ringwaldbuild-asan/mesh_configuration_composition_data_message_test: ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${MESH_OBJ_ASAN} build-asan/mesh_configuration_composition_data_message_test.o | build-asan
122*1d3bd1e5SMatthias Ringwald	${CXX} ${LDFLAGS_ASAN} $^ -lCppUTest -lCppUTestExt -o $@
123cd56fb44SMatthias Ringwald
1243d87570fSMatthias Ringwald
1253d87570fSMatthias Ringwaldtest: tests
126c9fe0d9fSMatthias Ringwald	# Ignore leaks in mesh message test as tests stop before all PDUs are fully processed
127cd56fb44SMatthias Ringwald	ASAN_OPTIONS=detect_leaks=0 build-asan/mesh_message_test
128cd56fb44SMatthias Ringwald	build-asan/provisioning_device_test
129cd56fb44SMatthias Ringwald	build-asan/provisioning_provisioner_test
130cd56fb44SMatthias Ringwald	build-asan/mesh_configuration_composition_data_message_test
1313d87570fSMatthias Ringwald
1323d87570fSMatthias Ringwaldcoverage: tests
133cd56fb44SMatthias Ringwald	rm -f build-coverage/*.gcda
134cd56fb44SMatthias Ringwald	@echo "no coverage here"
135d491c1eaSMatthias Ringwald
136777f7d8dSMilanka Ringwaldclean:
137cd56fb44SMatthias Ringwald	rm -rf build-coverage build-asan
138