]>
Commit | Line | Data |
---|---|---|
22b74881 GKH |
1 | From foo@baz Wed Nov 21 18:50:39 CET 2018 |
2 | From: Matthias Kaehlcke <mka@chromium.org> | |
3 | Date: Wed, 12 Apr 2017 12:43:52 -0700 | |
4 | Subject: kbuild: Consolidate header generation from ASM offset information | |
5 | ||
6 | From: Matthias Kaehlcke <mka@chromium.org> | |
7 | ||
8 | commit ebf003f0cfb3705e60d40dedc3ec949176c741af upstream. | |
9 | ||
10 | Largely redundant code is used in different places to generate C headers | |
11 | from offset information extracted from assembly language output. | |
12 | Consolidate the code in Makefile.lib and use this instead. | |
13 | ||
14 | Signed-off-by: Matthias Kaehlcke <mka@chromium.org> | |
15 | Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> | |
16 | Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> | |
17 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
18 | --- | |
19 | Kbuild | 25 ------------------------- | |
20 | arch/ia64/kernel/Makefile | 26 ++------------------------ | |
21 | scripts/Makefile.lib | 28 ++++++++++++++++++++++++++++ | |
22 | scripts/mod/Makefile | 28 ++-------------------------- | |
23 | 4 files changed, 32 insertions(+), 75 deletions(-) | |
24 | ||
25 | --- a/Kbuild | |
26 | +++ b/Kbuild | |
27 | @@ -6,31 +6,6 @@ | |
28 | # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h) | |
29 | # 4) Check for missing system calls | |
30 | ||
31 | -# Default sed regexp - multiline due to syntax constraints | |
32 | -define sed-y | |
33 | - "/^->/{s:->#\(.*\):/* \1 */:; \ | |
34 | - s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ | |
35 | - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ | |
36 | - s:->::; p;}" | |
37 | -endef | |
38 | - | |
39 | -# Use filechk to avoid rebuilds when a header changes, but the resulting file | |
40 | -# does not | |
41 | -define filechk_offsets | |
42 | - (set -e; \ | |
43 | - echo "#ifndef $2"; \ | |
44 | - echo "#define $2"; \ | |
45 | - echo "/*"; \ | |
46 | - echo " * DO NOT MODIFY."; \ | |
47 | - echo " *"; \ | |
48 | - echo " * This file was generated by Kbuild"; \ | |
49 | - echo " */"; \ | |
50 | - echo ""; \ | |
51 | - sed -ne $(sed-y); \ | |
52 | - echo ""; \ | |
53 | - echo "#endif" ) | |
54 | -endef | |
55 | - | |
56 | ##### | |
57 | # 1) Generate bounds.h | |
58 | ||
59 | --- a/arch/ia64/kernel/Makefile | |
60 | +++ b/arch/ia64/kernel/Makefile | |
61 | @@ -50,32 +50,10 @@ CFLAGS_traps.o += -mfixed-range=f2-f5,f | |
62 | # The gate DSO image is built using a special linker script. | |
63 | include $(src)/Makefile.gate | |
64 | ||
65 | -# Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config | |
66 | -define sed-y | |
67 | - "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" | |
68 | -endef | |
69 | -quiet_cmd_nr_irqs = GEN $@ | |
70 | -define cmd_nr_irqs | |
71 | - (set -e; \ | |
72 | - echo "#ifndef __ASM_NR_IRQS_H__"; \ | |
73 | - echo "#define __ASM_NR_IRQS_H__"; \ | |
74 | - echo "/*"; \ | |
75 | - echo " * DO NOT MODIFY."; \ | |
76 | - echo " *"; \ | |
77 | - echo " * This file was generated by Kbuild"; \ | |
78 | - echo " *"; \ | |
79 | - echo " */"; \ | |
80 | - echo ""; \ | |
81 | - sed -ne $(sed-y) $<; \ | |
82 | - echo ""; \ | |
83 | - echo "#endif" ) > $@ | |
84 | -endef | |
85 | - | |
86 | # We use internal kbuild rules to avoid the "is up to date" message from make | |
87 | arch/$(SRCARCH)/kernel/nr-irqs.s: arch/$(SRCARCH)/kernel/nr-irqs.c | |
88 | $(Q)mkdir -p $(dir $@) | |
89 | $(call if_changed_dep,cc_s_c) | |
90 | ||
91 | -include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s | |
92 | - $(Q)mkdir -p $(dir $@) | |
93 | - $(call cmd,nr_irqs) | |
94 | +include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s FORCE | |
95 | + $(call filechk,offsets,__ASM_NR_IRQS_H__) | |
96 | --- a/scripts/Makefile.lib | |
97 | +++ b/scripts/Makefile.lib | |
98 | @@ -388,3 +388,31 @@ quiet_cmd_xzmisc = XZMISC $@ | |
99 | cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ | |
100 | xz --check=crc32 --lzma2=dict=1MiB) > $@ || \ | |
101 | (rm -f $@ ; false) | |
102 | + | |
103 | +# ASM offsets | |
104 | +# --------------------------------------------------------------------------- | |
105 | + | |
106 | +# Default sed regexp - multiline due to syntax constraints | |
107 | +define sed-offsets | |
108 | + "/^->/{s:->#\(.*\):/* \1 */:; \ | |
109 | + s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ | |
110 | + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ | |
111 | + s:->::; p;}" | |
112 | +endef | |
113 | + | |
114 | +# Use filechk to avoid rebuilds when a header changes, but the resulting file | |
115 | +# does not | |
116 | +define filechk_offsets | |
117 | + (set -e; \ | |
118 | + echo "#ifndef $2"; \ | |
119 | + echo "#define $2"; \ | |
120 | + echo "/*"; \ | |
121 | + echo " * DO NOT MODIFY."; \ | |
122 | + echo " *"; \ | |
123 | + echo " * This file was generated by Kbuild"; \ | |
124 | + echo " */"; \ | |
125 | + echo ""; \ | |
126 | + sed -ne $(sed-offsets); \ | |
127 | + echo ""; \ | |
128 | + echo "#endif" ) | |
129 | +endef | |
130 | --- a/scripts/mod/Makefile | |
131 | +++ b/scripts/mod/Makefile | |
132 | @@ -5,32 +5,8 @@ modpost-objs := modpost.o file2alias.o s | |
133 | ||
134 | devicetable-offsets-file := devicetable-offsets.h | |
135 | ||
136 | -define sed-y | |
137 | - "/^->/{s:->#\(.*\):/* \1 */:; \ | |
138 | - s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ | |
139 | - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ | |
140 | - s:->::; p;}" | |
141 | -endef | |
142 | - | |
143 | -quiet_cmd_offsets = GEN $@ | |
144 | -define cmd_offsets | |
145 | - (set -e; \ | |
146 | - echo "#ifndef __DEVICETABLE_OFFSETS_H__"; \ | |
147 | - echo "#define __DEVICETABLE_OFFSETS_H__"; \ | |
148 | - echo "/*"; \ | |
149 | - echo " * DO NOT MODIFY."; \ | |
150 | - echo " *"; \ | |
151 | - echo " * This file was generated by Kbuild"; \ | |
152 | - echo " *"; \ | |
153 | - echo " */"; \ | |
154 | - echo ""; \ | |
155 | - sed -ne $(sed-y) $<; \ | |
156 | - echo ""; \ | |
157 | - echo "#endif" ) > $@ | |
158 | -endef | |
159 | - | |
160 | -$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s | |
161 | - $(call if_changed,offsets) | |
162 | +$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s FORCE | |
163 | + $(call filechk,offsets,__DEVICETABLE_OFFSETS_H__) | |
164 | ||
165 | targets += $(devicetable-offsets-file) devicetable-offsets.s | |
166 |