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
8 # 1) Generate generic-asm-offsets.h
10 generic-offsets-file := include/generated/generic-asm-offsets.h
12 always := $(generic-offsets-file)
13 targets := $(generic-offsets-file) lib/asm-offsets.s
15 quiet_cmd_generic-offsets = GEN $@
16 define cmd_generic-offsets
18 echo "#ifndef __GENERIC_ASM_OFFSETS_H__"; \
19 echo "#define __GENERIC_ASM_OFFSETS_H__"; \
21 echo " * DO NOT MODIFY."; \
23 echo " * This file was generated by Kbuild"; \
27 sed -ne $(sed-y) $<; \
32 # We use internal kbuild rules to avoid the "is up to date" message from make
33 lib/asm-offsets.s: lib/asm-offsets.c FORCE
34 $(Q)mkdir -p $(dir $@)
35 $(call if_changed_dep,cc_s_c)
37 $(obj)/$(generic-offsets-file): lib/asm-offsets.s Kbuild
38 $(Q)mkdir -p $(dir $@)
39 $(call cmd,generic-offsets)
42 # 2) Generate asm-offsets.h
45 ifneq ($(wildcard $(srctree)/arch/$(ARCH)/lib/asm-offsets.c),)
46 offsets-file := include/generated/asm-offsets.h
49 always += $(offsets-file)
50 targets += $(offsets-file)
51 targets += arch/$(ARCH)/lib/asm-offsets.s
54 # Default sed regexp - multiline due to syntax constraints
56 "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \
57 /^->/{s:->#\(.*\):/* \1 */:; \
58 s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
59 s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
63 CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY
65 quiet_cmd_offsets = GEN $@
68 echo "#ifndef __ASM_OFFSETS_H__"; \
69 echo "#define __ASM_OFFSETS_H__"; \
71 echo " * DO NOT MODIFY."; \
73 echo " * This file was generated by Kbuild"; \
77 sed -ne $(sed-y) $<; \
82 # We use internal kbuild rules to avoid the "is up to date" message from make
83 arch/$(ARCH)/lib/asm-offsets.s: arch/$(ARCH)/lib/asm-offsets.c FORCE
84 $(Q)mkdir -p $(dir $@)
85 $(call if_changed_dep,cc_s_c)
87 $(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s Kbuild