blob: 51f7433bb3d775635aaaded263fcaf998879f460 [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
Masahiro Yamada490cf5f2015-03-27 10:59:01 +09007# Default sed regexp - multiline due to syntax constraints
8define 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;}"
14endef
Masahiro Yamada6a44d802014-02-24 11:12:11 +090015
Masahiro Yamada490cf5f2015-03-27 10:59:01 +090016quiet_cmd_offsets = GEN $@
17define cmd_offsets
Masahiro Yamada6a44d802014-02-24 11:12:11 +090018 (set -e; \
Masahiro Yamada490cf5f2015-03-27 10:59:01 +090019 echo "#ifndef $2"; \
20 echo "#define $2"; \
Masahiro Yamada6a44d802014-02-24 11:12:11 +090021 echo "/*"; \
22 echo " * DO NOT MODIFY."; \
23 echo " *"; \
24 echo " * This file was generated by Kbuild"; \
Masahiro Yamada6a44d802014-02-24 11:12:11 +090025 echo " */"; \
26 echo ""; \
27 sed -ne $(sed-y) $<; \
28 echo ""; \
29 echo "#endif" ) > $@
30endef
31
Masahiro Yamada490cf5f2015-03-27 10:59:01 +090032#####
33# 1) Generate generic-asm-offsets.h
34
35generic-offsets-file := include/generated/generic-asm-offsets.h
36
37always := $(generic-offsets-file)
38targets := $(generic-offsets-file) lib/asm-offsets.s
39
Masahiro Yamada6a44d802014-02-24 11:12:11 +090040# We use internal kbuild rules to avoid the "is up to date" message from make
41lib/asm-offsets.s: lib/asm-offsets.c FORCE
42 $(Q)mkdir -p $(dir $@)
43 $(call if_changed_dep,cc_s_c)
44
45$(obj)/$(generic-offsets-file): lib/asm-offsets.s Kbuild
46 $(Q)mkdir -p $(dir $@)
Masahiro Yamada490cf5f2015-03-27 10:59:01 +090047 $(call cmd,offsets,__GENERIC_ASM_OFFSETS_H__)
Masahiro Yamada6a44d802014-02-24 11:12:11 +090048
49#####
50# 2) Generate asm-offsets.h
51#
52
Masahiro Yamada254d68b2014-03-18 16:38:13 +090053ifneq ($(wildcard $(srctree)/arch/$(ARCH)/lib/asm-offsets.c),)
Masahiro Yamada6a44d802014-02-24 11:12:11 +090054offsets-file := include/generated/asm-offsets.h
55endif
56
57always += $(offsets-file)
58targets += $(offsets-file)
Masahiro Yamada254d68b2014-03-18 16:38:13 +090059targets += arch/$(ARCH)/lib/asm-offsets.s
Masahiro Yamada6a44d802014-02-24 11:12:11 +090060
Masahiro Yamada6a44d802014-02-24 11:12:11 +090061CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY
62
Masahiro Yamada6a44d802014-02-24 11:12:11 +090063# We use internal kbuild rules to avoid the "is up to date" message from make
Masahiro Yamada254d68b2014-03-18 16:38:13 +090064arch/$(ARCH)/lib/asm-offsets.s: arch/$(ARCH)/lib/asm-offsets.c FORCE
Masahiro Yamada6a44d802014-02-24 11:12:11 +090065 $(Q)mkdir -p $(dir $@)
66 $(call if_changed_dep,cc_s_c)
67
Masahiro Yamada254d68b2014-03-18 16:38:13 +090068$(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s Kbuild
Masahiro Yamada490cf5f2015-03-27 10:59:01 +090069 $(call cmd,offsets,__ASM_OFFSETS_H__)