touchup pkg-config/library handling

Make sure we execute pkg-config twice in the ebuild and not once
per object compile/link.

Fix the order of libraries when linking libmetric -- we need them to
come after the objects, and we need to link in libbase since we use
symbols from it.  (Things happen to be working now because libpolicy
accidentally exports some symbols from libbase.)

BUG=chromium-os:26658
TEST=`emerge-x86-alex metrics` still works

Change-Id: Ic8381ce9cb3e8a6d81d45d613ac66fea8a12b669
Reviewed-on: https://gerrit.chromium.org/gerrit/16290
Reviewed-by: Julian Pastarmov <pastarmovj@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2012-02-21 13:15:09 -05:00 committed by Gerrit
parent 1135355246
commit 8b8dd20794

View file

@ -5,10 +5,10 @@
# Makefile for metrics utilities -- library, client and daemon
#
PKG_CONFIG ?= pkg-config
PC_DEPS = dbus-1 glib-2.0 dbus-glib-1 libchrome libchromeos
CCONFIG = $(shell $(PKG_CONFIG) --cflags $(PC_DEPS))
LDCONFIG = $(shell $(PKG_CONFIG) --libs $(PC_DEPS) gthread-2.0)
CCONFIG := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS))
LDCONFIG := $(shell $(PKG_CONFIG) --libs $(PC_DEPS) gthread-2.0)
CXXFLAGS += -Wall -Werror -fPIC -fno-exceptions $(CCONFIG)
@ -50,14 +50,14 @@ DAEMON_LDFLAGS = $(LDFLAGS) $(LDCONFIG) -lpthread -lgflags \
-lglib-2.0 -lrootdev -lpolicy
TESTDAEMON_LIBS = -lgmock -lgtest
TESTLIB_LIBS = -lgtest -lgmock -lbase -lrt -lpthread -lglib-2.0
POLICY_LIBS = -lpolicy
POLICY_LIBS := -lpolicy $(shell $(PKG_CONFIG) --libs libchrome)
all: $(LIB) $(SHAREDLIB) $(CLIENT) $(DAEMON)
tests: $(COUNTER_TEST) $(DAEMON_TEST) $(LIB_TEST) $(TIMER_TEST)
$(CLIENT): $(CLIENT_OBJS) $(SHAREDLIB)
$(CXX) $(LDFLAGS) $(POLICY_LIBS) -lrt $^ -o $@
$(CXX) $(LDFLAGS) $^ -o $@ $(POLICY_LIBS) -lrt
$(COUNTER_TEST): $(TESTCOUNTER_OBJS)
$(CXX) -o $@ $^ $(TESTCOUNTER_LIBS)
@ -75,7 +75,7 @@ $(LIB): $(LIB_OBJS)
$(AR) rcs $@ $^
$(SHAREDLIB): $(LIB_OBJS)
$(CXX) $(LDFLAGS) $(POLICY_LIBS) -shared $^ -o $@
$(CXX) $(LDFLAGS) -shared $^ -o $@ $(POLICY_LIBS)
$(LIB_TEST): $(TESTLIB_OBJS) $(SHAREDLIB)
$(CXX) -o $@ $^ $(LDFLAGS) $(POLICY_LIBS) $(TESTLIB_LIBS)