From patchwork Mon May 13 06:22:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10940353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0437A13AD for ; Mon, 13 May 2019 06:26:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E874A223B3 for ; Mon, 13 May 2019 06:26:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCAE026E40; Mon, 13 May 2019 06:26:47 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 25053223B3 for ; Mon, 13 May 2019 06:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727102AbfEMG0q (ORCPT ); Mon, 13 May 2019 02:26:46 -0400 Received: from condef-02.nifty.com ([202.248.20.67]:35237 "EHLO condef-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbfEMG0q (ORCPT ); Mon, 13 May 2019 02:26:46 -0400 Received: from conuserg-10.nifty.com ([10.126.8.73])by condef-02.nifty.com with ESMTP id x4D6Md9M004470 for ; Mon, 13 May 2019 15:22:39 +0900 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id x4D6MKMG031944; Mon, 13 May 2019 15:22:23 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x4D6MKMG031944 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1557728544; bh=d8gbEARL3UEIkmRM3efisa39Z3caCnTyjI4aXWlpqto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5SBMawRToWN8wXGdhy3zro5xY47D7sCmKP5XsuainrhzTWMQ6wYv49fVxLJTgggU fkamefo4i1gUpwYmRNgGYS+lSXdVa8RLYxFtG/8lVDQcXVbNZM0QoTLmJi8mXRjJcw tcKGm6P30sZEWp1PGwoZdZ331QFjfMdrDwtVoJ94zCZNouSpiURUWpXVYGYwT2AXWm VXiwCe/25fR2S29w9qlOrPy2H3r5mb1PS+6a59VpoAYf4OiNGIwviu9W6kJ3HPuXPk FjLmGBGvqKoVU8A4SK18OLAIDgCErvnF6U5tRAOMKoPtFlw6OB4v54TxMYTAkWK9zQ LHIVXfsL/WspQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , netdev@vger.kernel.org, x86@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/4] treewide: prefix header search paths with $(srctree)/ Date: Mon, 13 May 2019 15:22:16 +0900 Message-Id: <20190513062217.20750-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513062217.20750-1-yamada.masahiro@socionext.com> References: <20190513062217.20750-1-yamada.masahiro@socionext.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the Kbuild core manipulates header search paths in a crazy way [1]. To fix this mess, I want all Makefiles to add explicit $(srctree)/ to the search paths in the srctree. Some Makefiles are already written in that way, but not all. The goal of this work is to make the notation consistent, and finally get rid of the gross hacks. Having whitespaces after -I does not matter since commit 48f6e3cf5bc6 ("kbuild: do not drop -I without parameter"). [1]: https://patchwork.kernel.org/patch/9632347/ Signed-off-by: Masahiro Yamada --- arch/mips/pnx833x/Platform | 2 +- arch/powerpc/Makefile | 2 +- arch/sh/Makefile | 4 ++-- arch/x86/kernel/Makefile | 2 +- arch/x86/mm/Makefile | 2 +- arch/xtensa/boot/lib/Makefile | 2 +- drivers/hid/intel-ish-hid/Makefile | 2 +- drivers/net/ethernet/chelsio/libcxgb/Makefile | 2 +- drivers/target/iscsi/cxgbit/Makefile | 6 +++--- drivers/usb/storage/Makefile | 2 +- fs/ocfs2/dlm/Makefile | 3 +-- fs/ocfs2/dlmfs/Makefile | 2 +- fs/xfs/Makefile | 4 ++-- net/bpfilter/Makefile | 2 +- scripts/dtc/Makefile | 6 +++--- scripts/genksyms/Makefile | 4 ++-- scripts/kconfig/Makefile | 4 ++-- 17 files changed, 25 insertions(+), 26 deletions(-) diff --git a/arch/mips/pnx833x/Platform b/arch/mips/pnx833x/Platform index 794526caab12..6b1a847d593f 100644 --- a/arch/mips/pnx833x/Platform +++ b/arch/mips/pnx833x/Platform @@ -1,5 +1,5 @@ # NXP STB225 platform-$(CONFIG_SOC_PNX833X) += pnx833x/ -cflags-$(CONFIG_SOC_PNX833X) += -Iarch/mips/include/asm/mach-pnx833x +cflags-$(CONFIG_SOC_PNX833X) += -I $(srctree)/arch/mips/include/asm/mach-pnx833x load-$(CONFIG_NXP_STB220) += 0xffffffff80001000 load-$(CONFIG_NXP_STB225) += 0xffffffff80001000 diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 258ea6b2f2e7..c345b79414a9 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -211,7 +211,7 @@ endif asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) -KBUILD_CPPFLAGS += -Iarch/$(ARCH) $(asinstr) +KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr) KBUILD_AFLAGS += $(AFLAGS-y) KBUILD_CFLAGS += $(call cc-option,-msoft-float) KBUILD_CFLAGS += -pipe $(CFLAGS-y) diff --git a/arch/sh/Makefile b/arch/sh/Makefile index 4009bef62fe9..b4a86f27e048 100644 --- a/arch/sh/Makefile +++ b/arch/sh/Makefile @@ -191,8 +191,8 @@ cpuincdir-y += cpu-common # Must be last drivers-y += arch/sh/drivers/ drivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/ -cflags-y += $(foreach d, $(cpuincdir-y), -Iarch/sh/include/$(d)) \ - $(foreach d, $(machdir-y), -Iarch/sh/include/$(d)) +cflags-y += $(foreach d, $(cpuincdir-y), -I $(srctree)/arch/sh/include/$(d)) \ + $(foreach d, $(machdir-y), -I $(srctree)/arch/sh/include/$(d)) KBUILD_CFLAGS += -pipe $(cflags-y) KBUILD_CPPFLAGS += $(cflags-y) diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 00b7e27bc2b7..ce1b5cc360a2 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -42,7 +42,7 @@ endif # non-deterministic coverage. KCOV_INSTRUMENT := n -CFLAGS_irq.o := -I$(src)/../include/asm/trace +CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace obj-y := process_$(BITS).o signal.o obj-$(CONFIG_COMPAT) += signal_compat.o diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile index 4b101dd6e52f..84373dc9b341 100644 --- a/arch/x86/mm/Makefile +++ b/arch/x86/mm/Makefile @@ -21,7 +21,7 @@ CFLAGS_physaddr.o := $(nostackp) CFLAGS_setup_nx.o := $(nostackp) CFLAGS_mem_encrypt_identity.o := $(nostackp) -CFLAGS_fault.o := -I$(src)/../include/asm/trace +CFLAGS_fault.o := -I $(srctree)/$(src)/../include/asm/trace obj-$(CONFIG_X86_PAT) += pat_rbtree.o diff --git a/arch/xtensa/boot/lib/Makefile b/arch/xtensa/boot/lib/Makefile index 355127faade1..e3d717c7bfa1 100644 --- a/arch/xtensa/boot/lib/Makefile +++ b/arch/xtensa/boot/lib/Makefile @@ -7,7 +7,7 @@ zlib := inffast.c inflate.c inftrees.c lib-y += $(zlib:.c=.o) zmem.o -ccflags-y := -Ilib/zlib_inflate +ccflags-y := -I $(srctree)/lib/zlib_inflate ifdef CONFIG_FUNCTION_TRACER CFLAGS_REMOVE_inflate.o = -pg CFLAGS_REMOVE_zmem.o = -pg diff --git a/drivers/hid/intel-ish-hid/Makefile b/drivers/hid/intel-ish-hid/Makefile index 2de97e4b7740..f0a82b1c7cb9 100644 --- a/drivers/hid/intel-ish-hid/Makefile +++ b/drivers/hid/intel-ish-hid/Makefile @@ -23,4 +23,4 @@ intel-ishtp-hid-objs += ishtp-hid-client.o obj-$(CONFIG_INTEL_ISH_FIRMWARE_DOWNLOADER) += intel-ishtp-loader.o intel-ishtp-loader-objs += ishtp-fw-loader.o -ccflags-y += -Idrivers/hid/intel-ish-hid/ishtp +ccflags-y += -I $(srctree)/$(src)/ishtp diff --git a/drivers/net/ethernet/chelsio/libcxgb/Makefile b/drivers/net/ethernet/chelsio/libcxgb/Makefile index 2534e30a1560..441913b5221e 100644 --- a/drivers/net/ethernet/chelsio/libcxgb/Makefile +++ b/drivers/net/ethernet/chelsio/libcxgb/Makefile @@ -1,4 +1,4 @@ -ccflags-y := -Idrivers/net/ethernet/chelsio/cxgb4 +ccflags-y := -I $(srctree)/$(src)/../cxgb4 obj-$(CONFIG_CHELSIO_LIB) += libcxgb.o diff --git a/drivers/target/iscsi/cxgbit/Makefile b/drivers/target/iscsi/cxgbit/Makefile index d16aaae7ba2a..0dcaf2006f78 100644 --- a/drivers/target/iscsi/cxgbit/Makefile +++ b/drivers/target/iscsi/cxgbit/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -ccflags-y := -Idrivers/net/ethernet/chelsio/cxgb4 -ccflags-y += -Idrivers/net/ethernet/chelsio/libcxgb -ccflags-y += -Idrivers/target/iscsi +ccflags-y := -I $(srctree)/drivers/net/ethernet/chelsio/cxgb4 +ccflags-y += -I $(srctree)/drivers/net/ethernet/chelsio/libcxgb +ccflags-y += -I $(srctree)/drivers/target/iscsi obj-$(CONFIG_ISCSI_TARGET_CXGB4) += cxgbit.o diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile index c5126a4cd954..a67ddcbb4e24 100644 --- a/drivers/usb/storage/Makefile +++ b/drivers/usb/storage/Makefile @@ -6,7 +6,7 @@ # Rewritten to use lists instead of if-statements. # -ccflags-y := -Idrivers/scsi +ccflags-y := -I $(srctree)/drivers/scsi obj-$(CONFIG_USB_UAS) += uas.o obj-$(CONFIG_USB_STORAGE) += usb-storage.o diff --git a/fs/ocfs2/dlm/Makefile b/fs/ocfs2/dlm/Makefile index ef2854422a6e..3d4041f0431e 100644 --- a/fs/ocfs2/dlm/Makefile +++ b/fs/ocfs2/dlm/Makefile @@ -1,7 +1,6 @@ -ccflags-y := -I$(src)/.. +ccflags-y := -I $(srctree)/$(src)/.. obj-$(CONFIG_OCFS2_FS_O2CB) += ocfs2_dlm.o ocfs2_dlm-objs := dlmdomain.o dlmdebug.o dlmthread.o dlmrecovery.o \ dlmmaster.o dlmast.o dlmconvert.o dlmlock.o dlmunlock.o - diff --git a/fs/ocfs2/dlmfs/Makefile b/fs/ocfs2/dlmfs/Makefile index 33431a0296a3..0a0b93d940fe 100644 --- a/fs/ocfs2/dlmfs/Makefile +++ b/fs/ocfs2/dlmfs/Makefile @@ -1,4 +1,4 @@ -ccflags-y := -I$(src)/.. +ccflags-y := -I $(srctree)/$(src)/.. obj-$(CONFIG_OCFS2_FS) += ocfs2_dlmfs.o diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 1dfc6df2e2bd..91831975363b 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile @@ -4,8 +4,8 @@ # All Rights Reserved. # -ccflags-y += -I$(src) # needed for trace events -ccflags-y += -I$(src)/libxfs +ccflags-y += -I $(srctree)/$(src) # needed for trace events +ccflags-y += -I $(srctree)/$(src)/libxfs ccflags-$(CONFIG_XFS_DEBUG) += -g diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile index 854395fb98cd..aa945ab5b655 100644 --- a/net/bpfilter/Makefile +++ b/net/bpfilter/Makefile @@ -5,7 +5,7 @@ hostprogs-y := bpfilter_umh bpfilter_umh-objs := main.o -KBUILD_HOSTCFLAGS += -Itools/include/ -Itools/include/uapi +KBUILD_HOSTCFLAGS += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi HOSTCC := $(CC) ifeq ($(CONFIG_BPFILTER_UMH), y) diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index 5f227d8d39d8..82160808765c 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile @@ -9,7 +9,7 @@ dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o # Source files need to get at the userspace version of libfdt_env.h to compile -HOST_EXTRACFLAGS := -I$(src)/libfdt +HOST_EXTRACFLAGS := -I $(srctree)/$(src)/libfdt ifeq ($(wildcard /usr/include/yaml.h),) ifneq ($(CHECK_DTBS),) @@ -23,8 +23,8 @@ HOSTLDLIBS_dtc := -lyaml endif # Generated files need one more search path to include headers in source tree -HOSTCFLAGS_dtc-lexer.lex.o := -I$(src) -HOSTCFLAGS_dtc-parser.tab.o := -I$(src) +HOSTCFLAGS_dtc-lexer.lex.o := -I $(srctree)/$(src) +HOSTCFLAGS_dtc-parser.tab.o := -I $(srctree)/$(src) # dependencies on generated files need to be listed explicitly $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile index 03b7ce97de14..66c314bc5933 100644 --- a/scripts/genksyms/Makefile +++ b/scripts/genksyms/Makefile @@ -31,8 +31,8 @@ $(obj)/parse.tab.h: $(src)/parse.y FORCE endif # -I needed for generated C source (shipped source) -HOSTCFLAGS_parse.tab.o := -I$(src) -HOSTCFLAGS_lex.lex.o := -I$(src) +HOSTCFLAGS_parse.tab.o := -I $(srctree)/$(src) +HOSTCFLAGS_lex.lex.o := -I $(srctree)/$(src) # dependencies on generated files need to be listed explicitly $(obj)/lex.lex.o: $(obj)/parse.tab.h diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 7c5dc31c1d95..5e0cd86cb4a7 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -147,8 +147,8 @@ common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \ symbol.o $(obj)/lexer.lex.o: $(obj)/parser.tab.h -HOSTCFLAGS_lexer.lex.o := -I$(src) -HOSTCFLAGS_parser.tab.o := -I$(src) +HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) +HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) # conf: Used for defconfig, oldconfig and related targets hostprogs-y += conf From patchwork Mon May 13 06:22:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10940343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67FD213AD for ; Mon, 13 May 2019 06:25:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A956201B1 for ; Mon, 13 May 2019 06:25:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EC86223B3; Mon, 13 May 2019 06:25:19 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 D8B1E20501 for ; Mon, 13 May 2019 06:25:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726259AbfEMGZS (ORCPT ); Mon, 13 May 2019 02:25:18 -0400 Received: from condef-10.nifty.com ([202.248.20.75]:57320 "EHLO condef-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbfEMGZR (ORCPT ); Mon, 13 May 2019 02:25:17 -0400 Received: from conuserg-10.nifty.com ([10.126.8.73])by condef-10.nifty.com with ESMTP id x4D6MeGB007299; Mon, 13 May 2019 15:22:40 +0900 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id x4D6MKMH031944; Mon, 13 May 2019 15:22:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x4D6MKMH031944 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1557728546; bh=OfIIhemlSrlQXaNMkfHqX67qd7jBRMPIHtESheuz9Xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGuNVM4HIJn3sGkIzCx0NaTE96qTKfhXUc4a/D58K2M1iRkcFfX8P2tF8AE2NGZJD D1PPv7MLc7uTQo3h9ng9GAWKckObeJnnAPN+WGFJitVDzWkSRysrBoEYGdk1wYvmRM s+c8yRHquRkzlJyY2Q8AsnOGT4QmMNN5w7lGIZxrOpE9wzZjEsHc2L6bHsceL2e8fs v6DK5RAoFJy+JbCP/d0RwDMMph4APDu82HpeTu5xqXz39PlzCgg0FEmID4TWt4M8+4 K78FqMrTdboC53WryiUe08oETiyFMjLTjiEQzHDUYJscz5eI8NbjZl7ETLQjC04Ubo NF2HmL3+14c4g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Mauro Carvalho Chehab , devicetree@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, x86@kernel.org, linux-media@vger.kernel.org Subject: [PATCH 4/4] kbuild: remove 'addtree' and 'flags' magic for header search paths Date: Mon, 13 May 2019 15:22:17 +0900 Message-Id: <20190513062217.20750-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513062217.20750-1-yamada.masahiro@socionext.com> References: <20190513062217.20750-1-yamada.masahiro@socionext.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The 'addtree' and 'flags' in scripts/Kbuild.include are so compilecated and ugly. As I mentioned in [1], Kbuild should stop automatic prefixing of header search path options. Instead, in-kernel Makefiles should explicitly add $(srctree)/ to the search paths in the srctree. Kbuild still caters to add $(srctree)/$(src) and $(objtree)/$(obj) to the header search path for O= building, but never touches extra compiler options from ccflags-y etc. Going forward, in-kernel Makefiles should explicitly specify $(srctree)/ if extra search paths are needed. Example) ccflags-y += -I $(srctree)/foo/bar You do not have to change external module Makefiles because $(src) is already an absolute path for external modules. Example) ccflags-y += -I $(src)/foo/bar [1]: https://patchwork.kernel.org/patch/9632347/ Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 8 -------- scripts/Makefile.host | 12 +++++------- scripts/Makefile.lib | 26 ++++++++------------------ 3 files changed, 13 insertions(+), 33 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 7484b9d8272f..a675ce11a573 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -192,14 +192,6 @@ clean := -f $(srctree)/scripts/Makefile.clean obj # $(Q)$(MAKE) $(hdr-inst)=dir hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj -# Prefix -I with $(srctree) if it is not an absolute path. -# skip if -I has no parameter -addtree = $(if $(patsubst -I%,%,$(1)), \ -$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) - -# Find all -I options and call addtree -flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) - # echo command. # Short version is used, if $(quiet) equals `quiet_', otherwise full one. echo-cmd = $(if $($(quiet)cmd_$(1)),\ diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 73b804197fca..b6a54bdf0965 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -67,18 +67,16 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ $(HOSTCXXFLAGS_$(basetarget).o) -__hostc_flags = $(_hostc_flags) -__hostcxx_flags = $(_hostcxx_flags) - +# $(objtree)/$(obj) for including generated headers from checkin source files ifeq ($(KBUILD_EXTMOD),) ifneq ($(srctree),.) -__hostc_flags = -I$(obj) $(call flags,_hostc_flags) -__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) +_hostc_flags += -I $(objtree)/$(obj) +_hostcxx_flags += -I $(objtree)/$(obj) endif endif -hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) -hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) +hostc_flags = -Wp,-MD,$(depfile) $(_hostc_flags) +hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags) ##### # Compile programs on the host diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 41e98fa66b91..1b412d4394ae 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -137,36 +137,26 @@ _c_flags += $(if $(patsubst n%,, \ $(CFLAGS_KCOV)) endif -__c_flags = $(_c_flags) -__a_flags = $(_a_flags) -__cpp_flags = $(_cpp_flags) - -# If building the kernel in a separate objtree expand all occurrences -# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). +# $(srctree)/$(src) for including checkin headers from generated source files +# $(objtree)/$(obj) for including generated headers from checkin source files ifeq ($(KBUILD_EXTMOD),) ifneq ($(srctree),.) - -# -I$(obj) locates generated .h files -# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files -# and locates generated .h files -# FIXME: Replace both with specific CFLAGS* statements in the makefiles -__c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \ - $(call flags,_c_flags) -__a_flags = $(call flags,_a_flags) -__cpp_flags = $(call flags,_cpp_flags) +_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) +_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) +_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) endif endif c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ -include $(srctree)/include/linux/compiler_types.h \ - $(__c_flags) $(modkern_cflags) \ + $(_c_flags) $(modkern_cflags) \ $(basename_flags) $(modname_flags) a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ - $(__a_flags) $(modkern_aflags) + $(_a_flags) $(modkern_aflags) cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ - $(__cpp_flags) + $(_cpp_flags) ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))