From patchwork Tue Dec 1 16:14:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Renninger X-Patchwork-Id: 7738621 X-Patchwork-Delegate: rjw@sisk.pl 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 1B6979F39D for ; Tue, 1 Dec 2015 16:14:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D69A204B5 for ; Tue, 1 Dec 2015 16:14:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5D5320524 for ; Tue, 1 Dec 2015 16:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755546AbbLAQOZ (ORCPT ); Tue, 1 Dec 2015 11:14:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:49851 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755580AbbLAQOV (ORCPT ); Tue, 1 Dec 2015 11:14:21 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 21421AC0B; Tue, 1 Dec 2015 16:14:19 +0000 (UTC) From: Thomas Renninger To: rjw@rjwysocki.net Cc: linux-pm@vger.kernel.org, Thomas Renninger , "sriram@marirs.net.in" Subject: [PATCH 2/5] cpupower: Provide STATIC variable in Makefile for debug builds Date: Tue, 1 Dec 2015 17:14:14 +0100 Message-Id: <1448986457-12844-3-git-send-email-trenn@suse.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448986457-12844-1-git-send-email-trenn@suse.com> References: <1448986457-12844-1-git-send-email-trenn@suse.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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 When working on cpupower code, you often want to compile library code into the binary. This allows to execute modified cpupower code, even with library changes without doing "make install" CC: sriram@marirs.net.in Signed-off-by: Thomas Renninger --- tools/power/cpupower/Makefile | 19 +++++++++++++++++++ tools/power/cpupower/bench/Makefile | 8 +++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile index 2e2ba2e..0adaf0c 100644 --- a/tools/power/cpupower/Makefile +++ b/tools/power/cpupower/Makefile @@ -47,6 +47,11 @@ NLS ?= true # cpufreq-bench benchmarking tool CPUFREQ_BENCH ?= true +# Do not build libraries, but build the code in statically +# Libraries are still built, otherwise the Makefile code would +# be rather ugly. +export STATIC ?= false + # Prefix to the directories we're installing to DESTDIR ?= @@ -161,6 +166,12 @@ ifeq ($(strip $(CPUFREQ_BENCH)),true) COMPILE_BENCH += compile-bench endif +ifeq ($(strip $(STATIC)),true) + UTIL_OBJS += $(LIB_OBJS) + UTIL_HEADERS += $(LIB_HEADERS) + UTIL_SRC += $(LIB_SRC) +endif + CFLAGS += $(WARNINGS) ifeq ($(strip $(V)),false) @@ -209,7 +220,11 @@ $(OUTPUT)%.o: %.c $(OUTPUT)cpupower: $(UTIL_OBJS) $(OUTPUT)libcpupower.so.$(LIB_MAJ) $(ECHO) " CC " $@ +ifeq ($(strip $(STATIC)),true) + $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lrt -lpci -L$(OUTPUT) -o $@ +else $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lcpupower -lrt -lpci -L$(OUTPUT) -o $@ +endif $(QUIET) $(STRIPCMD) $@ $(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC) @@ -291,7 +306,11 @@ install-bench: @#DESTDIR must be set from outside to survive @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) install +ifeq ($(strip $(STATIC)),true) +install: all install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH) +else install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH) +endif uninstall: - rm -f $(DESTDIR)${libdir}/libcpupower.* diff --git a/tools/power/cpupower/bench/Makefile b/tools/power/cpupower/bench/Makefile index 7ec7021..d0f879b 100644 --- a/tools/power/cpupower/bench/Makefile +++ b/tools/power/cpupower/bench/Makefile @@ -5,9 +5,15 @@ ifneq ($(O),) endif endif +ifeq ($(strip $(STATIC)),true) +LIBS = -L../ -L$(OUTPUT) -lm +OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o \ + $(OUTPUT)../lib/cpufreq.o $(OUTPUT)../lib/sysfs.o +else LIBS = -L../ -L$(OUTPUT) -lm -lcpupower - OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o +endif + CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\" $(OUTPUT)%.o : %.c