blob: ef97787bf45945ee22803325a641d13b9c4468d9 [file] [log] [blame]
Masahiro Yamada6a44d802014-02-24 11:12:11 +09001#
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
7#####
8# 1) Generate generic-asm-offsets.h
9
10generic-offsets-file := include/generated/generic-asm-offsets.h
11
12always := $(generic-offsets-file)
13targets := $(generic-offsets-file) lib/asm-offsets.s
14
15quiet_cmd_generic-offsets = GEN $@
16define cmd_generic-offsets
17 (set -e; \
18 echo "#ifndef __GENERIC_ASM_OFFSETS_H__"; \
19 echo "#define __GENERIC_ASM_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" ) > $@
30endef
31
32# We use internal kbuild rules to avoid the "is up to date" message from make
33lib/asm-offsets.s: lib/asm-offsets.c FORCE
34 $(Q)mkdir -p $(dir $@)
35 $(call if_changed_dep,cc_s_c)
36
37$(obj)/$(generic-offsets-file): lib/asm-offsets.s Kbuild
38 $(Q)mkdir -p $(dir $@)
39 $(call cmd,generic-offsets)
40
41#####
42# 2) Generate asm-offsets.h
43#
44
Masahiro Yamada254d68b2014-03-18 16:38:13 +090045ifneq ($(wildcard $(srctree)/arch/$(ARCH)/lib/asm-offsets.c),)
Masahiro Yamada6a44d802014-02-24 11:12:11 +090046offsets-file := include/generated/asm-offsets.h
47endif
48
49always += $(offsets-file)
50targets += $(offsets-file)
Masahiro Yamada254d68b2014-03-18 16:38:13 +090051targets += arch/$(ARCH)/lib/asm-offsets.s
Masahiro Yamada6a44d802014-02-24 11:12:11 +090052
53
54# Default sed regexp - multiline due to syntax constraints
55define sed-y
Jeroen Hofsteefe5d1ab2014-07-30 21:54:54 +020056 "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \
57 /^->/{s:->#\(.*\):/* \1 */:; \
Masahiro Yamada6a44d802014-02-24 11:12:11 +090058 s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
59 s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
60 s:->::; p;}"
61endef
62
63CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY
64
65quiet_cmd_offsets = GEN $@
66define cmd_offsets
67 (set -e; \
68 echo "#ifndef __ASM_OFFSETS_H__"; \
69 echo "#define __ASM_OFFSETS_H__"; \
70 echo "/*"; \
71 echo " * DO NOT MODIFY."; \
72 echo " *"; \
73 echo " * This file was generated by Kbuild"; \
74 echo " *"; \
75 echo " */"; \
76 echo ""; \
77 sed -ne $(sed-y) $<; \
78 echo ""; \
79 echo "#endif" ) > $@
80endef
81
82# We use internal kbuild rules to avoid the "is up to date" message from make
Masahiro Yamada254d68b2014-03-18 16:38:13 +090083arch/$(ARCH)/lib/asm-offsets.s: arch/$(ARCH)/lib/asm-offsets.c FORCE
Masahiro Yamada6a44d802014-02-24 11:12:11 +090084 $(Q)mkdir -p $(dir $@)
85 $(call if_changed_dep,cc_s_c)
86
Masahiro Yamada254d68b2014-03-18 16:38:13 +090087$(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s Kbuild
Masahiro Yamada6a44d802014-02-24 11:12:11 +090088 $(call cmd,offsets)