From patchwork Thu Nov 3 16:09:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 9411149 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 17CFC60585 for ; Thu, 3 Nov 2016 16:09:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF2E12AD06 for ; Thu, 3 Nov 2016 16:09:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E111F2AD08; Thu, 3 Nov 2016 16:09:52 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 1E5292AD06 for ; Thu, 3 Nov 2016 16:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756558AbcKCQJv (ORCPT ); Thu, 3 Nov 2016 12:09:51 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:34600 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755112AbcKCQJu (ORCPT ); Thu, 3 Nov 2016 12:09:50 -0400 Received: by mail-yw0-f194.google.com with SMTP id l124so1739070ywb.1; Thu, 03 Nov 2016 09:09:49 -0700 (PDT) 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=UwnjdWq9ZYx7tvwHKVY9nrnBnLrWkR2PCLHUpM02w9I=; b=fcpvzo7G99d9rOuj0kCfYd9TDwtGb8K9L+PiDUuXSE5EjFLwa4YPrR6T8hMiDZ6Osh BhBqkwPBzY6/26sbKB/Hh/qlBCrdyVi62x9oEPMFv9kD8Xtl4+8I9O9Tqy5fC8GnXmYd oS4vw3hVrrwuxYQr6Hz8welpskLt2bqHvaB9xfmAtn8xYu69Y1kxj1DLsGimO1+UySwJ IdDiLqnzTeuuoN8NbMpLAy1LeFvqSfvysYkQZJU9+xhy0yw2Si5Gr8N/T4J5UpQtj0v7 UrlOZsC8dW/bnEcBvX+jAxhAF+9Z/jVy6nJ82Hft0je6q9yaaUeHnCl4ODjBgXCBLIuc 3Cyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UwnjdWq9ZYx7tvwHKVY9nrnBnLrWkR2PCLHUpM02w9I=; b=LS4wnb7o9EZVhIRGaiY+0Oc3XCYNld3RyhAHcTjElJL3cZV47QQI4ciQ/Dxzy/PXMd EbfRzj0TdvdbJUO6g91vCAw6Ue+XfJWzN5bySv6fnGJIEUcXVbxc4iNsBTGeAap3qD+B dhOiRK9UnKLuOsPWGvor3Esh5NiaXkO/Dh2i1bDZGZo5k1QyfaUzLhbruSAgSn0L15U2 xJkFdVDZ71XnsvgXVNQgyF/dy2p1TWTtteL3/IVezVxmN/wD1O6/VCorVEm0aq1OVBZs rPS3rFKRHHtB31wPb523AJH2j/Pxc+ZzjrA5/vUpDgoF9jCIc9l3I913TXwnyS4UCTP8 8oNQ== X-Gm-Message-State: ABUngvfUtc44BNmq+m9TWKbMqfvUbpCFifISFZpoCLGpLtE+INVGnTWbOM7nuz4XddqpSA== X-Received: by 10.129.50.133 with SMTP id y127mr8432642ywy.109.1478189388909; Thu, 03 Nov 2016 09:09:48 -0700 (PDT) Received: from localhost.localdomain ([173.46.78.189]) by smtp.gmail.com with ESMTPSA id u134sm543622ywg.31.2016.11.03.09.09.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Nov 2016 09:09:47 -0700 (PDT) From: Lv Zheng X-Google-Original-From: Lv Zheng To: "Rafael J . Wysocki" , "Rafael J . Wysocki" , Len Brown Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Lv Zheng , Andy Shevchenko Subject: [PATCH v2] tools/power/acpi: Remove direct kernel source include reference Date: Fri, 4 Nov 2016 00:09:24 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ACPICA tools trickily uses integer types, and trickily includes kernel include directory directly, which breaks tools build for some cross compilers. This patch improves ACPICA tools build to make it a bit more robust in such situation by splitting include/acpi into a separate output directory. This patch also contains OUTPUT/srctree cleanups in order to make above fix working for various build environments. Reported-and-tested-by: Yisheng Xie Reported-by: Andy Shevchenko Signed-off-by: Lv Zheng Cc: Andy Shevchenko --- include/acpi/platform/aclinux.h | 3 +++ tools/power/acpi/Makefile.config | 21 ++++++++++---------- tools/power/acpi/Makefile.rules | 34 +++++++++++++++++++++----------- tools/power/acpi/tools/acpidbg/Makefile | 4 +--- tools/power/acpi/tools/acpidbg/acpidbg.c | 8 +++++++- tools/power/acpi/tools/acpidump/Makefile | 4 +--- 6 files changed, 46 insertions(+), 28 deletions(-) diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index a5d98d1..e861a24 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h @@ -191,6 +191,9 @@ #ifndef __init #define __init #endif +#ifndef __iomem +#define __iomem +#endif /* Host-dependent types and defines for user-space ACPICA */ diff --git a/tools/power/acpi/Makefile.config b/tools/power/acpi/Makefile.config index a538ff4..8320616 100644 --- a/tools/power/acpi/Makefile.config +++ b/tools/power/acpi/Makefile.config @@ -8,18 +8,19 @@ # as published by the Free Software Foundation; version 2 # of the License. -include ../../../../scripts/Makefile.include +ifeq ($(srctree),) +srctree := $(patsubst %/,%,$(dir $(shell pwd))) +srctree := $(patsubst %/,%,$(dir $(srctree))) +#$(info Determined 'srctree' to be $(srctree)) +endif + +include $(srctree)/../../scripts/Makefile.include -OUTPUT=./ +OUTPUT=$(srctree)/ ifeq ("$(origin O)", "command line") OUTPUT := $(O)/ endif - -ifneq ($(OUTPUT),) -# check that the output directory actually exists -OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) -$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) -endif +##$(info Determined 'OUTPUT' to be $(OUTPUT)) # --- CONFIGURATION BEGIN --- @@ -70,8 +71,8 @@ WARNINGS := -Wall WARNINGS += $(call cc-supports,-Wstrict-prototypes) WARNINGS += $(call cc-supports,-Wdeclaration-after-statement) -KERNEL_INCLUDE := ../../../include -ACPICA_INCLUDE := ../../../drivers/acpi/acpica +KERNEL_INCLUDE := $(OUTPUT)include +ACPICA_INCLUDE := $(srctree)/../../../drivers/acpi/acpica CFLAGS += -D_LINUX -I$(KERNEL_INCLUDE) -I$(ACPICA_INCLUDE) CFLAGS += $(WARNINGS) diff --git a/tools/power/acpi/Makefile.rules b/tools/power/acpi/Makefile.rules index ec87a9e..1a663bb 100644 --- a/tools/power/acpi/Makefile.rules +++ b/tools/power/acpi/Makefile.rules @@ -8,26 +8,38 @@ # as published by the Free Software Foundation; version 2 # of the License. -$(OUTPUT)$(TOOL): $(TOOL_OBJS) FORCE - $(ECHO) " LD " $@ - $(QUIET) $(LD) $(CFLAGS) $(LDFLAGS) $(TOOL_OBJS) -L$(OUTPUT) -o $@ +objdir := $(OUTPUT)tools/$(TOOL)/ +toolobjs := $(addprefix $(objdir),$(TOOL_OBJS)) +$(OUTPUT)$(TOOL): $(KERNEL_INCLUDE) $(toolobjs) FORCE + $(ECHO) " LD " $(subst $(OUTPUT),,$@) + $(QUIET) $(LD) $(CFLAGS) $(LDFLAGS) $(toolobjs) -L$(OUTPUT) -o $@ + $(ECHO) " STRIP " $(subst $(OUTPUT),,$@) $(QUIET) $(STRIPCMD) $@ -$(OUTPUT)%.o: %.c - $(ECHO) " CC " $@ +$(KERNEL_INCLUDE): + $(ECHO) " MKDIR " $(subst $(OUTPUT),,$@) + $(QUIET) mkdir -p $(KERNEL_INCLUDE) + $(ECHO) " CP " $(subst $(OUTPUT),,$@) + $(QUIET) cp -rf $(srctree)/../../../include/acpi $(KERNEL_INCLUDE)/ + +$(objdir)%.o: %.c + $(ECHO) " CC " $(subst $(OUTPUT),,$@) $(QUIET) $(CC) -c $(CFLAGS) -o $@ $< all: $(OUTPUT)$(TOOL) clean: - -find $(OUTPUT) \( -not -type d \) \ - -and \( -name '*~' -o -name '*.[oas]' \) \ - -type f -print \ - | xargs rm -f - -rm -f $(OUTPUT)$(TOOL) + $(ECHO) " RMOBJ " $(subst $(OUTPUT),,$(objdir)) + $(QUIET) find $(objdir) \( -not -type d \)\ + -and \( -name '*~' -o -name '*.[oas]' \)\ + -type f -print | xargs rm -f + $(ECHO) " RM " $(TOOL) + $(QUIET) rm -f $(OUTPUT)$(TOOL) + $(ECHO) " RMINC " $(subst $(OUTPUT),,$(KERNEL_INCLUDE)) + $(QUIET) rm -rf $(KERNEL_INCLUDE) install-tools: $(INSTALL) -d $(DESTDIR)${sbindir} - $(INSTALL_PROGRAM) $(OUTPUT)$(TOOL) $(DESTDIR)${sbindir} + $(INSTALL_PROGRAM) $(objdir)$(TOOL) $(DESTDIR)${sbindir} uninstall-tools: - rm -f $(DESTDIR)${sbindir}/$(TOOL) diff --git a/tools/power/acpi/tools/acpidbg/Makefile b/tools/power/acpi/tools/acpidbg/Makefile index 352df4b..f2d06e7 100644 --- a/tools/power/acpi/tools/acpidbg/Makefile +++ b/tools/power/acpi/tools/acpidbg/Makefile @@ -17,9 +17,7 @@ vpath %.c \ ../../os_specific/service_layers\ . CFLAGS += -DACPI_APPLICATION -DACPI_SINGLE_THREAD -DACPI_DEBUGGER\ - -I.\ - -I../../../../../drivers/acpi/acpica\ - -I../../../../../include + -I. LDFLAGS += -lpthread TOOL_OBJS = \ acpidbg.o diff --git a/tools/power/acpi/tools/acpidbg/acpidbg.c b/tools/power/acpi/tools/acpidbg/acpidbg.c index a88ac45..4308362 100644 --- a/tools/power/acpi/tools/acpidbg/acpidbg.c +++ b/tools/power/acpi/tools/acpidbg/acpidbg.c @@ -12,10 +12,16 @@ #include /* Headers not included by include/acpi/platform/aclinux.h */ +#include +#include +#include +#include +#include #include #include #include -#include +#include +#include "../../../../../include/linux/circ_buf.h" #define ACPI_AML_FILE "/sys/kernel/debug/acpi/acpidbg" #define ACPI_AML_SEC_TICK 1 diff --git a/tools/power/acpi/tools/acpidump/Makefile b/tools/power/acpi/tools/acpidump/Makefile index 04b5db7..2b94dea 100644 --- a/tools/power/acpi/tools/acpidump/Makefile +++ b/tools/power/acpi/tools/acpidump/Makefile @@ -19,9 +19,7 @@ vpath %.c \ ./\ ../../common\ ../../os_specific/service_layers -CFLAGS += -DACPI_DUMP_APP -I.\ - -I../../../../../drivers/acpi/acpica\ - -I../../../../../include +CFLAGS += -DACPI_DUMP_APP -I. TOOL_OBJS = \ apdump.o\ apfiles.o\