1BASE=../.. 2SUBS=system/core \ 3 hardware/libhardware \ 4 external/gtest 5GTEST=$(BASE)/external/gtest 6 7INCLUDES=$(foreach dir,$(SUBS),-I $(BASE)/$(dir)/include) \ 8 -I $(BASE)/libnativehelper/include/nativehelper \ 9 -I $(GTEST) -Iinclude 10 11ifdef USE_CLANG 12CC=/usr/bin/clang 13CXX=/usr/bin/clang 14CLANG_TEST_DEFINE=-DKEYMASTER_CLANG_TEST_BUILD 15COMPILER_SPECIFIC_ARGS=-std=c++11 $(CLANG_TEST_DEFINE) 16else 17COMPILER_SPECIFIC_ARGS=-std=c++0x -fprofile-arcs 18endif 19 20CPPFLAGS=$(INCLUDES) -g -O0 -MD 21CXXFLAGS=-Wall -Werror -Wno-unused -Winit-self -Wpointer-arith -Wunused-parameter \ 22 -Wmissing-declarations -ftest-coverage \ 23 -Wno-deprecated-declarations -fno-exceptions -DKEYMASTER_NAME_TAGS \ 24 $(COMPILER_SPECIFIC_ARGS) 25LDLIBS=-lcrypto -lpthread -lstdc++ 26 27CPPSRCS=\ 28 asymmetric_key.cpp \ 29 authorization_set.cpp \ 30 authorization_set_test.cpp \ 31 dsa_operation.cpp \ 32 ecdsa_operation.cpp \ 33 google_keymaster.cpp \ 34 google_keymaster_messages.cpp \ 35 google_keymaster_messages_test.cpp \ 36 google_keymaster_test.cpp \ 37 google_keymaster_test_utils.cpp \ 38 google_keymaster_utils.cpp \ 39 key.cpp \ 40 key_blob.cpp \ 41 key_blob_test.cpp \ 42 rsa_operation.cpp \ 43 serializable.cpp 44CCSRCS=$(GTEST)/src/gtest-all.cc 45CSRCS=ocb.c 46 47OBJS=$(CPPSRCS:.cpp=.o) $(CCSRCS:.cc=.o) $(CSRCS:.c=.o) 48DEPS=$(CPPSRCS:.cpp=.d) $(CCSRCS:.cc=.d) $(CSRCS:.c=.d) 49 50LINK.o=$(LINK.cc) 51 52BINARIES=authorization_set_test \ 53 google_keymaster_test \ 54 google_keymaster_messages_test \ 55 key_blob_test 56 57.PHONY: coverage memcheck massif clean run 58 59%.run: % 60 ./$< 61 touch $@ 62 63run: $(BINARIES:=.run) 64 65coverage: coverage.info 66 genhtml coverage.info --output-directory coverage 67 68coverage.info: run 69 lcov --capture --directory=. --output-file coverage.info 70 71%.coverage : % 72 $(MAKE) clean && $(MAKE) $< 73 ./$< 74 lcov --capture --directory=. --output-file coverage.info 75 genhtml coverage.info --output-directory coverage 76 77#UNINIT_OPTS=--track-origins=yes 78UNINIT_OPTS=--undef-value-errors=no 79 80MEMCHECK_OPTS=--leak-check=full \ 81 --show-reachable=yes \ 82 --vgdb=full \ 83 $(UNINIT_OPTS) \ 84 --error-exitcode=1 85 86MASSIF_OPTS=--tool=massif \ 87 --stacks=yes 88 89%.memcheck : % 90 valgrind $(MEMCHECK_OPTS) ./$< && \ 91 touch $@ 92 93%.massif : % 94 valgrind $(MASSIF_OPTS) --massif-out-file=$@ ./$< 95 96memcheck: $(BINARIES:=.memcheck) 97 98massif: $(BINARIES:=.massif) 99 100authorization_set_test: authorization_set_test.o \ 101 authorization_set.o \ 102 google_keymaster_test_utils.o \ 103 serializable.o \ 104 $(GTEST)/src/gtest-all.o 105 106key_blob_test: key_blob_test.o \ 107 authorization_set.o \ 108 google_keymaster_test_utils.o \ 109 key_blob.o \ 110 ocb.o \ 111 serializable.o \ 112 $(GTEST)/src/gtest-all.o 113 114google_keymaster_messages_test: google_keymaster_messages_test.o \ 115 authorization_set.o \ 116 google_keymaster_messages.o \ 117 google_keymaster_test_utils.o \ 118 google_keymaster_utils.o \ 119 serializable.o \ 120 $(GTEST)/src/gtest-all.o 121 122google_keymaster_test: google_keymaster_test.o \ 123 asymmetric_key.o \ 124 authorization_set.o \ 125 dsa_operation.o \ 126 ecdsa_operation.o \ 127 google_keymaster.o \ 128 google_keymaster_messages.o \ 129 google_keymaster_test_utils.o \ 130 google_keymaster_utils.o \ 131 key.o \ 132 key_blob.o \ 133 ocb.o \ 134 rsa_operation.o \ 135 serializable.o \ 136 $(GTEST)/src/gtest-all.o 137 138$(GTEST)/src/gtest-all.o: CXXFLAGS:=$(subst -Wmissing-declarations,,$(CXXFLAGS)) 139ocb.o: CFLAGS=$(CLANG_TEST_DEFINE) 140 141clean: 142 rm -f $(OBJS) $(DEPS) $(BINARIES) \ 143 $(BINARIES:=.run) $(BINARIES:=.memcheck) $(BINARIES:=.massif) \ 144 *gcno *gcda coverage.info 145 rm -rf coverage 146 147-include $(CPPSRCS:.cpp=.d) 148-include $(CCSRCS:.cc=.d) 149 150