| # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # TODO(asharif): Convert this to common.mk. |
| CXX ?= g++ |
| |
| BASE_VER ?= 334380 |
| PKG_CONFIG ?= pkg-config |
| PC_DEPS = openssl protobuf |
| PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS)) |
| PC_LIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS)) |
| |
| CXXFLAGS += -std=c++11 -g -Wall -Werror -Wall -Wno-error |
| CPPFLAGS += -Imybase -I. -I.. $(PC_CFLAGS) |
| LDLIBS += -lpthread -lgcov $(PC_LIBS) |
| |
| MAIN_SOURCES = quipper.cc perf_converter.cc |
| PROGRAMS = $(MAIN_SOURCES:.cc=) |
| |
| LIBRARY_SOURCES_WITH_TESTS = \ |
| address_mapper.cc buffer_reader.cc buffer_writer.cc \ |
| conversion_utils.cc file_reader.cc perf_parser.cc \ |
| perf_reader.cc perf_option_parser.cc perf_recorder.cc \ |
| perf_serializer.cc perf_stat_parser.cc run_command.cc \ |
| sample_info_reader.cc scoped_temp_path.cc utils.cc |
| LIBRARY_SOURCES = mybase/base/logging.cc data_reader.cc data_writer.cc \ |
| perf_protobuf_io.cc $(LIBRARY_SOURCES_WITH_TESTS) |
| TEST_SOURCES = $(LIBRARY_SOURCES_WITH_TESTS:.cc=_test.cc) |
| GENERATED_SOURCES = perf_data.pb.cc perf_stat.pb.cc |
| GENERATED_HEADERS = $(GENERATED_SOURCES:.pb.cc=.pb.h) |
| |
| COMMON_SOURCES = $(LIBRARY_SOURCES) $(GENERATED_SOURCES) |
| COMMON_OBJECTS = $(COMMON_SOURCES:.cc=.o) |
| TEST_COMMON_SOURCES = test_perf_data.cc test_utils.cc |
| TEST_COMMON_OBJECTS = $(TEST_COMMON_SOURCES:.cc=.o) |
| |
| TESTS = $(TEST_SOURCES:.cc=) |
| |
| ALL_SOURCES = $(MAIN_SOURCES) $(COMMON_SOURCES) $(TEST_SOURCES) |
| |
| all: $(PROGRAMS) $(TESTS) |
| @echo Sources compiled! |
| |
| ifneq ($(MAKECMDGOALS),clean) |
| -include $(ALL_SOURCES:.cc=.d) |
| endif |
| |
| # Taken from: |
| # http://www.gnu.org/software/make/manual/make.html#Automatic-Prerequisites |
| %.d: %.cc |
| @set -e; rm -f $@; \ |
| $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \ |
| sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ |
| rm -f $@.$$$$ |
| |
| # Rule for compiling protobufs. |
| %.pb.h %.pb.cc: %.proto |
| protoc --cpp_out=. $^ |
| |
| $(PROGRAMS): %: %.o $(COMMON_OBJECTS) |
| $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) |
| |
| $(TESTS): LDLIBS += -lgtest |
| $(TESTS): %: %.o $(COMMON_OBJECTS) $(TEST_COMMON_OBJECTS) |
| $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) |
| |
| # With large perf.data files, the tests will spew a lot of logging. The |
| # following calls will pipe the logging to a log file. To see test logging, |
| # build with 'FEATURES="test noclean"' and go to the build directory. |
| check: $(TESTS) |
| for test in $(TESTS); do \ |
| case $$test in \ |
| perf_*_test) \ |
| ./$$test 2> ./$$test.stderr.log && continue; \ |
| echo "See $$test.stderr.log for errors" \ |
| ;; \ |
| *) \ |
| ./$$test && continue \ |
| ;; \ |
| esac; \ |
| exit 1; \ |
| done |
| |
| clean: |
| rm -f *.o *.d *.d.* *.a $(PROGRAMS) $(TESTS) $(GENERATED_SOURCES) \ |
| $(GENERATED_HEADERS) |