From patchwork Wed Dec 5 11:28:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10713903 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 2D6DA13AF for ; Wed, 5 Dec 2018 11:29:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CA5C2C2A4 for ; Wed, 5 Dec 2018 11:29:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 109262C30B; Wed, 5 Dec 2018 11:29:13 +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=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 644A02C2A4 for ; Wed, 5 Dec 2018 11:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727257AbeLEL3L (ORCPT ); Wed, 5 Dec 2018 06:29:11 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:57972 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726937AbeLEL3L (ORCPT ); Wed, 5 Dec 2018 06:29:11 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id wB5BSBlV028064; Wed, 5 Dec 2018 20:28:11 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com wB5BSBlV028064 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544009292; bh=sWyas4YPx7Kc+mWtxj9UKPr4KlAhoGwLASCZp+3wZhU=; h=From:To:Cc:Subject:Date:From; b=w9S4OUbL7uO43hdC0S5b/isieGpBRChmF2XR3C5LWA5ongMKo1Egv23tDOrWEglsA T0G7r7k1uOn0AzftSYsEJk0Gmyw7yvak7t97CLQIEIPpF3/IQBI/yTQw0Aoj/I3Jwc m0wK8qvkG+Ug6KHxoLtnFlgxolvu+Kr5nhm6Ewsynifn367SuyIz0i3U1RJrry36KV oKApaiNcv4Nc5bgItsFJLZ8yNMEcuUz2lH77Bou6W5QNu3Fg2UbtRKNtCAwvJDAlfC E6yD0rC+8ji0kyqfDYZ8scdEMgLdCcO1BshvYncuXyxlm1miohYHcM4dId3MxZIHfC t49OPVTaiTT3Q== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] kbuild: refactor Makefile.asm-generic Date: Wed, 5 Dec 2018 20:28:04 +0900 Message-Id: <1544009286-15705-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 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 - Use conventional $(MAKE) $(asm-generic)= style for directory descending - Remove unneeded FORCE since "all" is a phony target - Remove unneeded "_dummy :=" assignment - Skip $(shell mkdir ...) when headers exist in the directory - Misc cleanups Signed-off-by: Masahiro Yamada --- Makefile | 8 ++++---- scripts/Makefile.asm-generic | 37 +++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index ab38eb2..3af0379 100644 --- a/Makefile +++ b/Makefile @@ -1122,13 +1122,13 @@ prepare0: archprepare prepare: prepare0 prepare-objtool # Support for using generic headers in asm-generic +asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj + PHONY += asm-generic uapi-asm-generic asm-generic: uapi-asm-generic - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ - src=asm obj=arch/$(SRCARCH)/include/generated/asm + $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm uapi-asm-generic: - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ - src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm + $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm PHONY += prepare-objtool prepare-objtool: $(objtool_target) diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic index 32ad8e9..760323e 100644 --- a/scripts/Makefile.asm-generic +++ b/scripts/Makefile.asm-generic @@ -2,41 +2,42 @@ # include/asm-generic contains a lot of files that are used # verbatim by several architectures. # -# This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild +# This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild # and for each file listed in this file with generic-y creates -# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src)) +# a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm. PHONY := all all: -kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild --include $(kbuild-file) +src := $(subst /generated,,$(obj)) +-include $(src)/Kbuild include scripts/Kbuild.include -# Create output directory if not already present -_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) +generic-y := $(addprefix $(obj)/, $(generic-y)) +generated-y := $(addprefix $(obj)/, $(generated-y)) -# Stale wrappers when the corresponding files are removed from generic-y -# need removing. -generated-y := $(generic-y) $(generated-y) -all-files := $(patsubst %, $(obj)/%, $(generated-y)) -old-headers := $(wildcard $(obj)/*.h) -unwanted := $(filter-out $(all-files),$(old-headers)) +# Remove stale wrappers when the corresponding files are removed from generic-y +old-headers := $(wildcard $(obj)/*.h) +unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers)) quiet_cmd_wrap = WRAP $@ -cmd_wrap = echo "\#include " >$@ + cmd_wrap = echo "\#include " > $@ quiet_cmd_remove = REMOVE $(unwanted) -cmd_remove = rm -f $(unwanted) + cmd_remove = rm -f $(unwanted) -all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE - $(if $(unwanted),$(call cmd,remove),) +all: $(generic-y) + $(if $(unwanted),$(call cmd,remove)) @: $(obj)/%.h: $(call cmd,wrap) -PHONY += FORCE +# Create output directory. Skip it if at least one old header exists +# since we know the output directory already exists. +ifeq ($(old-headers),) +$(shell mkdir -p $(obj)) +endif + .PHONY: $(PHONY) -FORCE: ; From patchwork Wed Dec 5 11:28:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10713905 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 E3F5D13AF for ; Wed, 5 Dec 2018 11:29:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3B172C2A4 for ; Wed, 5 Dec 2018 11:29:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C78162C30B; Wed, 5 Dec 2018 11:29:24 +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=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 5CE222C2A4 for ; Wed, 5 Dec 2018 11:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727173AbeLEL3W (ORCPT ); Wed, 5 Dec 2018 06:29:22 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:58256 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726866AbeLEL3W (ORCPT ); Wed, 5 Dec 2018 06:29:22 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id wB5BSBlW028064; Wed, 5 Dec 2018 20:28:12 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com wB5BSBlW028064 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544009292; bh=H36yvD8LOqrJ4DjVGlwvJ7B2rd10VOZDsz4ulX8ISz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nUcDnLH0CqUfD05RzSYxzCgBpv1ctmbz+Nvtqu/kBHV441FxN5rG1c9VHyi92EmGe YtIAoHxKvFy7Jrx7YUphXGLquRTXkrsCmSWAv8KMZ0mutCzYSt5UuqVtxFMaIRJ6QU SIq57KMcQRQX+MHu646R1r5JtAE3aKqe5JHwCWd3e48XrveCukWIYqlSIl7VUju+8B g07upgCR78yaz9Q2fvr/X6UCLhlYUs+AUyHTzsXA1SLdo/KIObYY34a36I34kIGl0g DqT1h7SFcFhm9o5ss3XUTJidJ0c4mm5pjyeyqsQx3mi26pmcTP83p8zNgKFAGDCLRt 5R9VMjYqnWvHQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Masahiro Yamada , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Michal Marek Subject: [PATCH 2/3] kbuild: generate asm-generic wrappers if mandatory headers are missing Date: Wed, 5 Dec 2018 20:28:05 +0900 Message-Id: <1544009286-15705-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544009286-15705-1-git-send-email-yamada.masahiro@socionext.com> References: <1544009286-15705-1-git-send-email-yamada.masahiro@socionext.com> 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 Some time ago, Sam pointed out a certain degree of overwrap between generic-y and mandatory-y. (https://lkml.org/lkml/2017/7/10/121) I a bit tweaked the meaning of mandatory-y; now it defines the minimum set of ASM headers that all architectures must have. If arch does not have specific implementation of a mandatory header, Kbuild will let it fallback to the asm-generic one by automatically generating a wrapper. This will allow to drop lots of redundant generic-y defines. Previously, "mandatory" was used in the context of UAPI, but I guess this can be extended to kernel space ASM headers. Suggested-by: Sam Ravnborg Signed-off-by: Masahiro Yamada Acked-by: Sam Ravnborg --- Documentation/kbuild/makefiles.txt | 9 ++++++--- scripts/Makefile.asm-generic | 3 +++ scripts/Makefile.headersinst | 7 ------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 8da26c6..bf28c47 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -1296,9 +1296,12 @@ See subsequent chapter for the syntax of the Kbuild file. --- 7.4 mandatory-y - mandatory-y is essentially used by include/uapi/asm-generic/Kbuild.asm - to define the minimum set of headers that must be exported in - include/asm. + mandatory-y is essentially used by include/(uapi/)asm-generic/Kbuild.asm + to define the minimum set of ASM headers that all architectures must have. + + This works like optional generic-y. If a mandatory header is missing + in arch/$(ARCH)/include/(uapi/)/asm, Kbuild will automatically generate + a wrapper of the asm-generic one. The convention is to list one subdir per line and preferably in alphabetic order. diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic index 760323e..c7cd23d 100644 --- a/scripts/Makefile.asm-generic +++ b/scripts/Makefile.asm-generic @@ -14,6 +14,9 @@ src := $(subst /generated,,$(obj)) include scripts/Kbuild.include +# If arch does not implement mandatory headers, fallback to asm-generic ones. +generic-y += $(foreach f, $(mandatory-y), $(if $(wildcard $(srctree)/$(src)/$(f)),,$(f))) + generic-y := $(addprefix $(obj)/, $(generic-y)) generated-y := $(addprefix $(obj)/, $(generated-y)) diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index d5e1314..0d4a96d 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -57,13 +57,6 @@ check-file := $(installdir)/.check all-files := $(header-files) $(genhdr-files) output-files := $(addprefix $(installdir)/, $(all-files)) -ifneq ($(mandatory-y),) -missing := $(filter-out $(all-files),$(mandatory-y)) -ifneq ($(missing),) -$(error Some mandatory headers ($(missing)) are missing in $(obj)) -endif -endif - # Work out what needs to be removed oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) unwanted := $(filter-out $(all-files),$(oldheaders))