From patchwork Fri May 19 04:28:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 9735811 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 DD108601C2 for ; Fri, 19 May 2017 04:28:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5B082866A for ; Fri, 19 May 2017 04:28:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA549288A9; Fri, 19 May 2017 04:28:55 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 569C62866A for ; Fri, 19 May 2017 04:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755667AbdESE2f (ORCPT ); Fri, 19 May 2017 00:28:35 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:38336 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755589AbdESE2b (ORCPT ); Fri, 19 May 2017 00:28:31 -0400 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 v4J4SJ9n025971; Fri, 19 May 2017 13:28:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v4J4SJ9n025971 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1495168099; bh=Cwql8eykxLpD/0A8KzulUNph3whTp62A8/bsN+gp3IM=; h=From:To:Cc:Subject:Date:From; b=PFHxhO+YmxnVaQ9vAUkdr0ukxBfe5E89bbXwENqt3ud8esZlR7e3d/Arsr4YfbzY9 Va5bPNA/FK7mILMCBXHszodRaRWX07pIIvizlZJyRKJ0jN17ysF/+xsoGe9qdBx+74 bndFd4UF7LRjBMLTyArSPA4TY49J92kCSufteBC4USyC+LQgAU7V9ooU+Ck+7ZTg6U xeQV6WBEtDUzrbxqKB7dayBh1NXcUXpISZtPF5+85GLrbwLVvgLl1jXuI7mo/iYeiz 9s/prY8mqSXWRtbOUmh2lOfA+ElE2Cs+mGnNqJRLk1cEqQJ4D1FlhS6tPlXPHIsJ/2 EHi6g0jR+IF7Q== 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 Subject: [PATCH] kbuild: simplify silent build (-s) detection Date: Fri, 19 May 2017 13:28:16 +0900 Message-Id: <1495168096-22440-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 This allows to detect -s 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 could be prefixed with '-'. 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 end with '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 We can take care of them, by filtering out long options (--%), then matching -s% s% %s patterns. Signed-off-by: Masahiro Yamada --- Makefile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Makefile b/Makefile index b1ee4a4..d8b5c42 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 ($(filter -s% s% %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