[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170403193739.84905-1-mka@chromium.org>
Date: Mon, 3 Apr 2017 12:37:39 -0700
From: Matthias Kaehlcke <mka@...omium.org>
To: Tony Luck <tony.luck@...el.com>, Fenghua Yu <fenghua.yu@...el.com>,
Michal Marek <mmarek@...e.com>,
Jan Kiszka <jan.kiszka@...mens.com>,
Kieran Bingham <kieran.bingham@...aro.org>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, linux-ia64@...r.kernel.org,
linux-kbuild@...r.kernel.org,
Grant Grundler <grundler@...omium.org>,
Michael Davidson <md@...gle.com>,
Greg Hackmann <ghackmann@...gle.com>,
Matthias Kaehlcke <mka@...omium.org>
Subject: [PATCH] kbuild: Consolidate header generation from ASM offset information
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 <mka@...omium.org>
---
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
--
2.12.2.564.g063fe858b8-goog
Powered by blists - more mailing lists