Skip to content

Commit 0493e5f

Browse files
Matthias Kaehlckepundiramit
Matthias Kaehlcke
authored andcommittedNov 20, 2017
UPSTREAM: 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 Makefile.lib and use this instead. Signed-off-by: Matthias Kaehlcke <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> (cherry picked from commit ebf003f) Signed-off-by: Greg Hackmann <[email protected]> Change-Id: I0acd54dd27c0cf0868f221bd63728a9b67320b25
1 parent 60354b7 commit 0493e5f

File tree

4 files changed

+32
-75
lines changed

4 files changed

+32
-75
lines changed
 

‎Kbuild

-25
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,6 @@
66
# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
77
# 4) Check for missing system calls
88

9-
# Default sed regexp - multiline due to syntax constraints
10-
define sed-y
11-
"/^->/{s:->#\(.*\):/* \1 */:; \
12-
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
13-
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
14-
s:->::; p;}"
15-
endef
16-
17-
# Use filechk to avoid rebuilds when a header changes, but the resulting file
18-
# does not
19-
define filechk_offsets
20-
(set -e; \
21-
echo "#ifndef $2"; \
22-
echo "#define $2"; \
23-
echo "/*"; \
24-
echo " * DO NOT MODIFY."; \
25-
echo " *"; \
26-
echo " * This file was generated by Kbuild"; \
27-
echo " */"; \
28-
echo ""; \
29-
sed -ne $(sed-y); \
30-
echo ""; \
31-
echo "#endif" )
32-
endef
33-
349
#####
3510
# 1) Generate bounds.h
3611

‎arch/ia64/kernel/Makefile

+2-24
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,10 @@ CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31
5050
# The gate DSO image is built using a special linker script.
5151
include $(src)/Makefile.gate
5252

53-
# Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config
54-
define sed-y
55-
"/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
56-
endef
57-
quiet_cmd_nr_irqs = GEN $@
58-
define cmd_nr_irqs
59-
(set -e; \
60-
echo "#ifndef __ASM_NR_IRQS_H__"; \
61-
echo "#define __ASM_NR_IRQS_H__"; \
62-
echo "/*"; \
63-
echo " * DO NOT MODIFY."; \
64-
echo " *"; \
65-
echo " * This file was generated by Kbuild"; \
66-
echo " *"; \
67-
echo " */"; \
68-
echo ""; \
69-
sed -ne $(sed-y) $<; \
70-
echo ""; \
71-
echo "#endif" ) > $@
72-
endef
73-
7453
# We use internal kbuild rules to avoid the "is up to date" message from make
7554
arch/$(SRCARCH)/kernel/nr-irqs.s: arch/$(SRCARCH)/kernel/nr-irqs.c
7655
$(Q)mkdir -p $(dir $@)
7756
$(call if_changed_dep,cc_s_c)
7857

79-
include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s
80-
$(Q)mkdir -p $(dir $@)
81-
$(call cmd,nr_irqs)
58+
include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s FORCE
59+
$(call filechk,offsets,__ASM_NR_IRQS_H__)

‎scripts/Makefile.lib

+28
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,31 @@ quiet_cmd_xzmisc = XZMISC $@
394394
cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
395395
xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
396396
(rm -f $@ ; false)
397+
398+
# ASM offsets
399+
# ---------------------------------------------------------------------------
400+
401+
# Default sed regexp - multiline due to syntax constraints
402+
define sed-offsets
403+
"/^->/{s:->#\(.*\):/* \1 */:; \
404+
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
405+
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
406+
s:->::; p;}"
407+
endef
408+
409+
# Use filechk to avoid rebuilds when a header changes, but the resulting file
410+
# does not
411+
define filechk_offsets
412+
(set -e; \
413+
echo "#ifndef $2"; \
414+
echo "#define $2"; \
415+
echo "/*"; \
416+
echo " * DO NOT MODIFY."; \
417+
echo " *"; \
418+
echo " * This file was generated by Kbuild"; \
419+
echo " */"; \
420+
echo ""; \
421+
sed -ne $(sed-offsets); \
422+
echo ""; \
423+
echo "#endif" )
424+
endef

‎scripts/mod/Makefile

+2-26
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,8 @@ modpost-objs := modpost.o file2alias.o sumversion.o
55

66
devicetable-offsets-file := devicetable-offsets.h
77

8-
define sed-y
9-
"/^->/{s:->#\(.*\):/* \1 */:; \
10-
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
11-
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
12-
s:->::; p;}"
13-
endef
14-
15-
quiet_cmd_offsets = GEN $@
16-
define cmd_offsets
17-
(set -e; \
18-
echo "#ifndef __DEVICETABLE_OFFSETS_H__"; \
19-
echo "#define __DEVICETABLE_OFFSETS_H__"; \
20-
echo "/*"; \
21-
echo " * DO NOT MODIFY."; \
22-
echo " *"; \
23-
echo " * This file was generated by Kbuild"; \
24-
echo " *"; \
25-
echo " */"; \
26-
echo ""; \
27-
sed -ne $(sed-y) $<; \
28-
echo ""; \
29-
echo "#endif" ) > $@
30-
endef
31-
32-
$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s
33-
$(call if_changed,offsets)
8+
$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s FORCE
9+
$(call filechk,offsets,__DEVICETABLE_OFFSETS_H__)
3410

3511
targets += $(devicetable-offsets-file) devicetable-offsets.s
3612

0 commit comments

Comments
 (0)
Please sign in to comment.