From patchwork Thu Feb 14 03:05:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10811653 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 61A20746 for ; Thu, 14 Feb 2019 03:06:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F8F62C3E8 for ; Thu, 14 Feb 2019 03:06:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43E7B2D813; Thu, 14 Feb 2019 03:06:07 +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 CAF392C3E8 for ; Thu, 14 Feb 2019 03:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394333AbfBNDGG (ORCPT ); Wed, 13 Feb 2019 22:06:06 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64387 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726271AbfBNDGG (ORCPT ); Wed, 13 Feb 2019 22:06:06 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1E35Pg2020814; Thu, 14 Feb 2019 12:05:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1E35Pg2020814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550113525; bh=yO8RC+IzX+7q6ObGuUgOsgj+kpMFLH2G7hMx94CJuxg=; h=From:To:Cc:Subject:Date:From; b=xa9xx55x3a46jz1CDBYlsEEOL296PAe7Tgo9BkkXj3NBFmssf4NG8Pentf8AbN9u4 h1Ozqfic48t7KM6Ws3JxYECl69MbPv1M6bOhoJhCBMUFIADfZRQe18F6FoEcTBar+8 6jZ/A7ZsKVHwZeTd07VyBFEKRsinWNwH0NszGYxDQTpQQ4vaNWtwvwAG9l5QZbpjP0 6KBUu56t4sa5xPacF5h7NMvHrVDNqnca/uAge8lEVCxlHuD6VBeqoYoO0+N+/Vt5YC NuTl95roarog8CttNiwm6d8vB60wLbk+UXGuCZCg31j9CJg3XOzgP5up7BZOoRuer7 hW4tYZzpZuC/g== 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/8] kbuild: pkg: use -f $(srctree)/Makefile to recurse to top Makefile Date: Thu, 14 Feb 2019 12:05:14 +0900 Message-Id: <1550113521-23577-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 '$(MAKE) KBUILD_SRC=' changes the working directory back and forth between objtree and srctree. It is better to recurse to the top-level Makefile directly. Signed-off-by: Masahiro Yamada --- scripts/package/Makefile | 4 ++-- scripts/package/builddeb | 10 +++++----- scripts/package/buildtar | 2 +- scripts/package/mkdebian | 6 ++++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 453fece..aa39c2b 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -59,7 +59,7 @@ rpm-pkg: FORCE # binrpm-pkg # --------------------------------------------------------------------------- binrpm-pkg: FORCE - $(MAKE) KBUILD_SRC= + $(MAKE) -f $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ $(UTS_MACHINE) -bb $(objtree)/binkernel.spec @@ -102,7 +102,7 @@ clean-dirs += $(objtree)/snap/ # tarball targets # --------------------------------------------------------------------------- tar%pkg: FORCE - $(MAKE) KBUILD_SRC= + $(MAKE) -f $(srctree)/Makefile $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ clean-dirs += $(objtree)/tar-install/ diff --git a/scripts/package/builddeb b/scripts/package/builddeb index f43a274..8ac25d1 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -86,12 +86,12 @@ cp "$($MAKE -s -f $srctree/Makefile image_name)" "$tmpdir/$installed_image_path" if grep -q "^CONFIG_OF_EARLY_FLATTREE=y" $KCONFIG_CONFIG ; then # Only some architectures with OF support have this target if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then - $MAKE KBUILD_SRC= INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install + $MAKE -f $srctree/Makefile INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install fi fi if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then - INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install + INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_install rm -f "$tmpdir/lib/modules/$version/build" rm -f "$tmpdir/lib/modules/$version/source" if [ "$ARCH" = "um" ] ; then @@ -113,14 +113,14 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then # resign stripped modules MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)" if [ -n "$MODULE_SIG_ALL" ]; then - INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_sign + INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_sign fi fi fi if [ "$ARCH" != "um" ]; then - $MAKE headers_check KBUILD_SRC= - $MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr" + $MAKE -f $srctree/Makefile headers_check + $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr" fi # Install the maintainer scripts diff --git a/scripts/package/buildtar b/scripts/package/buildtar index d624a07..cfd2a4a 100755 --- a/scripts/package/buildtar +++ b/scripts/package/buildtar @@ -57,7 +57,7 @@ dirs=boot # Try to install modules # if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then - make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install + make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install dirs="$dirs lib" fi diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index edcad61..f030961 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -205,13 +205,15 @@ EOF cat < debian/rules #!$(command -v $MAKE) -f +srctree ?= . + build: \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ - KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= + KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile binary-arch: \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ - KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= intdeb-pkg + KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg clean: rm -rf debian/*tmp debian/files From patchwork Thu Feb 14 03:05:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10811665 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 48814746 for ; Thu, 14 Feb 2019 03:06:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3575E2C3E8 for ; Thu, 14 Feb 2019 03:06:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 298D62D813; Thu, 14 Feb 2019 03:06:50 +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 CB25B2C3E8 for ; Thu, 14 Feb 2019 03:06:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394280AbfBNDGF (ORCPT ); Wed, 13 Feb 2019 22:06:05 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64388 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388324AbfBNDGF (ORCPT ); Wed, 13 Feb 2019 22:06:05 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1E35Pg3020814; Thu, 14 Feb 2019 12:05:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1E35Pg3020814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550113526; bh=z7QbcsEL2gebJ2pwu1NQAHednh5Ku/Vt6/MmBfIu8UY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yCK6NlQq6emtPRc5IEqJokU4opyLttoMvwtjnKyj1aW62BKX7SUzwb0Z5eHz2syxN zJcnKWII+vT+cGsJwxmaPRr8FQMjcmj+k3RBvAZbFqcuzECTumdAVH8WIooepZyOst M2nRsOUWRKjU5kjCUqfGIWAUyo0duBrmXFr4cLIakX4a3x0XmKBRCtNoS3ihhJB2va RegSQBaiSUQOe2KSK6+HsA99W7BI5e2l0DQ3cDyCT6/pyN1ZVZNlZ9xJjcQYkb1SAW wkFYrdyAd/I/N3KN+vcRyFda95z8UgIfpMXde2cvSLHxxopfSxqEb1iHFbBr7fm25m pdbmM1KAcgAsA== 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 2/8] kbuild: generate modules.order only when CONFIG_MODULES=y Date: Thu, 14 Feb 2019 12:05:15 +0900 Message-Id: <1550113521-23577-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550113521-23577-1-git-send-email-yamada.masahiro@socionext.com> References: <1550113521-23577-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 Do not generate pointless modules.order when the module support is disabled. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 99be01c..89debbe 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -63,7 +63,9 @@ ifneq ($(strip $(real-obj-y) $(need-builtin)),) builtin-target := $(obj)/built-in.a endif +ifdef CONFIG_MODULES modorder-target := $(obj)/modules.order +endif # We keep a list of all modules in $(MODVERDIR) From patchwork Thu Feb 14 03:05: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: 10811663 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 63407139A for ; Thu, 14 Feb 2019 03:06:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 513D32D811 for ; Thu, 14 Feb 2019 03:06:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45A9E2D886; Thu, 14 Feb 2019 03:06:42 +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 EB8AD2D813 for ; Thu, 14 Feb 2019 03:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405301AbfBNDGl (ORCPT ); Wed, 13 Feb 2019 22:06:41 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64383 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393468AbfBNDGF (ORCPT ); Wed, 13 Feb 2019 22:06:05 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1E35Pg4020814; Thu, 14 Feb 2019 12:05:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1E35Pg4020814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550113527; bh=qmqFYzrO309vIKYtqQ9mMRdEh6RcNYvW13KnAIs8pHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gogeCQ+aeK2rK/zRoyN4DEr2oaQQkFWJzU1sHYgz8JNh1OEpdRF17PLUQ0EROdROE 68/9EMAPqH+gcEcLAcLrvGo8YDGs2hEu8dnY7VNZVXSolDGEnMH+DGkSib03Dsw8KA LixGtZOySh/1Ya29F+xPK70pPsiPhR0KJnyVJjVN101xAvKRyfbb34mC/KXuTL5tXQ EfSW2LsF2T1V1c3kOst+Bgz8+dTo5iARpIx1ZWHBsiKVrWlgOji1TLmJ33Ctd3P2Pp XRNBmy0rbkBMcIu9GXuIMaC5wAeP88Qh7OeFNOOvLtI2+Nl79/5laC89j/Ir61c3LX Fn3zd9l5sxe0g== 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 3/8] kbuild: set KBUILD_MODULES=1 all the time for single target %/ Date: Thu, 14 Feb 2019 12:05:16 +0900 Message-Id: <1550113521-23577-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550113521-23577-1-git-send-email-yamada.masahiro@socionext.com> References: <1550113521-23577-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 It is fine to set KBUILD_MODULES=1 when CONFIG_MODULES is disabled. It is actually how "make allnoconfig all" works. On the other hand, KBUILD_MODULES=1 is unneeded for the %.ko pattern. It is just a matter of whether modules.order is generated or not. Signed-off-by: Masahiro Yamada --- Makefile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3cf253d..fe62de3 100644 --- a/Makefile +++ b/Makefile @@ -1710,16 +1710,13 @@ endif # Modules /: prepare FORCE - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ - $(build)=$(build-dir) + $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) # Make sure the latest headers are built for Documentation Documentation/ samples/: headers_install %/: prepare FORCE - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ - $(build)=$(build-dir) + $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) %.ko: prepare FORCE - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ - $(build)=$(build-dir) $(@:.ko=.o) + $(Q)$(MAKE) $(build)=$(build-dir) $(@:.ko=.o) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost # FIXME Should go into a make.lib or something From patchwork Thu Feb 14 03:05: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: 10811659 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 B89DB139A for ; Thu, 14 Feb 2019 03:06:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A83792D846 for ; Thu, 14 Feb 2019 03:06:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CADB2D886; Thu, 14 Feb 2019 03:06:38 +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 481B12D811 for ; Thu, 14 Feb 2019 03:06:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404737AbfBNDGW (ORCPT ); Wed, 13 Feb 2019 22:06:22 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64821 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393851AbfBNDGS (ORCPT ); Wed, 13 Feb 2019 22:06:18 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1E35Pg5020814; Thu, 14 Feb 2019 12:05:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1E35Pg5020814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550113527; bh=12ymzprJkRQOxFpe2dJ/Cbc9UDJYC/XmnLNco9k9Spw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tG9dxpNyBLAjEl8FblEfSiTQNpAD2n7eZvUoSTp7oHhj+PdGsZOOShr45k7YF+n2t l8YJbVG5Cu91/z7QDjULzMd4nEFu2/Y5n36u625G5FuVsZXb8smX4oK9q80IkREExn B/6408aN990ydI6bYIAuRIR3JsNBXej8nkR894OlZ2MFqpI3iiQkBjiNSg++Y6/6vJ tkkUlTEgmcKKQnSDQHbZLp6U8LIKc6ZG956gfwC6D7xu7BCvQlYq4tjMYYuMz/75YJ QIq5qy6xrZaZKnhdGYbzUI2LDCoHnTOmhUnK/JKHIPleHawAX+KUTDuraB8eBSPtxJ E3eF7DRjFVBvQ== 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 4/8] kbuild: turn '/' into an alias of './' Date: Thu, 14 Feb 2019 12:05:17 +0900 Message-Id: <1550113521-23577-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550113521-23577-1-git-send-email-yamada.masahiro@socionext.com> References: <1550113521-23577-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 Commit 06300b21f4c7 ("kbuild: support building individual files for external modules") introduced the '/' target. It works only for external modules to build all .o files, but skip the modpost stage. However, 'make /' looks a bit weird to me. 'make ./' is more sensible if you want to build all objects under the current directory, and it works as expected. Let's change '/' into a phony target that is an alias of './', but I may feel like deprecating it in the future. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/modules.txt | 2 +- Makefile | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt index 3fb39e0..80295c6 100644 --- a/Documentation/kbuild/modules.txt +++ b/Documentation/kbuild/modules.txt @@ -140,7 +140,7 @@ executed to make module versioning work. make -C $KDIR M=$PWD bar.lst make -C $KDIR M=$PWD baz.o make -C $KDIR M=$PWD foo.ko - make -C $KDIR M=$PWD / + make -C $KDIR M=$PWD ./ === 3. Creating a Kbuild File for an External Module diff --git a/Makefile b/Makefile index fe62de3..3956e93 100644 --- a/Makefile +++ b/Makefile @@ -1709,8 +1709,9 @@ endif $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) # Modules -/: prepare FORCE - $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) +PHONY += / +/: ./ + # Make sure the latest headers are built for Documentation Documentation/ samples/: headers_install %/: prepare FORCE From patchwork Thu Feb 14 03:05:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10811651 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 5B06D746 for ; Thu, 14 Feb 2019 03:06:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 442AA2C3E8 for ; Thu, 14 Feb 2019 03:06:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37F2B2D813; Thu, 14 Feb 2019 03:06:06 +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 A1D692C3E8 for ; Thu, 14 Feb 2019 03:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394269AbfBNDGF (ORCPT ); Wed, 13 Feb 2019 22:06:05 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64385 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733190AbfBNDGF (ORCPT ); Wed, 13 Feb 2019 22:06:05 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1E35Pg6020814; Thu, 14 Feb 2019 12:05:28 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1E35Pg6020814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550113528; bh=9+FohcoLHm8KYNdVvN4X6+iAEs7CLHpN0SKeH6bEVW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1ty/8NMW+CQYyU1AAuHhVNAXdSzFBQqFW09+HRt81NogjtBW0P6b+UdsowdN+nYpZ 0G2z93wrqw/G2JCM802DB2vENVcXsfyKSKMntbRx0ORPadmAmI+G/pOibhITpKO+9a Ll4ONtRawU1Zp6U+EeQoCUsxq1a1RedYF/dGwA35ZwHeYOOkQpHPcsK/6txvP5PSc5 KMjBV0sg5nvES7Rzro+dwALW472L2H54pSUqMuNO56N1dWBJUVknPZnd6CAtQE+JJB vPMDxTPFAZZ5rfmBD1pdx9YIJH5jCX8SlJqZOkD4P147mWs39Sy4/NyqA+WlJrC7Fp PKhG36EGwz20g== 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 5/8] kbuild: move tools_silent to a more relevant place Date: Thu, 14 Feb 2019 12:05:18 +0900 Message-Id: <1550113521-23577-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550113521-23577-1-git-send-email-yamada.masahiro@socionext.com> References: <1550113521-23577-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 This would disturb the change the sub-make part. Move it near the tools/ target. Signed-off-by: Masahiro Yamada --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3956e93..0180b23 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,6 @@ endif ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) quiet=silent_ - tools_silent=s endif export quiet Q KBUILD_VERBOSE @@ -1664,6 +1663,11 @@ image_name: @echo $(KBUILD_IMAGE) # Clear a bunch of variables before executing the submake + +ifeq ($(quiet),silent_) +tools_silent=s +endif + tools/: FORCE $(Q)mkdir -p $(objtree)/tools $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ From patchwork Thu Feb 14 03:05:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10811657 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 8E0F8139A for ; Thu, 14 Feb 2019 03:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BCD02C3E8 for ; Thu, 14 Feb 2019 03:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F7822D813; Thu, 14 Feb 2019 03:06:23 +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 DF9882C3E8 for ; Thu, 14 Feb 2019 03:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403975AbfBNDGS (ORCPT ); Wed, 13 Feb 2019 22:06:18 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64382 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394145AbfBNDGG (ORCPT ); Wed, 13 Feb 2019 22:06:06 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1E35Pg7020814; Thu, 14 Feb 2019 12:05:28 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1E35Pg7020814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550113529; bh=UInuA6sjxvO1VVgZ8XgryVYJnyZUkO/SzulavMh+Za8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DD8gCOZ6YNKXjbMHKfAvzQAluld269OrZC1Z5CbLmpaYr68I6ycnzA2MYNPcmvx4c VnhWyuscYXmVr+LFbUWbBTd/pSe3RNUtVouLxokARc9aGEuNKiPb8Y+Vu4qPKtaLEn BNWrIbI/tQFwRe7m1n348IQcq/nzOMmIKucDsbJO6IfpRQVDuRh4NRyGCJEyviADWY JIr0DwsQR/JjpGDrYh8hIpdNr2iWECuIJyi2k5qvfwzZEoRIpwNfGitEU/d29WWC/a /CZxyc0ICvZiYNPrRMzSqBN7jlu9feDwCzVKYCr6ov+ZBpJG0I4PkNmzXW5ZbQFnvC xWN6j01qMFMDw== 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 6/8] kbuild: make -r/-R effective in top Makefile for old Make versions Date: Thu, 14 Feb 2019 12:05:19 +0900 Message-Id: <1550113521-23577-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550113521-23577-1-git-send-email-yamada.masahiro@socionext.com> References: <1550113521-23577-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 Adding -rR to MAKEFLAGS is important because we do not want to be bothered by built-in implicit rules or variables. One problem that used to exist in older GNU Make versions is MAKEFLAGS += -rR ... does not become effective in the current Makefile. When you are building with O= option, it becomes effective in the top Makefile since it recurses via 'sub-make' target. Otherwise, the top Makefile tries implicit rules. That is why we explicitly add empty rules for Makefiles, but we often miss to do that. In fact, adding -d option to older GNU Make versions shows it is trying a bunch of implicit pattern rules. Considering target file `scripts/Makefile.kcov'. Looking for an implicit rule for `scripts/Makefile.kcov'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.o'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.c'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.cc'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.C'. ... This issue was fixed by GNU Make commit 58dae243526b ("[Savannah #20501] Handle adding -r/-R to MAKEFLAGS in the makefile"). So, it is no longer a problem if you use GNU Make 4.0 or later. However, older versions are still widely used. So, I decided to patch the kernel Makefile to invoke sub-make regardless of O= option. This will allow further cleanups. Signed-off-by: Masahiro Yamada --- Makefile | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 0180b23..25d7d46 100644 --- a/Makefile +++ b/Makefile @@ -15,19 +15,6 @@ NAME = Shy Crocodile PHONY := _all _all: -# Do not use make's built-in rules and variables -# (this increases performance and avoids hard-to-debug behaviour) -MAKEFLAGS += -rR - -# Avoid funny character set dependencies -unexport LC_ALL -LC_COLLATE=C -LC_NUMERIC=C -export LC_COLLATE LC_NUMERIC - -# Avoid interference with shell env settings -unexport GREP_OPTIONS - # We are using a recursive build, so we need to do a little thinking # to get the ordering right. # @@ -44,6 +31,21 @@ unexport GREP_OPTIONS # descending is started. They are now explicitly listed as the # prepare rule. +ifndef KBUILD_SUBMAKE + +# Do not use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour) +MAKEFLAGS += -rR + +# Avoid funny character set dependencies +unexport LC_ALL +LC_COLLATE=C +LC_NUMERIC=C +export LC_COLLATE LC_NUMERIC + +# Avoid interference with shell env settings +unexport GREP_OPTIONS + # Beautify output # --------------------------------------------------------------------------- # @@ -111,7 +113,6 @@ export quiet Q KBUILD_VERBOSE # KBUILD_SRC is not intended to be used by the regular user (for now), # it is set on invocation of make with KBUILD_OUTPUT or O= specified. -ifeq ($(KBUILD_SRC),) # OK, Make called in directory where kernel src resides # Do we want to locate output files in a separate directory? @@ -141,6 +142,13 @@ $(if $(KBUILD_OUTPUT),, \ # 'sub-make' below. MAKEFLAGS += --include-dir=$(CURDIR) +else + +# Do not print "Entering directory ..." at all for in-tree build. +MAKEFLAGS += --no-print-directory + +endif # ifneq ($(KBUILD_OUTPUT),) + PHONY += $(MAKECMDGOALS) sub-make $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make @@ -148,16 +156,12 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make # Invoke a second make in the output directory, passing relevant variables sub-make: - $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ + $(Q)$(MAKE) KBUILD_SUBMAKE=1 \ + $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) -# Leave processing to above invocation of make -skip-makefile := 1 -endif # ifneq ($(KBUILD_OUTPUT),) -endif # ifeq ($(KBUILD_SRC),) - +else # KBUILD_SUBMAKE # We process the rest of the Makefile if this is the final invocation of make -ifeq ($(skip-makefile),) # Do not print "Entering directory ...", # but we want to display it when entering to the output directory @@ -1752,7 +1756,7 @@ $(cmd_files): ; # Do not try to update included dependency files endif # ifeq ($(config-targets),1) endif # ifeq ($(mixed-targets),1) -endif # skip-makefile +endif # ifndef KBUILD_SUBMAKE PHONY += FORCE FORCE: From patchwork Thu Feb 14 03:05:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10811655 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 06CCD746 for ; Thu, 14 Feb 2019 03:06:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E73E92C3E8 for ; Thu, 14 Feb 2019 03:06:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB8F32D846; Thu, 14 Feb 2019 03:06:17 +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 0032E2C3E8 for ; Thu, 14 Feb 2019 03:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394338AbfBNDGG (ORCPT ); Wed, 13 Feb 2019 22:06:06 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64384 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394268AbfBNDGG (ORCPT ); Wed, 13 Feb 2019 22:06:06 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1E35Pg8020814; Thu, 14 Feb 2019 12:05:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1E35Pg8020814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550113529; bh=9rCnJrZhrNGJF/7A8mlLM75Z8BqThK/fBdPkgtUyRPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YHX966QjGfaHOVTquVmuzHmIIdhYCCM6T/lIo243Ly6iBmhF/LJ76ItK3CsAh+GZh A9ionEc55vwALlYZXihilnIQi/q6yBLM4lxAJfWHTQambXxNMch63348VWxCAHj4pJ LC/kCJ4MNa6WgfVj6ROeXAsL8Y9BgGHP6SJ9nCKY7Epspf9kV1jYKN8fUp3zYpv+fS NA5kuV/JTaHvOJd5wFTR522ny/WsOIGwi/ab7QXpJpo8HHtrc0HCnwkrACzdkwa0Zo w8PP+6lp50lVKeUjl5FRxIRhbVM+7cDVxWgRXsCHp8kb5eB1eCdwgHqD9fvajxQQzR sm1dYtn9UQE+A== 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 7/8] kbuild: remove empty rules for makefiles Date: Thu, 14 Feb 2019 12:05:20 +0900 Message-Id: <1550113521-23577-7-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550113521-23577-1-git-send-email-yamada.masahiro@socionext.com> References: <1550113521-23577-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 The previous commit made 'MAKEFLAGS += -rR' effective in the top Makefile regardless of O= option, GNU Make versions. The top Makefile does not need to cancel implicit rules for makefiles. There is still one place where an empty rule is useful. Since -rR is effective only after sub-make, GNU Make would try implicit rules to update the top Makefile. Although it is not a big overhead, cancel it just in case. Signed-off-by: Masahiro Yamada --- Makefile | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 25d7d46..f7f1aa1 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,10 @@ ifndef KBUILD_SUBMAKE # (this increases performance and avoids hard-to-debug behaviour) MAKEFLAGS += -rR +# 'MAKEFLAGS += -rR' does not become immediately effective for old +# GNU Make versions. Cancel implicit rules for this Makefile. +$(lastword $(MAKEFILE_LIST)): ; + # Avoid funny character set dependencies unexport LC_ALL LC_COLLATE=C @@ -120,9 +124,6 @@ ifeq ("$(origin O)", "command line") KBUILD_OUTPUT := $(O) endif -# Cancel implicit rules on top Makefile -$(CURDIR)/Makefile Makefile: ; - ifneq ($(words $(subst :, ,$(CURDIR))), 1) $(error main directory cannot contain spaces nor colons) endif @@ -303,8 +304,6 @@ __build_one_by_one: else -# We need some generic definitions (do not try to remake the file). -scripts/Kbuild.include: ; include scripts/Kbuild.include # Read KERNELRELEASE from include/config/kernel.release (if it exists) @@ -627,9 +626,6 @@ ifeq ($(may-sync-config),1) # because some architectures define CROSS_COMPILE there. -include include/config/auto.conf.cmd -# To avoid any implicit rule to kick in, define an empty command -$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; - # The actual configuration files used during the build are stored in # include/generated/ and include/config/. Update them if .config is newer than # include/config/auto.conf (which mirrors .config). @@ -1750,9 +1746,7 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ # read saved command lines for existing targets existing-targets := $(wildcard $(sort $(targets))) -cmd_files := $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) -$(cmd_files): ; # Do not try to update included dependency files --include $(cmd_files) +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) endif # ifeq ($(config-targets),1) endif # ifeq ($(mixed-targets),1) From patchwork Thu Feb 14 03:05:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10811661 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 28E4E746 for ; Thu, 14 Feb 2019 03:06:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16FBB2D811 for ; Thu, 14 Feb 2019 03:06:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B4AE2D886; Thu, 14 Feb 2019 03:06:39 +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 9EBAB2D811 for ; Thu, 14 Feb 2019 03:06:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394268AbfBNDGS (ORCPT ); Wed, 13 Feb 2019 22:06:18 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64386 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393527AbfBNDGG (ORCPT ); Wed, 13 Feb 2019 22:06:06 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1E35Pg9020814; Thu, 14 Feb 2019 12:05:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1E35Pg9020814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550113530; bh=VnFzu1pRBkse1rgGgc43E28soFZDRai0oiY6uEajTrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o9Udx84v3yeIM0EAKBWQuWLIjCN5zZoaes7EcO/oM3OqAil+9BT3IM8dWkAQZVOez A6xzIGv4dQjpPG4qm7Apl4rCZV75ZHN4jNNOKcRZQospeyxDXuUdvQY6TSUHRrE2dA 5u6iVZwUNa5TYa6H4fHf//Id/NaiOnO5b8nWLGPtY8MgsM3wymuzgI+m7J0bHvmdOX MHZpc4mwPBey7X6YpF9WEForOxFl8IdNVUqdQxckfSRMlpHNSEnsbUCT1jSFij8mZz mBhkswIpVFnP+89h3pTKIfaVgGg74pnXYLHIurShSmFk3LR57wpUvJZmfKug5jhVZl h06Vnc05KqBkg== 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 8/8] kbuild: simplify single targets Date: Thu, 14 Feb 2019 12:05:21 +0900 Message-Id: <1550113521-23577-8-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550113521-23577-1-git-send-email-yamada.masahiro@socionext.com> References: <1550113521-23577-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 The dependency will be checked anyway after Kbuild descends into a sub-directory. Skip object/source dependency checks in top Makefile. VPATH can be simpler since the top Makefile no longer checks the preprense of the source file, which is located in in the external module directory. [Pros] - Code is cleaner - It can compile an object from a generated source file For example, $ make crypto/rsapubkey.asn1.o ... ASN.1 crypto/rsapubkey.asn1.c CC crypto/rsapubkey.asn1.o [Cons] - The top Makefile does not let it fail immediately when a user tries to build a wrong object. Signed-off-by: Masahiro Yamada --- Makefile | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index f7f1aa1..8bf0ed6 100644 --- a/Makefile +++ b/Makefile @@ -219,7 +219,7 @@ objtree := . src := $(srctree) obj := $(objtree) -VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) +VPATH := $(srctree) export srctree objtree VPATH @@ -1686,31 +1686,14 @@ tools/%: FORCE # target-dir => where to store outputfile # build-dir => directory in kernel source tree to use -ifeq ($(KBUILD_EXTMOD),) - build-dir = $(patsubst %/,%,$(dir $@)) - target-dir = $(dir $@) -else - zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) - build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) - target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) -endif - -%.s: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.i: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.o: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.lst: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.s: %.S prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.o: %.S prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.symtypes: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.ll: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@ +build-dir = $(patsubst %/,%,$(dir $(build-target))) + +%.i %.ll %.lst %.o %.s %.symtypes: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) + +%.ko: %.o + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost # Modules PHONY += / @@ -1720,9 +1703,6 @@ PHONY += / Documentation/ samples/: headers_install %/: prepare FORCE $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) -%.ko: prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(@:.ko=.o) - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost # FIXME Should go into a make.lib or something # ===========================================================================