xref: /btstack/test/security_manager_sc/Makefile (revision a8d51f092f1b660d0f6921369ad2bc3f9368296c)
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 += -I${BTSTACK_ROOT}/src
49CFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
50CFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael
51CFLAGS += -I${BTSTACK_ROOT}/3rd-party/tinydir
52CFLAGS += -I${BTSTACK_ROOT}/chipset/zephyr
53CFLAGS += -I${BTSTACK_ROOT}/platform/posix
54CFLAGS += -I${BTSTACK_ROOT}/platform/embedded
55
56VPATH += ${BTSTACK_ROOT}/src
57VPATH += ${BTSTACK_ROOT}/src/ble
58VPATH += ${BTSTACK_ROOT}/platform/posix
59VPATH += ${BTSTACK_ROOT}/platform/libusb
60VPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc
61VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
62VPATH += ${BTSTACK_ROOT}/chipset/zephyr
63
64# coverage
65CFLAGS  += -fprofile-arcs -ftest-coverage
66LDFLAGS += -fprofile-arcs -ftest-coverage
67
68# use pkg-config for libusb
69CFLAGS  += $(shell pkg-config libusb-1.0 --cflags)
70LDFLAGS += $(shell pkg-config libusb-1.0 --libs)
71
72
73CORE_OBJ    = $(CORE:.c=.o)
74COMMON_OBJ  = $(COMMON:.c=.o)
75ATT_OBJ     = $(ATT:.c=.o)
76SM_OBJ = $(SM:.c=.o) $(MICROECC:.c=.o)
77GATT_CLIENT_OBJ = $(GATT_CLIENT:.c=.o)
78GATT_SERVER_OBJ = $(GATT_SERVER:.c=.o)
79
80# compile .gatt descriptions
81%.h: %.gatt
82	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
83
84.PHONY: all coverage test
85
86all: sm_test
87
88sm_test: sm_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${GATT_CLIENT_OBJ}  ${SM_OBJ} sm_test.o
89	${CC} $(filter-out sm_test.h,$^) ${LDFLAGS} -o $@
90
91myclean:
92	rm -rf sm_test.h sm_test
93	rm -f  *.o
94	rm -rf *.dSYM
95	rm -f *.gcno *.gcda
96	rm -rf SM_*
97
98clean: myclean
99
100test: sm_test
101	rm -rf SM_*
102	python3 ./sm_test.py
103
104coverage: sm_test
105	# delete trace data
106	find . -name "*.gcda" -type f -delete
107	# run tests
108	make test
109	# collect traces
110	lcov --capture --rc lcov_branch_coverage=1 --directory . --exclude "/Applications/*" --exclude "/Library/*" --exclude "/usr/*" --exclude "*/test/*" --output-file coverage-sm-sc.info
111	# demangle
112	python3 ../coverage_demangle.py coverage-sm-sc.info
113