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