Patchwork [Lucid] UBUNTU: SAUCE: perf: Link libbfd statically

login
register
mail settings
Submitter Stefan Bader
Date Aug. 2, 2011, 9:38 a.m.
Message ID <1312277892-5468-4-git-send-email-stefan.bader@canonical.com>
Download mbox | patch
Permalink /patch/107870/
State New
Headers show

Comments

Stefan Bader - Aug. 2, 2011, 9:38 a.m.
From 9d6246a468ae0c7ceb0eeccf085944c631699c73 Mon Sep 17 00:00:00 2001
From: Anders Kaseorg <andersk@mit.edu>
Date: Tue, 5 Jul 2011 20:13:40 -0400
Subject: [PATCH] UBUNTU: SAUCE: perf: Link libbfd statically

The binutils-dev package description forbids Debian packages from
linking libbfd dynamically, because that would lead to very strict
versioned dependencies, so that frequent rebuilds are required to keep
every package in sync with current binutils.  It would also make it
impossible to install multiple versions of linux-tools linked against

Patch

different binutils versions.

BugLink: https://bugs.launchpad.net/bugs/783660

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
[v2: Changed to modify EXTLIBS]
[v3: Adapted to apply to Maverick]
[v4: Adapted to apply to Lucid]
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 tools/perf/Makefile |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index e5c942b..9851a06 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -454,18 +454,19 @@  else ifdef HAVE_CPLUS_DEMANGLE
 	EXTLIBS += -liberty
 	BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
 else
-	has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y")
+	LIBBFD := $(shell $(CC) -print-file-name=libbfd.a)
+	has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBBFD) "$(QUIET_STDERR)" && echo y")
 
 	ifeq ($(has_bfd),y)
-		EXTLIBS += -lbfd
+		EXTLIBS += $(LIBBFD)
 	else
-		has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y")
+		has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBBFD) -liberty "$(QUIET_STDERR)" && echo y")
 		ifeq ($(has_bfd_iberty),y)
-			EXTLIBS += -lbfd -liberty
+			EXTLIBS += $(LIBBFD) -liberty
 		else
-			has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y")
+			has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBBFD) -liberty -lz "$(QUIET_STDERR)" && echo y")
 			ifeq ($(has_bfd_iberty_z),y)
-				EXTLIBS += -lbfd -liberty -lz
+				EXTLIBS += $(LIBBFD) -liberty -lz
 			else
 				has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y")
 				ifeq ($(has_cplus_demangle),y)