From patchwork Wed Feb 18 02:18:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 5842431 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C330C9F37F for ; Wed, 18 Feb 2015 02:20:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0535220155 for ; Wed, 18 Feb 2015 02:20:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 178B020149 for ; Wed, 18 Feb 2015 02:20:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751480AbbBRCT7 (ORCPT ); Tue, 17 Feb 2015 21:19:59 -0500 Received: from mail-pd0-f182.google.com ([209.85.192.182]:44914 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752612AbbBRCTh (ORCPT ); Tue, 17 Feb 2015 21:19:37 -0500 Received: by pdbnh10 with SMTP id nh10so43776759pdb.11; Tue, 17 Feb 2015 18:19:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PWwJjE2S88zpLMHLZLMwK+Gn708BQ0PoYQO9u3yRYjc=; b=KE30178ardprL6mVqel98EXHtWC42uoOMHvDjODmrJgF4MdoDDbm+Aaz352zFZl631 nvgRGs+M+NpTZHaACgUv6PDXqBIILs/wYcEZDzcE7a8FcFW8QS+BsFBG4qwzzPM6BVD/ Y0rg5t4iNtqs9X24I8rmP3Gn/d7R+D1vhIu/Zo0CxPnQljfma9qQlA7NvjhSio37KWdJ negtsPqbh5r0KsArzp7joB2Y98jnqv0sohJMMF3fqdVwrVSUawyShWiElhCrbziMFGPF OAdlNE9wHjvT3J4+4NRpv1eJcVZuzZgUPl19Zg0oLUStmq1r10BPKAZ7oRPO82Rcr6jD k2wA== X-Received: by 10.70.42.206 with SMTP id q14mr35885811pdl.141.1424225976803; Tue, 17 Feb 2015 18:19:36 -0800 (PST) Received: from ld-irv-0074.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id ff10sm19169159pad.1.2015.02.17.18.19.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Feb 2015 18:19:36 -0800 (PST) From: Brian Norris To: Zhang Rui , Cc: Neil Horman , Brian Norris , Javi Merino , Florian Fainelli , , Subject: [PATCH 7/8] tools/thermal: tmon: use pkg-config to determine library dependencies Date: Tue, 17 Feb 2015 18:18:35 -0800 Message-Id: <1424225916-13488-8-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424225916-13488-1-git-send-email-computersforpeace@gmail.com> References: <1424225916-13488-1-git-send-email-computersforpeace@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some distros (e.g., Arch Linux) don't package the tinfo library separately from ncurses, so don't unconditionally include it. Instead, use pkg-config. The $(STATIC) ugliness is to handle the reported build case from commit 6b533269fb25 ("tools/thermal: tmon: fix compilation errors when building statically"), where a developer wants to be able to build with: make LDFLAGS=-static which requires an additional pkg-config flag. Finally, support a lowest common denominator fallback (-lpanel -lncurses) for build systems that don't have pkg-config entries for ncurses. Signed-off-by: Brian Norris --- tools/thermal/tmon/Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile index 13d1876c7889..0788621c8d76 100644 --- a/tools/thermal/tmon/Makefile +++ b/tools/thermal/tmon/Makefile @@ -16,12 +16,21 @@ INSTALL_CONFIGFILE=install -m 644 -p CONFIG_FILE= CONFIG_PATH= +# Static builds might require -ltinfo, for instance +ifneq ($(findstring -static, $(LDFLAGS)),) +STATIC := --static +endif + +TMON_LIBS=-lm -lpthread +TMON_LIBS += $(shell pkg-config --libs $(STATIC) panelw ncursesw 2> /dev/null || \ + pkg-config --libs $(STATIC) panel ncurses 2> /dev/null || \ + echo -lpanel -lncurses) OBJS = tmon.o tui.o sysfs.o pid.o OBJS += tmon: $(OBJS) Makefile tmon.h - $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -ltinfo -lpthread + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS) valgrind: tmon sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null