From patchwork Tue Mar 29 20:44:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 8691231 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BDF0B9F44D for ; Tue, 29 Mar 2016 20:48:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECFEC20272 for ; Tue, 29 Mar 2016 20:48:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 033822026F for ; Tue, 29 Mar 2016 20:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754764AbcC2Ur7 (ORCPT ); Tue, 29 Mar 2016 16:47:59 -0400 Received: from alt13.smtp-out.videotron.ca ([135.19.0.26]:15237 "EHLO alt12.smtp-out.videotron.ca" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754332AbcC2UpK (ORCPT ); Tue, 29 Mar 2016 16:45:10 -0400 Received: from yoda.home ([96.23.157.65]) by Videotron with SMTP id l0VgaIpSDkaTMl0Vhabbk9; Tue, 29 Mar 2016 16:45:09 -0400 X-Authority-Analysis: v=2.1 cv=D8PnUqlj c=1 sm=1 tr=0 a=keA3yYpnlypCNW5BNWqu+w==:117 a=keA3yYpnlypCNW5BNWqu+w==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=7OsogOcEt9IA:10 a=KKAkSRfTAAAA:8 a=bCMoAEywNKvE7_hr2qYA:9 Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 426E62DA059F; Tue, 29 Mar 2016 16:45:08 -0400 (EDT) From: Nicolas Pitre To: Michal Marek Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 4/8] kbuild: de-duplicate fixdep usage Date: Tue, 29 Mar 2016 16:44:38 -0400 Message-Id: <1459284282-6676-5-git-send-email-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459284282-6676-1-git-send-email-nicolas.pitre@linaro.org> References: <1459284282-6676-1-git-send-email-nicolas.pitre@linaro.org> X-CMAE-Envelope: MS4wfHBS/e6gwAYgKsckvsz2F0WAVFBnje47rKjfLbtPwT5idxYdIE4irlIQFco2ci1k0j2qKlLsDpugrMSrecMop2jzBCeIETfjNHvgmJm1MoBJ1p8xoumP 1jlM1WSrUk6LhT4I4WR/YjtbB2ptDRpH2o1E5fKTqySNnoZ3IQUYvByiHdXaA0K0r+KwfuSSjmkF+QrVo9xMk2YeNzk9HhkDHlbhcjKX+yDJ3/1Qsej5YnwN mk7P0r4Yk+K5bdf+aVTPYg== Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The generation and postprocessing of automatic dependency rules is duplicated in rule_cc_o_c, rule_as_o_S and if_changed_dep. Since this is not a trivial one-liner action, it is now abstracted under cmd_and_fixdep to simplify things and make future changes in this area easier. In the rule_cc_o_c and rule_as_o_S cases that means the order of some commands has been altered, namely fixdep and related file manipulations are executed earlier, but they didn't depend on those commands that now execute later. Signed-off-by: Nicolas Pitre --- scripts/Kbuild.include | 5 ++++- scripts/Makefile.build | 19 +++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index b2ab2a92a3..80ca538bfb 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -256,10 +256,13 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ # Execute the command and also postprocess generated .d dependencies file. if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ + $(cmd_and_fixdep), @:) + +cmd_and_fixdep = \ $(echo-cmd) $(cmd_$(1)); \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd, @:) + mv -f $(dot-target).tmp $(dot-target).cmd; # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 74556e5e4e..12821d9eae 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -266,24 +266,15 @@ endif # CONFIG_STACK_VALIDATION define rule_cc_o_c $(call echo-cmd,checksrc) $(cmd_checksrc) \ - $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ + $(call cmd_and_fixdep,cc_o_c) \ $(cmd_modversions) \ - $(cmd_objtool) \ - $(call echo-cmd,record_mcount) \ - $(cmd_record_mcount) \ - scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ - $(dot-target).tmp; \ - rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd + $(cmd_objtool) \ + $(call echo-cmd,record_mcount) $(cmd_record_mcount) endef define rule_as_o_S - $(call echo-cmd,as_o_S) $(cmd_as_o_S); \ - $(cmd_objtool) \ - scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,as_o_S)' > \ - $(dot-target).tmp; \ - rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd + $(call cmd_and_fixdep,as_o_S) \ + $(cmd_objtool) endef # List module undefined symbols (or empty line if not enabled)