diff options
| author | Matthias Kaehlcke <mka@chromium.org> | 2017-04-12 15:43:52 -0400 |
|---|---|---|
| committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-04-12 16:43:37 -0400 |
| commit | ebf003f0cfb3705e60d40dedc3ec949176c741af (patch) | |
| tree | 38e55cfbac691e87fe377f11dac3b4d1fa285416 /scripts | |
| parent | 6748cb3c299de1ffbe56733647b01dbcc398c419 (diff) | |
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 <mka@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Makefile.lib | 28 | ||||
| -rw-r--r-- | scripts/mod/Makefile | 28 |
2 files changed, 30 insertions, 26 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0a07f9014944..dd567e5d59e0 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
| @@ -408,3 +408,31 @@ quiet_cmd_xzmisc = XZMISC $@ | |||
| 408 | cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ | 408 | cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ |
| 409 | xz --check=crc32 --lzma2=dict=1MiB) > $@ || \ | 409 | xz --check=crc32 --lzma2=dict=1MiB) > $@ || \ |
| 410 | (rm -f $@ ; false) | 410 | (rm -f $@ ; false) |
| 411 | |||
| 412 | # ASM offsets | ||
| 413 | # --------------------------------------------------------------------------- | ||
| 414 | |||
| 415 | # Default sed regexp - multiline due to syntax constraints | ||
| 416 | define sed-offsets | ||
| 417 | "/^->/{s:->#\(.*\):/* \1 */:; \ | ||
| 418 | s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ | ||
| 419 | s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ | ||
| 420 | s:->::; p;}" | ||
| 421 | endef | ||
| 422 | |||
| 423 | # Use filechk to avoid rebuilds when a header changes, but the resulting file | ||
| 424 | # does not | ||
| 425 | define filechk_offsets | ||
| 426 | (set -e; \ | ||
| 427 | echo "#ifndef $2"; \ | ||
| 428 | echo "#define $2"; \ | ||
| 429 | echo "/*"; \ | ||
| 430 | echo " * DO NOT MODIFY."; \ | ||
| 431 | echo " *"; \ | ||
| 432 | echo " * This file was generated by Kbuild"; \ | ||
| 433 | echo " */"; \ | ||
| 434 | echo ""; \ | ||
| 435 | sed -ne $(sed-offsets); \ | ||
| 436 | echo ""; \ | ||
| 437 | echo "#endif" ) | ||
| 438 | endef | ||
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index 19d9bcadc0cc..b497d9764dcf 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile | |||
| @@ -7,32 +7,8 @@ modpost-objs := modpost.o file2alias.o sumversion.o | |||
| 7 | 7 | ||
| 8 | devicetable-offsets-file := devicetable-offsets.h | 8 | devicetable-offsets-file := devicetable-offsets.h |
| 9 | 9 | ||
| 10 | define sed-y | 10 | $(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s FORCE |
| 11 | "/^->/{s:->#\(.*\):/* \1 */:; \ | 11 | $(call filechk,offsets,__DEVICETABLE_OFFSETS_H__) |
| 12 | s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ | ||
| 13 | s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ | ||
| 14 | s:->::; p;}" | ||
| 15 | endef | ||
| 16 | |||
| 17 | quiet_cmd_offsets = GEN $@ | ||
| 18 | define cmd_offsets | ||
| 19 | (set -e; \ | ||
| 20 | echo "#ifndef __DEVICETABLE_OFFSETS_H__"; \ | ||
| 21 | echo "#define __DEVICETABLE_OFFSETS_H__"; \ | ||
| 22 | echo "/*"; \ | ||
| 23 | echo " * DO NOT MODIFY."; \ | ||
| 24 | echo " *"; \ | ||
| 25 | echo " * This file was generated by Kbuild"; \ | ||
| 26 | echo " *"; \ | ||
| 27 | echo " */"; \ | ||
| 28 | echo ""; \ | ||
| 29 | sed -ne $(sed-y) $<; \ | ||
| 30 | echo ""; \ | ||
| 31 | echo "#endif" ) > $@ | ||
| 32 | endef | ||
| 33 | |||
| 34 | $(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s | ||
| 35 | $(call if_changed,offsets) | ||
| 36 | 12 | ||
| 37 | targets += $(devicetable-offsets-file) devicetable-offsets.s | 13 | targets += $(devicetable-offsets-file) devicetable-offsets.s |
| 38 | 14 | ||
