From patchwork Mon Apr 3 19:37:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 9660457 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 682196032D for ; Mon, 3 Apr 2017 19:38:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 585C4284D6 for ; Mon, 3 Apr 2017 19:38:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C7CE284EC; Mon, 3 Apr 2017 19:38:20 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 8C50F284D6 for ; Mon, 3 Apr 2017 19:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751918AbdDCTiB (ORCPT ); Mon, 3 Apr 2017 15:38:01 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:36623 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752515AbdDCTiA (ORCPT ); Mon, 3 Apr 2017 15:38:00 -0400 Received: by mail-pg0-f47.google.com with SMTP id g2so128225376pge.3 for ; Mon, 03 Apr 2017 12:38:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Rg175T8ISI9WRf+z0ab+xxBZMM86u9me+Z6VW4DyX04=; b=FhIfMdXsjNfbYcZYfECrhzsaSqhn3dS3irlkrCb/l49V+HIe5zmWGsNu2B3pm1uxie sIlicSZ8eQsuj2gk7jd0vHeUupASvSZXeJGa7YkuWzO/i8OuFMRQK0wNvTO/LbDl+v/A BsYssCCq+Mb7vm7sze8oZtu0biiDPFKiOAw0m1vT9ed4qpp0iREpFq6xjOGi08GwVjLm VRWsb+Wi8U7D2snqQzmidlLntGJYNkG+mo6IfKy+GS5Y49xfCq8N+IIdcz7O4z0vxmaK KaZR0/NkjZbiDKPIdLipvbzwir8qhqtg78daxF6G/c0SIZXJG1zK29zhvI8BKScirFwH uukw== X-Gm-Message-State: AFeK/H0MlOtUkjKWJtHHEnY/ZxPQsMVnEyeKwvT+FJQcskb3m/BZdyZ7bUPV5fqQCRTJw9Pb X-Received: by 10.98.67.89 with SMTP id q86mr18354289pfa.237.1491248279738; Mon, 03 Apr 2017 12:37:59 -0700 (PDT) Received: from mka.mtv.corp.google.com ([172.22.64.162]) by smtp.gmail.com with ESMTPSA id z21sm27465629pgc.53.2017.04.03.12.37.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 12:37:59 -0700 (PDT) From: Matthias Kaehlcke To: Tony Luck , Fenghua Yu , Michal Marek , Jan Kiszka , Kieran Bingham , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-kbuild@vger.kernel.org, Grant Grundler , Michael Davidson , Greg Hackmann , Matthias Kaehlcke Subject: [PATCH] kbuild: Consolidate header generation from ASM offset information Date: Mon, 3 Apr 2017 12:37:39 -0700 Message-Id: <20170403193739.84905-1-mka@chromium.org> X-Mailer: git-send-email 2.12.2.564.g063fe858b8-goog 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 Largely redundant code is used in different places to generate C headers from offset information extracted from assembly language output. Consolidate the code in a Makefile include and use this instead. Signed-off-by: Matthias Kaehlcke --- Kbuild | 21 ++------------------- arch/ia64/kernel/Makefile | 19 +++---------------- scripts/Makefile.asm-offsets | 22 ++++++++++++++++++++++ scripts/mod/Makefile | 21 ++------------------- 4 files changed, 29 insertions(+), 54 deletions(-) create mode 100644 scripts/Makefile.asm-offsets diff --git a/Kbuild b/Kbuild index 3d0ae152af7c..e3789c9611fd 100644 --- a/Kbuild +++ b/Kbuild @@ -7,29 +7,12 @@ # 4) Check for missing system calls # 5) Generate constants.py (may need bounds.h) -# Default sed regexp - multiline due to syntax constraints -define sed-y - "/^->/{s:->#\(.*\):/* \1 */:; \ - s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:->::; p;}" -endef +include scripts/Makefile.asm-offsets # Use filechk to avoid rebuilds when a header changes, but the resulting file # does not define filechk_offsets - (set -e; \ - echo "#ifndef $2"; \ - echo "#define $2"; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was generated by Kbuild"; \ - echo " */"; \ - echo ""; \ - sed -ne $(sed-y); \ - echo ""; \ - echo "#endif" ) + $(call gen_header_from_asm_offsets,$2) endef ##### diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile index 3686d6abafde..186ba553ff26 100644 --- a/arch/ia64/kernel/Makefile +++ b/arch/ia64/kernel/Makefile @@ -50,25 +50,12 @@ CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31 # The gate DSO image is built using a special linker script. include $(src)/Makefile.gate +include $(srctree)/scripts/Makefile.asm-offsets + # Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config -define sed-y - "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" -endef quiet_cmd_nr_irqs = GEN $@ define cmd_nr_irqs - (set -e; \ - echo "#ifndef __ASM_NR_IRQS_H__"; \ - echo "#define __ASM_NR_IRQS_H__"; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was generated by Kbuild"; \ - echo " *"; \ - echo " */"; \ - echo ""; \ - sed -ne $(sed-y) $<; \ - echo ""; \ - echo "#endif" ) > $@ + $(call gen_header_from_asm_offsets,__ASM_NR_IRQS_H__) < $< > $@ endef # We use internal kbuild rules to avoid the "is up to date" message from make diff --git a/scripts/Makefile.asm-offsets b/scripts/Makefile.asm-offsets new file mode 100644 index 000000000000..4ba80ba29b82 --- /dev/null +++ b/scripts/Makefile.asm-offsets @@ -0,0 +1,22 @@ +# Default sed regexp - multiline due to syntax constraints +define sed-asm-offsets-to-c + "/^->/{s:->#\(.*\):/* \1 */:; \ + s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:->::; p;}" +endef + +define gen_header_from_asm_offsets + (set -e; \ + echo "#ifndef $1"; \ + echo "#define $1"; \ + echo "/*"; \ + echo " * DO NOT MODIFY."; \ + echo " *"; \ + echo " * This file was generated by Kbuild"; \ + echo " */"; \ + echo ""; \ + sed -ne $(sed-asm-offsets-to-c); \ + echo ""; \ + echo "#endif" ) +endef diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index 19d9bcadc0cc..5858bebfaf32 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile @@ -7,28 +7,11 @@ modpost-objs := modpost.o file2alias.o sumversion.o devicetable-offsets-file := devicetable-offsets.h -define sed-y - "/^->/{s:->#\(.*\):/* \1 */:; \ - s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:->::; p;}" -endef +include $(srctree)/scripts/Makefile.asm-offsets quiet_cmd_offsets = GEN $@ define cmd_offsets - (set -e; \ - echo "#ifndef __DEVICETABLE_OFFSETS_H__"; \ - echo "#define __DEVICETABLE_OFFSETS_H__"; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was generated by Kbuild"; \ - echo " *"; \ - echo " */"; \ - echo ""; \ - sed -ne $(sed-y) $<; \ - echo ""; \ - echo "#endif" ) > $@ + $(call gen_header_from_asm_offsets,__DEVICETABLE_OFFSETS_H__) < $< > $@ endef $(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s