OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 # | 4 # |
5 # Makefile for metrics utilities -- library, client and daemon | 5 # Makefile for metrics utilities -- library, client and daemon |
6 # | 6 # |
7 | 7 |
8 CCONFIG = $(shell $(PKG_CONFIG) --cflags dbus-1 glib-2.0 dbus-glib-1) | 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) | 9 LDCONFIG = $(shell $(PKG_CONFIG) --libs dbus-1 glib-2.0 gthread-2.0 dbus-glib-1) |
10 | 10 |
11 CXXFLAGS += -Wall -Werror -fPIC -fno-exceptions $(CCONFIG) | 11 CXXFLAGS += -Wall -Werror -fPIC -fno-exceptions $(CCONFIG) |
12 | 12 |
13 CLIENT = metrics_client | 13 CLIENT = metrics_client |
14 DAEMON = metrics_daemon | 14 DAEMON = metrics_daemon |
15 DAEMON_TEST = metrics_daemon_test | 15 DAEMON_TEST = metrics_daemon_test |
16 LIB = libmetrics.a | 16 LIB = libmetrics.a |
17 SHAREDLIB = libmetrics.so | 17 SHAREDLIB = libmetrics.so |
| 18 LIB_TEST = metrics_library_test |
18 | 19 |
19 CLIENT_OBJS = \ | 20 CLIENT_OBJS = \ |
20 metrics_client.o | 21 metrics_client.o |
21 LIB_OBJS = \ | 22 LIB_OBJS = \ |
22 metrics_library.o | 23 metrics_library.o |
| 24 TESTLIB_OBJS = \ |
| 25 metrics_library.o \ |
| 26 metrics_library_test.o |
23 DAEMON_OBJS = \ | 27 DAEMON_OBJS = \ |
24 metrics_daemon.o \ | 28 metrics_daemon.o \ |
25 metrics_daemon_main.o | 29 metrics_daemon_main.o |
26 TESTDAEMON_OBJS = \ | 30 TESTDAEMON_OBJS = \ |
27 metrics_daemon.o \ | 31 metrics_daemon.o \ |
28 metrics_daemon_test.o | 32 metrics_daemon_test.o |
29 | 33 |
30 DAEMON_LDFLAGS = $(LDCONFIG) -lrt -lbase -lpthread -lgflags | 34 DAEMON_LDFLAGS = $(LDFLAGS) $(LDCONFIG) -lrt -lbase -lpthread -lgflags |
31 TESTDAEMON_LIBS = -lgmock -lgtest | 35 TESTDAEMON_LIBS = -lgmock -lgtest |
| 36 TESTLIB_LIBS = -lgtest -lbase -lrt -lpthread |
32 | 37 |
33 all: $(LIB) $(SHAREDLIB) $(CLIENT) $(DAEMON) | 38 all: $(LIB) $(SHAREDLIB) $(CLIENT) $(DAEMON) |
34 | 39 |
35 tests: $(DAEMON_TEST) | 40 tests: $(DAEMON_TEST) $(LIB_TEST) |
36 | 41 |
37 $(CLIENT): $(CLIENT_OBJS) $(SHAREDLIB) | 42 $(CLIENT): $(CLIENT_OBJS) $(SHAREDLIB) |
38 $(CXX) $(LDFLAGS) $^ -o $@ | 43 $(CXX) $(LDFLAGS) $^ -o $@ |
39 | 44 |
40 $(DAEMON): $(DAEMON_OBJS) $(SHAREDLIB) | 45 $(DAEMON): $(DAEMON_OBJS) $(SHAREDLIB) |
41 $(CXX) -o $@ $^ $(DAEMON_LDFLAGS) | 46 $(CXX) -o $@ $^ $(DAEMON_LDFLAGS) |
42 | 47 |
43 $(DAEMON_TEST): $(TESTDAEMON_OBJS) $(SHAREDLIB) | 48 $(DAEMON_TEST): $(TESTDAEMON_OBJS) |
44 $(CXX) -o $@ $^ $(DAEMON_LDFLAGS) $(TESTDAEMON_LIBS) | 49 $(CXX) -o $@ $^ $(DAEMON_LDFLAGS) $(TESTDAEMON_LIBS) |
45 | 50 |
46 $(LIB): $(LIB_OBJS) | 51 $(LIB): $(LIB_OBJS) |
47 $(AR) rcs $@ $^ | 52 $(AR) rcs $@ $^ |
48 | 53 |
49 $(SHAREDLIB): $(LIB_OBJS) | 54 $(SHAREDLIB): $(LIB_OBJS) |
50 $(CXX) $(LDFLAGS) -shared $^ -o $@ | 55 $(CXX) $(LDFLAGS) -shared $^ -o $@ |
51 | 56 |
| 57 $(LIB_TEST): $(TESTLIB_OBJS) $(SHAREDLIB) |
| 58 $(CXX) -o $@ $^ $(LDFLAGS) $(TESTLIB_LIBS) |
| 59 |
52 %.o: %.cc | 60 %.o: %.cc |
53 $(CXX) $(CXXFLAGS) -c $< -o $@ | 61 $(CXX) $(CXXFLAGS) -c $< -o $@ |
54 | 62 |
55 # dependencies in addition to those defined by the rules | 63 # dependencies in addition to those defined by the rules |
56 | 64 |
57 metrics_daemon.o: \ | 65 metrics_daemon.o: \ |
58 metrics_daemon.h \ | 66 metrics_daemon.h \ |
59 network_states.h \ | 67 network_states.h \ |
60 power_states.h | 68 power_states.h |
61 metrics_daemon_test.o: \ | 69 metrics_daemon_test.o: \ |
62 metrics_daemon.h \ | 70 metrics_daemon.h \ |
63 network_states.h \ | 71 network_states.h \ |
64 power_states.h | 72 power_states.h |
65 | 73 |
66 clean: | 74 clean: |
67 » rm -f $(CLIENT) $(DAEMON) $(LIB) $(SHAREDLIB) $(TESTDAEMON) *.o | 75 » rm -f $(CLIENT) $(DAEMON) $(LIB) $(SHAREDLIB) *.o |
| 76 » rm -f $(DAEMON_TEST) $(LIB_TEST) |
OLD | NEW |