xref: /btstack/test/security_manager_sc/Makefile (revision 503a627edab6ba8492c3d0cdd9ac598fe2b0f08a)
1# Makefile for libusb based PTS tests
2BTSTACK_ROOT = ../..
3
4CORE += \
5	btstack_memory.c            \
6	btstack_linked_list.c	    \
7	btstack_memory_pool.c       \
8	btstack_run_loop.c		    \
9	btstack_util.c 	            \
10	main.c 						\
11	btstack_stdin_posix.c       \
12	btstack_tlv.c 		\
13	btstack_tlv_posix.c 		\
14	rijndael.c \
15
16COMMON += \
17	hci.c			            \
18	ad_parser.c                 \
19	hci_cmd.c		            \
20	hci_dump.c		            \
21	hci_dump_posix_fs.c         \
22	l2cap.c			            \
23	l2cap_signaling.c	        \
24	hci_transport_h2_libusb.c 	\
25	btstack_crypto.c            \
26	btstack_run_loop_posix.c 	\
27	le_device_db_tlv.c 			\
28	sm.c 						\
29	uECC.c 					    \
30	btstack_chipset_zephyr.c    \
31
32ATT	+= \
33	att_dispatch.c       	    \
34
35GATT_SERVER += \
36	att_db.c 				 	    \
37	att_server.c        	    \
38
39GATT_CLIENT += \
40	gatt_client.c        	    \
41
42SM += \
43	sm.c 				 	    \
44
45CFLAGS += -g -std=c99 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wunused-parameter -Wredundant-decls -Wsign-compare
46CFLAGS += -D ENABLE_TESTING_SUPPORT
47CFLAGS += -DCOVERAGE
48CFLAGS += -I.
49CFLAGS += -Ibuild-coverage
50CFLAGS += -I${BTSTACK_ROOT}/src
51CFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
52CFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael
53CFLAGS += -I${BTSTACK_ROOT}/3rd-party/tinydir
54CFLAGS += -I${BTSTACK_ROOT}/chipset/zephyr
55CFLAGS += -I${BTSTACK_ROOT}/platform/posix
56CFLAGS += -I${BTSTACK_ROOT}/platform/embedded
57
58VPATH += ${BTSTACK_ROOT}/src
59VPATH += ${BTSTACK_ROOT}/src/ble
60VPATH += ${BTSTACK_ROOT}/platform/posix
61VPATH += ${BTSTACK_ROOT}/platform/libusb
62VPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc
63VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
64VPATH += ${BTSTACK_ROOT}/chipset/zephyr
65
66# coverage
67CFLAGS  += -fprofile-arcs -ftest-coverage
68LDFLAGS += -fprofile-arcs -ftest-coverage
69
70# use pkg-config for libusb
71CFLAGS  += $(shell pkg-config libusb-1.0 --cflags)
72LDFLAGS += $(shell pkg-config libusb-1.0 --libs)
73
74CORE_OBJ = $(addprefix build-coverage/,$(CORE:.c=.o))
75COMMON_OBJ = $(addprefix build-coverage/,$(COMMON:.c=.o))
76ATT_OBJ = $(addprefix build-coverage/,$(ATT:.c=.o))
77SM_OBJ = $(addprefix build-coverage/,$(SM:.c=.o))
78GATT_CLIENT_OBJ = $(addprefix build-coverage/,$(GATT_CLIENT:.c=.o))
79GATT_SERVER_OBJ = $(addprefix build-coverage/,$(GATT_SERVER:.c=.o))
80
81# compile .gatt descriptions
82build-coverage/%.h: %.gatt
83	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
84
85.PHONY: all coverage test
86
87all: build-coverage/sm_test
88
89build-%:
90	mkdir -p $@
91
92build-coverage/sm_test.h: sm_test.gatt | build-coverage
93	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
94
95build-coverage/%.o: %.c | build-coverage
96	${CC} -c $(CFLAGS) ${CPPFLAGS} $< -o $@
97
98build-coverage/sm_test: build-coverage/sm_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${GATT_CLIENT_OBJ}  ${SM_OBJ} build-coverage/sm_test.o | build-coverage
99	${CC} $(filter-out build-coverage/sm_test.h,$^) ${LDFLAGS} -o $@
100
101myclean:
102	rm -rf build-coverage
103	rm -f  *.o
104	rm -rf *.dSYM
105	rm -f *.gcno *.gcda
106	rm -rf SM_*
107
108clean: myclean
109
110test: build-coverage/sm_test
111	rm -rf SM_*
112	python3 ./sm_test.py
113
114coverage: build-coverage/sm_test
115	# delete trace data
116	rm -f build-coverage/*.gcda
117	# run tests
118	make test
119	# collect traces
120	lcov --capture --rc lcov_branch_coverage=1 --directory . --exclude "/Applications/*" --exclude "/Library/*" --exclude "/usr/*" --exclude "*/test/*" --output-file coverage-sm-sc.info
121	# demangle
122	python3 ../coverage_demangle.py coverage-sm-sc.info
123