Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 1 | # |
| 2 | # Kbuild for top-level directory of U-Boot |
| 3 | # This file takes care of the following: |
| 4 | # 1) Generate generic-asm-offsets.h |
| 5 | # 2) Generate asm-offsets.h |
| 6 | |
Masahiro Yamada | 490cf5f | 2015-03-27 10:59:01 +0900 | [diff] [blame^] | 7 | # Default sed regexp - multiline due to syntax constraints |
| 8 | define sed-y |
| 9 | "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \ |
| 10 | /^->/{s:->#\(.*\):/* \1 */:; \ |
| 11 | s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ |
| 12 | s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ |
| 13 | s:->::; p;}" |
| 14 | endef |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 15 | |
Masahiro Yamada | 490cf5f | 2015-03-27 10:59:01 +0900 | [diff] [blame^] | 16 | quiet_cmd_offsets = GEN $@ |
| 17 | define cmd_offsets |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 18 | (set -e; \ |
Masahiro Yamada | 490cf5f | 2015-03-27 10:59:01 +0900 | [diff] [blame^] | 19 | echo "#ifndef $2"; \ |
| 20 | echo "#define $2"; \ |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 21 | echo "/*"; \ |
| 22 | echo " * DO NOT MODIFY."; \ |
| 23 | echo " *"; \ |
| 24 | echo " * This file was generated by Kbuild"; \ |
| 25 | echo " *"; \ |
| 26 | echo " */"; \ |
| 27 | echo ""; \ |
| 28 | sed -ne $(sed-y) $<; \ |
| 29 | echo ""; \ |
| 30 | echo "#endif" ) > $@ |
| 31 | endef |
| 32 | |
Masahiro Yamada | 490cf5f | 2015-03-27 10:59:01 +0900 | [diff] [blame^] | 33 | ##### |
| 34 | # 1) Generate generic-asm-offsets.h |
| 35 | |
| 36 | generic-offsets-file := include/generated/generic-asm-offsets.h |
| 37 | |
| 38 | always := $(generic-offsets-file) |
| 39 | targets := $(generic-offsets-file) lib/asm-offsets.s |
| 40 | |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 41 | # We use internal kbuild rules to avoid the "is up to date" message from make |
| 42 | lib/asm-offsets.s: lib/asm-offsets.c FORCE |
| 43 | $(Q)mkdir -p $(dir $@) |
| 44 | $(call if_changed_dep,cc_s_c) |
| 45 | |
| 46 | $(obj)/$(generic-offsets-file): lib/asm-offsets.s Kbuild |
| 47 | $(Q)mkdir -p $(dir $@) |
Masahiro Yamada | 490cf5f | 2015-03-27 10:59:01 +0900 | [diff] [blame^] | 48 | $(call cmd,offsets,__GENERIC_ASM_OFFSETS_H__) |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 49 | |
| 50 | ##### |
| 51 | # 2) Generate asm-offsets.h |
| 52 | # |
| 53 | |
Masahiro Yamada | 254d68b | 2014-03-18 16:38:13 +0900 | [diff] [blame] | 54 | ifneq ($(wildcard $(srctree)/arch/$(ARCH)/lib/asm-offsets.c),) |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 55 | offsets-file := include/generated/asm-offsets.h |
| 56 | endif |
| 57 | |
| 58 | always += $(offsets-file) |
| 59 | targets += $(offsets-file) |
Masahiro Yamada | 254d68b | 2014-03-18 16:38:13 +0900 | [diff] [blame] | 60 | targets += arch/$(ARCH)/lib/asm-offsets.s |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 61 | |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 62 | CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY |
| 63 | |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 64 | # We use internal kbuild rules to avoid the "is up to date" message from make |
Masahiro Yamada | 254d68b | 2014-03-18 16:38:13 +0900 | [diff] [blame] | 65 | arch/$(ARCH)/lib/asm-offsets.s: arch/$(ARCH)/lib/asm-offsets.c FORCE |
Masahiro Yamada | 6a44d80 | 2014-02-24 11:12:11 +0900 | [diff] [blame] | 66 | $(Q)mkdir -p $(dir $@) |
| 67 | $(call if_changed_dep,cc_s_c) |
| 68 | |
Masahiro Yamada | 254d68b | 2014-03-18 16:38:13 +0900 | [diff] [blame] | 69 | $(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s Kbuild |
Masahiro Yamada | 490cf5f | 2015-03-27 10:59:01 +0900 | [diff] [blame^] | 70 | $(call cmd,offsets,__ASM_OFFSETS_H__) |