From patchwork Thu Mar 1 12:55:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Puschmann X-Patchwork-Id: 10251259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 93BE960365 for ; Thu, 1 Mar 2018 13:02:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 855A728DB1 for ; Thu, 1 Mar 2018 13:02:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8411C28F16; Thu, 1 Mar 2018 13:02:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1697029111 for ; Thu, 1 Mar 2018 13:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030875AbeCANBz (ORCPT ); Thu, 1 Mar 2018 08:01:55 -0500 Received: from mx1.emlix.com ([46.4.235.150]:43190 "EHLO mx1.emlix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030657AbeCANBy (ORCPT ); Thu, 1 Mar 2018 08:01:54 -0500 X-Greylist: delayed 357 seconds by postgrey-1.27 at vger.kernel.org; Thu, 01 Mar 2018 08:01:54 EST Received: from mailer.emlix.com (unknown [80.150.94.234]) by mx1.emlix.com (Postfix) with ESMTP id B4D7225EF5B; Thu, 1 Mar 2018 13:55:55 +0100 (CET) Received: by mailer.emlix.com id 1erNo0-0000DE-N5; Thu, 01 Mar 2018 13:59:28 +0100 From: Philipp Puschmann To: yamada.masahiro@socionext.com Cc: michal.lkml@markovi.net, jpoimboe@redhat.com, peterz@infradead.org, linux-kbuild@vger.kernel.org, Philipp Puschmann Subject: [PATCH] objtool: make use of pkg-config for libelf Date: Thu, 1 Mar 2018 13:55:37 +0100 Message-Id: <20180301125537.14160-1-pp@emlix.com> Organization: emlix gmbh, Goettingen, Germany Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For libelf with non-standard paths make use of pkg-config. Signed-off-by: Philipp Puschmann --- 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 ' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)