public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Philipp Puschmann <pp@emlix.com>
To: yamada.masahiro@socionext.com
Cc: michal.lkml@markovi.net, jpoimboe@redhat.com,
	peterz@infradead.org, linux-kbuild@vger.kernel.org,
	Philipp Puschmann <pp@emlix.com>
Subject: [PATCH] objtool: make use of pkg-config for libelf
Date: Thu,  1 Mar 2018 13:55:37 +0100	[thread overview]
Message-ID: <20180301125537.14160-1-pp@emlix.com> (raw)

For libelf with non-standard paths make use of pkg-config.

Signed-off-by: Philipp Puschmann <pp@emlix.com>
---
 Makefile               | 4 +++-
 tools/objtool/Makefile | 8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 659a7780aeb3..31b296b0e941 100644
--- a/Makefile
+++ b/Makefile
@@ -953,8 +953,10 @@ endif
 export mod_sign_cmd
 
 ifdef CONFIG_STACK_VALIDATION
+  LIBELF_LIBS = $(shell pkg-config --libs libelf 2> /dev/null || \
+                        echo -lelf)
   has_libelf := $(call try-run,\
-		echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
+		echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(LIBELF_LIBS) -,1,0)
   ifeq ($(has_libelf),1)
     objtool_target := tools/objtool FORCE
   else
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index e6acc281dd37..c565eff8c393 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -27,12 +27,16 @@ OBJTOOL_IN := $(OBJTOOL)-in.o
 
 all: $(OBJTOOL)
 
+LIBELF_LIBS     = $(shell pkg-config --libs libelf 2> /dev/null || \
+                        echo -lelf)
+LIBELF_INCLUDES = $(shell pkg-config --cflags libelf 2> /dev/null)
 INCLUDES := -I$(srctree)/tools/include \
 	    -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
-	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include
+	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include \
+	    $(LIBELF_INCLUDES)
 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
 CFLAGS   += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
-LDFLAGS  += -lelf $(LIBSUBCMD)
+LDFLAGS  += $(LIBELF_LIBS) $(LIBSUBCMD)
 
 # Allow old libelf to be used:
 elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
-- 
2.16.1


             reply	other threads:[~2018-03-01 13:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01 12:55 Philipp Puschmann [this message]
2018-03-05 14:53 ` [PATCH] objtool: make use of pkg-config for libelf Josh Poimboeuf
2018-03-05 15:21   ` Robin Jarry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180301125537.14160-1-pp@emlix.com \
    --to=pp@emlix.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=peterz@infradead.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox