Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 1 | # 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 | |
| 8 | CCONFIG = $(shell $(PKG_CONFIG) --cflags dbus-1 glib-2.0 dbus-glib-1) |
| 9 | LDCONFIG = $(shell $(PKG_CONFIG) --libs dbus-1 glib-2.0 gthread-2.0 dbus-glib-1) |
| 10 | |
Darin Petkov | 41e0623 | 2010-05-03 16:45:37 -0700 | [diff] [blame] | 11 | CXXFLAGS += -Wall -Werror -fPIC -fno-exceptions $(CCONFIG) |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 12 | |
| 13 | CLIENT = metrics_client |
| 14 | DAEMON = metrics_daemon |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 15 | DAEMON_TEST = metrics_daemon_test |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 16 | LIB = libmetrics.a |
| 17 | SHAREDLIB = libmetrics.so |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 18 | LIB_TEST = metrics_library_test |
Darin Petkov | f1e85e4 | 2010-06-10 15:59:53 -0700 | [diff] [blame] | 19 | COUNTER_TEST = counter_test |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 20 | |
Darin Petkov | f1e85e4 | 2010-06-10 15:59:53 -0700 | [diff] [blame] | 21 | TESTCOUNTER_OBJS = \ |
| 22 | counter.o \ |
| 23 | counter_test.o |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 24 | CLIENT_OBJS = \ |
| 25 | metrics_client.o |
Darin Petkov | f1e85e4 | 2010-06-10 15:59:53 -0700 | [diff] [blame] | 26 | DAEMON_OBJS = \ |
| 27 | counter.o \ |
| 28 | metrics_daemon.o \ |
| 29 | metrics_daemon_main.o |
| 30 | TESTDAEMON_OBJS = \ |
| 31 | counter.o \ |
| 32 | metrics_daemon.o \ |
| 33 | metrics_daemon_test.o |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 34 | LIB_OBJS = \ |
Sam Leffler | 10b301d | 2010-06-17 14:22:43 -0700 | [diff] [blame] | 35 | c_metrics_library.o \ |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 36 | metrics_library.o |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 37 | TESTLIB_OBJS = \ |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 38 | metrics_library_test.o |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 39 | |
Chris Masone | 3fd7474 | 2010-08-12 12:19:25 -0700 | [diff] [blame] | 40 | TESTCOUNTER_LIBS = -lgmock -lgtest -lbase -lrt -lpthread -lglib-2.0 |
Luigi Semenzato | 0f132bb | 2011-02-28 11:17:43 -0800 | [diff] [blame] | 41 | DAEMON_LDFLAGS = $(LDFLAGS) $(LDCONFIG) -lrt -lbase -lpthread -lgflags \ |
Julian Pastarmov | a2ce30f | 2011-07-18 17:41:17 +0200 | [diff] [blame^] | 42 | -lglib-2.0 -lrootdev -lpolicy |
Darin Petkov | fc91b42 | 2010-05-12 13:05:45 -0700 | [diff] [blame] | 43 | TESTDAEMON_LIBS = -lgmock -lgtest |
Julian Pastarmov | a2ce30f | 2011-07-18 17:41:17 +0200 | [diff] [blame^] | 44 | TESTLIB_LIBS = -lgtest -lgmock -lbase -lrt -lpthread -lglib-2.0 |
| 45 | POLICY_LIBS = -lpolicy |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 46 | |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 47 | all: $(LIB) $(SHAREDLIB) $(CLIENT) $(DAEMON) |
| 48 | |
Darin Petkov | f1e85e4 | 2010-06-10 15:59:53 -0700 | [diff] [blame] | 49 | tests: $(COUNTER_TEST) $(DAEMON_TEST) $(LIB_TEST) |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 50 | |
| 51 | $(CLIENT): $(CLIENT_OBJS) $(SHAREDLIB) |
Julian Pastarmov | a2ce30f | 2011-07-18 17:41:17 +0200 | [diff] [blame^] | 52 | $(CXX) $(LDFLAGS) $(POLICY_LIBS) -lrt $^ -o $@ |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 53 | |
Darin Petkov | f1e85e4 | 2010-06-10 15:59:53 -0700 | [diff] [blame] | 54 | $(COUNTER_TEST): $(TESTCOUNTER_OBJS) |
| 55 | $(CXX) -o $@ $^ $(TESTCOUNTER_LIBS) |
| 56 | |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 57 | $(DAEMON): $(DAEMON_OBJS) $(SHAREDLIB) |
Ken Mixter | e4fb0af | 2010-09-14 18:09:20 -0700 | [diff] [blame] | 58 | $(CXX) -o $@ $^ $(DAEMON_LDFLAGS) |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 59 | |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 60 | $(DAEMON_TEST): $(TESTDAEMON_OBJS) |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 61 | $(CXX) -o $@ $^ $(DAEMON_LDFLAGS) $(TESTDAEMON_LIBS) |
| 62 | |
| 63 | $(LIB): $(LIB_OBJS) |
Darin Petkov | 2ccef01 | 2010-05-05 16:06:37 -0700 | [diff] [blame] | 64 | $(AR) rcs $@ $^ |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 65 | |
| 66 | $(SHAREDLIB): $(LIB_OBJS) |
Julian Pastarmov | a2ce30f | 2011-07-18 17:41:17 +0200 | [diff] [blame^] | 67 | $(CXX) $(LDFLAGS) $(POLICY_LIBS) -shared $^ -o $@ |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 68 | |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 69 | $(LIB_TEST): $(TESTLIB_OBJS) $(SHAREDLIB) |
Julian Pastarmov | a2ce30f | 2011-07-18 17:41:17 +0200 | [diff] [blame^] | 70 | $(CXX) -o $@ $^ $(LDFLAGS) $(POLICY_LIBS) $(TESTLIB_LIBS) |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 71 | |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 72 | %.o: %.cc |
| 73 | $(CXX) $(CXXFLAGS) -c $< -o $@ |
| 74 | |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 75 | clean: |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 76 | rm -f $(CLIENT) $(DAEMON) $(LIB) $(SHAREDLIB) *.o |
Darin Petkov | f1e85e4 | 2010-06-10 15:59:53 -0700 | [diff] [blame] | 77 | rm -f $(COUNTER_TEST) $(DAEMON_TEST) $(LIB_TEST) |