From patchwork Fri May 19 11:42:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 100186 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp269447qge; Fri, 19 May 2017 04:43:25 -0700 (PDT) X-Received: by 10.84.236.4 with SMTP id q4mr5027600plk.10.1495194205340; Fri, 19 May 2017 04:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495194205; cv=none; d=google.com; s=arc-20160816; b=sQ6++AH8ZjnXKmbQgH/3NnPoF443kJk5lw5wJDly93LcOvIGbEZA9IrPhLdlbxYKu+ UI9Pr9AvsDoqw9Lyrys8oKysmBuXNrY3R27LtOp9M48DiIen4j5/9mNobiHWeoE4USCy kIzHk520l0fDjVh9i0U9Y3tbL+30pAGq0LGZegrm6zbcLnvAskBYE3gUEZOAxQePg7of RvZ8Q7sFiJGMGgwk/0cainG1cbzv0+WB/YAkLHcjgY3HSfaObI4ve7EuSc35eYYdQqWJ KI+TMQraiAiUh3jsFdskgI1ZaHAVfZCpgEZhD7wNSAkET29dmdWeBYIGzgN1u4t5NMZl h5AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=MtA9M8Ub+bR2xLDzVBWPOj8P7PFCxv3lx0iF5ENn2+E=; b=iDLS0MpVAw/ufPWb6PIJy8gCqe4iSXqIAbiBEVduC09NLcXsHMJbGD3e7xpjdFf7C0 3ZLgS+Lk2ZvzIBh3F/8cAxjiJ6BiOlN5vRtWF6GFAi+WanA9jSjJfcMdNIV69orwZrUC YOkR8nhXDa0RzFJGxLXuc5t2Ht6nZGEwxbffMJrrE7JswtDB22dSFyaOPj2K4j/jFma+ rAIW6M4gzwp3hK/vK5grY6WD3VNx0XVh4flEjOakrUktbLYcRl7uarVM9KOYYaImXFQY bQ/EPCpTi7IaGJzO9FEbjGMYRsm/iKqyb7jHbeAzgKIRa8/Y41mV+9ZpGHQfvgAxWGFX YOgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u27si8170982pfj.61.2017.05.19.04.43.25; Fri, 19 May 2017 04:43:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754981AbdESLnE (ORCPT + 25 others); Fri, 19 May 2017 07:43:04 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:52268 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751003AbdESLm6 (ORCPT ); Fri, 19 May 2017 07:42:58 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id v4JBgYBK031636; Fri, 19 May 2017 20:42:35 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v4JBgYBK031636 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1495194156; bh=MtA9M8Ub+bR2xLDzVBWPOj8P7PFCxv3lx0iF5ENn2+E=; h=From:To:Cc:Subject:Date:From; b=KR8U/PHF3/52LIZaNoxi0HlwezJc+n6dtkKjW9iNKe+n+59WfDnjhVV0Gx9tjLKO+ HZlA7NEP3/1WNFEu7GgvA8cfD/3OAEIrTyh9SepMD2N2oAt/+Faud6Y2sAMTEs6vha gxn0YV5D8cdP8LDpMROOyMvSxBKKh++4Dkz9joY7vTBggBI9TbGGghLnM74/124e7N 2vtFvbGOhX/SzDIpxBTrecMr5dw24le17gLbLYNVqQaJTVw21BXDO20UuThKWQVdGf plkFzDnTE3BWqxlhSras7jViAyBP2QRTtrjf+titEJTH/1hCZ1jYo/mCGm4XrwboPC Uxt6wChZ9m+0Q== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org, Wang Nan , Josh Poimboeuf , Arnaldo Carvalho de Melo , Jiri Olsa Subject: [PATCH v3] kbuild: simplify silent build (-s) detection Date: Fri, 19 May 2017 20:42:30 +0900 Message-Id: <1495194150-14016-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows to detect -s (--silent) option without checking GNU Make version. As commit e36aaea28972 ("kbuild: Fix silent builds with make-4") pointed out, GNU Make 4.x changed the way/order it presents the command line options into MAKEFLAGS. In Make 3.8x, 's' is always be the first in a group of short options. The group may be prefixed with '-' in some cases. In Make 4.x, 's' is always the last in a group of short options. As commit e6ac89fabd03 ("kbuild: Correctly deal with make options which contain an 's'") addressed, we also need to deal with long options that contain 's', like --warn-undefined-variables. Test cases: [1] command line input: make --silent -> MAKEFLAGS for Make 3.8x: s -> MAKEFLAGS for Make 4.x : s [2] command line input: make -srR -> MAKEFLAGS for Make 3.8x: sRr -> MAKEFLAGS for Make 4.x : rRs [3] command line input: make -s -rR --warn-undefined-variables -> MAKEFLAGS for Make 3.8x: --warn-undefined-variables -sRr -> MAKEFLAGS for Make 4.x : rRs --warn-undefined-variables The idea to cater to all the cases more easily is to filter out long options (--%), then search 's' with $(findstring ...). This way will be more future-proof even if Make 5.x decides to put 's' in the middle of the group. Signed-off-by: Masahiro Yamada --- Changes in v3: - Even simpler way that works in any order. Changes in v2: - Fix makefiles under tools as well Makefile | 9 +-------- tools/build/Makefile.build | 8 +------- tools/scripts/Makefile.include | 8 +------- 3 files changed, 3 insertions(+), 22 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index b1ee4a49efa2..e4da5a0ccf97 100644 --- a/Makefile +++ b/Makefile @@ -84,17 +84,10 @@ endif # If the user is running make -s (silent mode), suppress echoing of # commands -ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 -ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) +ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) quiet=silent_ tools_silent=s endif -else # make-3.8x -ifneq ($(filter s% -s%,$(MAKEFLAGS)),) - quiet=silent_ - tools_silent=-s -endif -endif export quiet Q KBUILD_VERBOSE diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build index e279a71c650d..c46b20e4ad87 100644 --- a/tools/build/Makefile.build +++ b/tools/build/Makefile.build @@ -19,15 +19,9 @@ else Q=@ endif -ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 -ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) +ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) quiet=silent_ endif -else # make-3.8x -ifneq ($(filter s% -s%,$(MAKEFLAGS)),) - quiet=silent_ -endif -endif build-dir := $(srctree)/tools/build diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index fc74db62fef4..ccad8ce925e4 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -58,15 +58,9 @@ else NO_SUBDIR = : endif -ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 -ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) +ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) silent=1 endif -else # make-3.8x -ifneq ($(filter s% -s%,$(MAKEFLAGS)),) - silent=1 -endif -endif # # Define a callable command for descending to a new directory