From patchwork Thu Apr 5 15:16:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 895438 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40H61d2Ccrz9s0p for ; Fri, 6 Apr 2018 01:19:17 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbeDEPTF (ORCPT ); Thu, 5 Apr 2018 11:19:05 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34474 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751638AbeDEPRC (ORCPT ); Thu, 5 Apr 2018 11:17:02 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 178804072CF7; Thu, 5 Apr 2018 15:17:02 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DE98AB400; Thu, 5 Apr 2018 15:16:59 +0000 (UTC) From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann Cc: lkml , netdev@vger.kernel.org, linux-kbuild@vger.kernel.org, Quentin Monnet , Eugene Syromiatnikov , Jiri Benc , Stanislav Kozina , Jerome Marchand , Arnaldo Carvalho de Melo , Masahiro Yamada , Michal Marek , Jiri Kosina Subject: [PATCH 4/9] kbuild: Add filechk2 function Date: Thu, 5 Apr 2018 17:16:40 +0200 Message-Id: <20180405151645.19130-5-jolsa@kernel.org> In-Reply-To: <20180405151645.19130-1-jolsa@kernel.org> References: <20180405151645.19130-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 05 Apr 2018 15:17:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 05 Apr 2018 15:17:02 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@kernel.org' RCPT:'' Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Adding filechk2 function that has the same semantics as filechk, but it takes the target file from the 2nd argument instead of from the '$@' as in the filechk function. This function is needed when we can't have separate target for the file, like in the following patch. Signed-off-by: Jiri Olsa --- scripts/Kbuild.include | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 065324a8046f..9775ce2771d4 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -67,6 +67,30 @@ define filechk fi endef +# filechk2 is used to check if the content of a generated file is updated. +# It follows the same logic as the filechk except instead of the $@ target +# variable, the checked file is passed in 2nd argument. +# +# Sample usage: +# define filechk_sample +# echo $KERNELRELEASE +# endef +# version.h : Makefile +# $(call filechk2,sample,version.h) +# endef +define filechk2 + $(Q)set -e; \ + $(kecho) ' CHK $(2)'; \ + mkdir -p $(dir $(2)); \ + $(filechk_$(1)) < $< > $(2).tmp; \ + if [ -r $(2) ] && cmp -s $(2) $(2).tmp; then \ + rm -f $(2).tmp; \ + else \ + $(kecho) ' UPD $(2)'; \ + mv -f $(2).tmp $(2); \ + fi +endef + ###### # gcc support functions # See documentation in Documentation/kbuild/makefiles.txt