Home | History | Annotate | Download | only in keymaster
      1 BASE=../..
      2 SUBS=system/core \
      3 	hardware/libhardware \
      4 	external/gtest
      5 GTEST=$(BASE)/external/gtest
      6 
      7 INCLUDES=$(foreach dir,$(SUBS),-I $(BASE)/$(dir)/include) \
      8 	-I $(BASE)/libnativehelper/include/nativehelper \
      9 	-I $(GTEST) -Iinclude
     10 
     11 ifdef USE_CLANG
     12 CC=/usr/bin/clang
     13 CXX=/usr/bin/clang
     14 CLANG_TEST_DEFINE=-DKEYMASTER_CLANG_TEST_BUILD
     15 COMPILER_SPECIFIC_ARGS=-std=c++11 $(CLANG_TEST_DEFINE)
     16 else
     17 COMPILER_SPECIFIC_ARGS=-std=c++0x -fprofile-arcs
     18 endif
     19 
     20 CPPFLAGS=$(INCLUDES) -g -O0 -MD
     21 CXXFLAGS=-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)
     25 LDLIBS=-lcrypto -lpthread -lstdc++
     26 
     27 CPPSRCS=\
     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
     44 CCSRCS=$(GTEST)/src/gtest-all.cc
     45 CSRCS=ocb.c
     46 
     47 OBJS=$(CPPSRCS:.cpp=.o) $(CCSRCS:.cc=.o) $(CSRCS:.c=.o)
     48 DEPS=$(CPPSRCS:.cpp=.d) $(CCSRCS:.cc=.d) $(CSRCS:.c=.d)
     49 
     50 LINK.o=$(LINK.cc)
     51 
     52 BINARIES=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 
     63 run: $(BINARIES:=.run)
     64 
     65 coverage: coverage.info
     66 	genhtml coverage.info --output-directory coverage
     67 
     68 coverage.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
     78 UNINIT_OPTS=--undef-value-errors=no
     79 
     80 MEMCHECK_OPTS=--leak-check=full \
     81 	--show-reachable=yes \
     82 	--vgdb=full \
     83 	$(UNINIT_OPTS) \
     84 	--error-exitcode=1
     85 
     86 MASSIF_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 
     96 memcheck: $(BINARIES:=.memcheck)
     97 
     98 massif: $(BINARIES:=.massif)
     99 
    100 authorization_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 
    106 key_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 
    114 google_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 
    122 google_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))
    139 ocb.o: CFLAGS=$(CLANG_TEST_DEFINE)
    140 
    141 clean:
    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