Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp709325iob; Thu, 12 May 2022 03:02:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLx6YAieGJt7y0be3VWHcrepFg9m7xZK027BNsydAcN6/dv3DKXlrVg5KOyp7Apbzs97ZN X-Received: by 2002:a9d:74d8:0:b0:606:42dc:5ce3 with SMTP id a24-20020a9d74d8000000b0060642dc5ce3mr11299501otl.303.1652349748923; Thu, 12 May 2022 03:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652349748; cv=none; d=google.com; s=arc-20160816; b=AlTyP+wtA2LedW7DkIOUjgmpe+ejJdtrcZRl0Z0XOA2zRyu6kGgNSGpL16VoiTiuVu omHxYfii4Apf6MLcLRARzRwJwTnboMn25ytsTdwmJpxSCHX2d8kMldFxCJF3Jo9iq6wU LpSAMXrBAwx3Amdd+0bgIa43GovjEO6dbFRTBEEIzOQNb/vl19NfLVm/VIbNky7Hhn+g DAkBPgS72Dex9QRLLuovgTntdy183Y3sW/qxCK6LiFk/UrLGZwBBpem3AyAhZAx10JE1 qLZY1fENOWGxuX5eL4UeGWcgZyEDVoolUsEp/5Ua5TXclFMmDtCEeXW+dM2+wHnNHCUa kqEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=PfsqhsCBk5DMJKQrgxjPrt4cR290nXSjW4ewrtsP89A=; b=ZYzg73rweLeKp+W+WPh/qjKA/eCKMei6yTid5wTdQj/S3b7xAAx6SXII80BQBodzY2 1HI7IoNsJb5aONvysEWFq6MM/xsTCawF/6ivBpAKCDCjI507ODuT+Tnd2nRyGYXjzYc2 53ndl59kVLwFsbfdFHQCxcn2XgqqyBGyMmstU0YjD6rRQmrSg77pFYI0UH1FqRjQlivA UdH0U7wiKK1E6UN8V6LXyU12M93sHMrbt+fMBv/P8XP7DLipBkvUz7JPtLmDsBZs94kz f9/5rZzwMONAQROcrQNahxg2f8w5zmpqAMtN2lBvFYly9G4lCwUlTrAN+XqCx8npHA4f migw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KGPJJDya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l20-20020a056871069400b000edd590f638si4116762oao.194.2022.05.12.03.02.16; Thu, 12 May 2022 03:02:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KGPJJDya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345066AbiEKQt7 (ORCPT + 99 others); Wed, 11 May 2022 12:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235800AbiEKQtq (ORCPT ); Wed, 11 May 2022 12:49:46 -0400 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A36F95DDB; Wed, 11 May 2022 09:49:41 -0700 (PDT) Received: from grover.jp (133-32-177-133.west.xps.vectant.ne.jp [133.32.177.133]) (authenticated) by conuserg-08.nifty.com with ESMTP id 24BGlWc6031975; Thu, 12 May 2022 01:47:43 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 24BGlWc6031975 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1652287664; bh=PfsqhsCBk5DMJKQrgxjPrt4cR290nXSjW4ewrtsP89A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KGPJJDyaNocbo6ncNt90Q/OY7ihHW9tXr3BUWHXD4rjMD3KkrdCuYQZTTVomseqSK +XTfWkakm1H4RwK0EbAITtDKkiiAWjT8O/6BZqBXHN/rVs4Q1szUu/FPRyrbwrrzV0 eh/ATsHp2W7mHqysKrYp5SE61AiXtfsPnEra23WGRjfzpMzlwUP6MYeY1NoYNI4utk pZV5zT4e++CpCbsBFhvg07OMQ1FdS0zgT72+Ne+un4xKMRHYZBz2fyEsurC8zCVL1j 4THxnWfD6Pa3WElSRT+CekpOBnMwVZMMCbvzWIiwwQJLolqwlbnXUralfrpajp7JYT YrzXYa2EGODug== X-Nifty-SrcIP: [133.32.177.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Peter Zijlstra , linux-modules@vger.kernel.org, llvm@lists.linux.dev, Ard Biesheuvel , Sami Tolvanen , Masahiro Yamada , Kees Cook Subject: [PATCH v5 11/12] kbuild: add cmd_and_savecmd macro Date: Thu, 12 May 2022 01:45:13 +0900 Message-Id: <20220511164514.2741934-12-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220511164514.2741934-1-masahiroy@kernel.org> References: <20220511164514.2741934-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Separate out the command execution part of if_changed, as we did for if_changed_dep. This allows us to reuse it in if_changed_rule. define rule_foo $(call cmd_and_savecmd,foo) $(call cmd,bar) endef Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook --- (no changes since v4) Changes in v4: - New. Resent of my previous submission. https://lore.kernel.org/all/20210831074004.3195284-10-masahiroy@kernel.org/ scripts/Kbuild.include | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 455a0a6ce12d..ece44b735061 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -142,9 +142,11 @@ check-FORCE = $(if $(filter FORCE, $^),,$(warning FORCE prerequisite is missing) if-changed-cond = $(newer-prereqs)$(cmd-check)$(check-FORCE) # Execute command if command has changed or prerequisite(s) are updated. -if_changed = $(if $(if-changed-cond), \ +if_changed = $(if $(if-changed-cond),$(cmd_and_savecmd),@:) + +cmd_and_savecmd = \ $(cmd); \ - printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) + printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd # Execute the command and also postprocess generated .d dependencies file. if_changed_dep = $(if $(if-changed-cond),$(cmd_and_fixdep),@:) -- 2.32.0