xref: /btstack/test/security_manager_sc/Makefile (revision e8a62bb7728fe11a7e70e1ce74e5bb7dfde4485b)
16b7b368aSMatthias Ringwald# Makefile for libusb based PTS tests
26b7b368aSMatthias RingwaldBTSTACK_ROOT = ../..
36b7b368aSMatthias Ringwald
46b7b368aSMatthias RingwaldCORE += \
56b7b368aSMatthias Ringwald	btstack_memory.c            \
66b7b368aSMatthias Ringwald	btstack_linked_list.c	    \
76b7b368aSMatthias Ringwald	btstack_memory_pool.c       \
86b7b368aSMatthias Ringwald	btstack_run_loop.c		    \
96b7b368aSMatthias Ringwald	btstack_util.c 	            \
106b7b368aSMatthias Ringwald	main.c 						\
116b7b368aSMatthias Ringwald	btstack_stdin_posix.c       \
126b7b368aSMatthias Ringwald	btstack_tlv.c 		\
136b7b368aSMatthias Ringwald	btstack_tlv_posix.c 		\
146b7b368aSMatthias Ringwald	rijndael.c \
156b7b368aSMatthias Ringwald
166b7b368aSMatthias RingwaldCOMMON += \
176b7b368aSMatthias Ringwald	hci.c			            \
186b7b368aSMatthias Ringwald	ad_parser.c                 \
196b7b368aSMatthias Ringwald	hci_cmd.c		            \
206b7b368aSMatthias Ringwald	hci_dump.c		            \
216b7b368aSMatthias Ringwald	l2cap.c			            \
226b7b368aSMatthias Ringwald	l2cap_signaling.c	        \
236b7b368aSMatthias Ringwald	hci_transport_h2_libusb.c 	\
24a921db49SMatthias Ringwald	btstack_crypto.c            \
256b7b368aSMatthias Ringwald	btstack_run_loop_posix.c 	\
266b7b368aSMatthias Ringwald	le_device_db_tlv.c 			\
276b7b368aSMatthias Ringwald	sm.c 						\
286b7b368aSMatthias Ringwald	uECC.c 					    \
296b7b368aSMatthias Ringwald	btstack_chipset_zephyr.c    \
306b7b368aSMatthias Ringwald
316b7b368aSMatthias RingwaldATT	+= \
326b7b368aSMatthias Ringwald	att_dispatch.c       	    \
336b7b368aSMatthias Ringwald
346b7b368aSMatthias RingwaldGATT_SERVER += \
356b7b368aSMatthias Ringwald	att_db.c 				 	    \
366b7b368aSMatthias Ringwald	att_server.c        	    \
376b7b368aSMatthias Ringwald
386b7b368aSMatthias RingwaldGATT_CLIENT += \
396b7b368aSMatthias Ringwald	gatt_client.c        	    \
406b7b368aSMatthias Ringwald
416b7b368aSMatthias RingwaldSM += \
426b7b368aSMatthias Ringwald	sm.c 				 	    \
436b7b368aSMatthias Ringwald
44a921db49SMatthias RingwaldCFLAGS += -g -std=c99 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wunused-parameter -Wredundant-decls -Wsign-compare
456b7b368aSMatthias RingwaldCFLAGS += -D ENABLE_TESTING_SUPPORT
4628b5b606SMatthias RingwaldCFLAGS += -DCOVERAGE
47a921db49SMatthias RingwaldCFLAGS += -I.
486b7b368aSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/src
49a921db49SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
506b7b368aSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael
516b7b368aSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/tinydir
526b7b368aSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/chipset/zephyr
536b7b368aSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/posix
546b7b368aSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/embedded
556b7b368aSMatthias Ringwald
566b7b368aSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src
576b7b368aSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble
586b7b368aSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix
596b7b368aSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/libusb
606b7b368aSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc
616b7b368aSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
626b7b368aSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/chipset/zephyr
636b7b368aSMatthias Ringwald
64a921db49SMatthias Ringwald# coverage
6528b5b606SMatthias RingwaldCFLAGS  += -fprofile-arcs -ftest-coverage
6628b5b606SMatthias RingwaldLDFLAGS += -fprofile-arcs -ftest-coverage
67a921db49SMatthias Ringwald
686b7b368aSMatthias Ringwald# use pkg-config for libusb
696b7b368aSMatthias RingwaldCFLAGS  += $(shell pkg-config libusb-1.0 --cflags)
706b7b368aSMatthias RingwaldLDFLAGS += $(shell pkg-config libusb-1.0 --libs)
716b7b368aSMatthias Ringwald
72795c77dcSMatthias Ringwald
736b7b368aSMatthias RingwaldCORE_OBJ    = $(CORE:.c=.o)
746b7b368aSMatthias RingwaldCOMMON_OBJ  = $(COMMON:.c=.o)
756b7b368aSMatthias RingwaldATT_OBJ     = $(ATT:.c=.o)
766b7b368aSMatthias RingwaldSM_OBJ = $(SM:.c=.o) $(MICROECC:.c=.o)
776b7b368aSMatthias RingwaldGATT_CLIENT_OBJ = $(GATT_CLIENT:.c=.o)
786b7b368aSMatthias RingwaldGATT_SERVER_OBJ = $(GATT_SERVER:.c=.o)
796b7b368aSMatthias Ringwald
80a921db49SMatthias Ringwald# compile .gatt descriptions
81a921db49SMatthias Ringwald%.h: %.gatt
82a921db49SMatthias Ringwald	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
83a921db49SMatthias Ringwald
84*e8a62bb7SMatthias Ringwald.PHONY: all coverage test
85*e8a62bb7SMatthias Ringwald
866b7b368aSMatthias Ringwaldall: sm_test
876b7b368aSMatthias Ringwald
886b7b368aSMatthias Ringwaldsm_test: sm_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${GATT_CLIENT_OBJ}  ${SM_OBJ} sm_test.o
89a921db49SMatthias Ringwald	${CC} $(filter-out sm_test.h,$^) ${LDFLAGS} -o $@
906b7b368aSMatthias Ringwald
916b7b368aSMatthias Ringwaldmyclean:
92a921db49SMatthias Ringwald	rm -rf sm_test.h sm_test
93a921db49SMatthias Ringwald	rm -f  *.o
94a921db49SMatthias Ringwald	rm -rf *.dSYM
95a921db49SMatthias Ringwald	rm -f *.gcno *.gcda
962ce916b3SMatthias Ringwald	rm -rf SM_*
976b7b368aSMatthias Ringwald
986b7b368aSMatthias Ringwaldclean: myclean
99795c77dcSMatthias Ringwald
100795c77dcSMatthias Ringwaldtest: sm_test
1019a09a08aSMatthias Ringwald	rm -rf SM_*
1022ce916b3SMatthias Ringwald	python3 ./sm_test.py
103*e8a62bb7SMatthias Ringwald
104*e8a62bb7SMatthias Ringwaldcoverage: sm_test
105*e8a62bb7SMatthias Ringwald	# delete trace data
106*e8a62bb7SMatthias Ringwald	find . -name "*.gcda" -type f -delete
107*e8a62bb7SMatthias Ringwald	# run tests
108*e8a62bb7SMatthias Ringwald	make test
109*e8a62bb7SMatthias Ringwald	# collect traces
110*e8a62bb7SMatthias Ringwald	lcov --capture --rc lcov_branch_coverage=1 --directory . --exclude "/Applications/*" --exclude "/Library/*" --exclude "/usr/*" --exclude "*/test/*" --output-file security_manager_sc.info
111*e8a62bb7SMatthias Ringwald	# demangle
112*e8a62bb7SMatthias Ringwald	python3 ../coverage_demangle.py security_manager_sc.info
113