blob: 2920547ea6d952afa4d8a56e11a4b353ee76474d [file] [log] [blame]
Darin Petkov65b01462010-04-14 13:32:20 -07001# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4#
5# Makefile for metrics utilities -- library, client and daemon
6#
7
8CCONFIG = $(shell $(PKG_CONFIG) --cflags dbus-1 glib-2.0 dbus-glib-1)
9LDCONFIG = $(shell $(PKG_CONFIG) --libs dbus-1 glib-2.0 gthread-2.0 dbus-glib-1)
10
Darin Petkov41e06232010-05-03 16:45:37 -070011CXXFLAGS += -Wall -Werror -fPIC -fno-exceptions $(CCONFIG)
Darin Petkov65b01462010-04-14 13:32:20 -070012
13CLIENT = metrics_client
14DAEMON = metrics_daemon
Darin Petkov2ccef012010-05-05 16:06:37 -070015DAEMON_TEST = metrics_daemon_test
Darin Petkov65b01462010-04-14 13:32:20 -070016LIB = libmetrics.a
17SHAREDLIB = libmetrics.so
Darin Petkov11b8eb32010-05-18 11:00:59 -070018LIB_TEST = metrics_library_test
Darin Petkovf1e85e42010-06-10 15:59:53 -070019COUNTER_TEST = counter_test
Darin Petkov65b01462010-04-14 13:32:20 -070020
Darin Petkovf1e85e42010-06-10 15:59:53 -070021TESTCOUNTER_OBJS = \
22 counter.o \
23 counter_test.o
Darin Petkov65b01462010-04-14 13:32:20 -070024CLIENT_OBJS = \
25 metrics_client.o
Darin Petkovf1e85e42010-06-10 15:59:53 -070026DAEMON_OBJS = \
27 counter.o \
28 metrics_daemon.o \
29 metrics_daemon_main.o
30TESTDAEMON_OBJS = \
31 counter.o \
32 metrics_daemon.o \
33 metrics_daemon_test.o
Darin Petkov65b01462010-04-14 13:32:20 -070034LIB_OBJS = \
Sam Leffler10b301d2010-06-17 14:22:43 -070035 c_metrics_library.o \
Darin Petkov65b01462010-04-14 13:32:20 -070036 metrics_library.o
Darin Petkov11b8eb32010-05-18 11:00:59 -070037TESTLIB_OBJS = \
Darin Petkov11b8eb32010-05-18 11:00:59 -070038 metrics_library_test.o
Darin Petkov65b01462010-04-14 13:32:20 -070039
Chris Masone3fd74742010-08-12 12:19:25 -070040TESTCOUNTER_LIBS = -lgmock -lgtest -lbase -lrt -lpthread -lglib-2.0
Luigi Semenzato0f132bb2011-02-28 11:17:43 -080041DAEMON_LDFLAGS = $(LDFLAGS) $(LDCONFIG) -lrt -lbase -lpthread -lgflags \
Julian Pastarmova2ce30f2011-07-18 17:41:17 +020042 -lglib-2.0 -lrootdev -lpolicy
Darin Petkovfc91b422010-05-12 13:05:45 -070043TESTDAEMON_LIBS = -lgmock -lgtest
Julian Pastarmova2ce30f2011-07-18 17:41:17 +020044TESTLIB_LIBS = -lgtest -lgmock -lbase -lrt -lpthread -lglib-2.0
45POLICY_LIBS = -lpolicy
Darin Petkov65b01462010-04-14 13:32:20 -070046
Darin Petkov2ccef012010-05-05 16:06:37 -070047all: $(LIB) $(SHAREDLIB) $(CLIENT) $(DAEMON)
48
Darin Petkovf1e85e42010-06-10 15:59:53 -070049tests: $(COUNTER_TEST) $(DAEMON_TEST) $(LIB_TEST)
Darin Petkov65b01462010-04-14 13:32:20 -070050
51$(CLIENT): $(CLIENT_OBJS) $(SHAREDLIB)
Julian Pastarmova2ce30f2011-07-18 17:41:17 +020052 $(CXX) $(LDFLAGS) $(POLICY_LIBS) -lrt $^ -o $@
Darin Petkov65b01462010-04-14 13:32:20 -070053
Darin Petkovf1e85e42010-06-10 15:59:53 -070054$(COUNTER_TEST): $(TESTCOUNTER_OBJS)
55 $(CXX) -o $@ $^ $(TESTCOUNTER_LIBS)
56
Darin Petkov65b01462010-04-14 13:32:20 -070057$(DAEMON): $(DAEMON_OBJS) $(SHAREDLIB)
Ken Mixtere4fb0af2010-09-14 18:09:20 -070058 $(CXX) -o $@ $^ $(DAEMON_LDFLAGS)
Darin Petkov65b01462010-04-14 13:32:20 -070059
Darin Petkov11b8eb32010-05-18 11:00:59 -070060$(DAEMON_TEST): $(TESTDAEMON_OBJS)
Darin Petkov65b01462010-04-14 13:32:20 -070061 $(CXX) -o $@ $^ $(DAEMON_LDFLAGS) $(TESTDAEMON_LIBS)
62
63$(LIB): $(LIB_OBJS)
Darin Petkov2ccef012010-05-05 16:06:37 -070064 $(AR) rcs $@ $^
Darin Petkov65b01462010-04-14 13:32:20 -070065
66$(SHAREDLIB): $(LIB_OBJS)
Julian Pastarmova2ce30f2011-07-18 17:41:17 +020067 $(CXX) $(LDFLAGS) $(POLICY_LIBS) -shared $^ -o $@
Darin Petkov65b01462010-04-14 13:32:20 -070068
Darin Petkov11b8eb32010-05-18 11:00:59 -070069$(LIB_TEST): $(TESTLIB_OBJS) $(SHAREDLIB)
Julian Pastarmova2ce30f2011-07-18 17:41:17 +020070 $(CXX) -o $@ $^ $(LDFLAGS) $(POLICY_LIBS) $(TESTLIB_LIBS)
Darin Petkov11b8eb32010-05-18 11:00:59 -070071
Darin Petkov65b01462010-04-14 13:32:20 -070072%.o: %.cc
73 $(CXX) $(CXXFLAGS) -c $< -o $@
74
Darin Petkov65b01462010-04-14 13:32:20 -070075clean:
Darin Petkov11b8eb32010-05-18 11:00:59 -070076 rm -f $(CLIENT) $(DAEMON) $(LIB) $(SHAREDLIB) *.o
Darin Petkovf1e85e42010-06-10 15:59:53 -070077 rm -f $(COUNTER_TEST) $(DAEMON_TEST) $(LIB_TEST)