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