Commit 6a44d80634f7bf78182f5988ed0b93f2349a25ce
Committed by
Tom Rini
1 parent
6378008a44
Exists in
master
and in
49 other branches
kbuild: move asm-offsets.h rules to ./Kbuild
Generate include/generated/generic-asm-offsets.h and include/generated/asm-offsets.h in ./Kbuild. This commit also changes the include guard. Before this commit, __ASM_OFFSETS_H__ was used for both of them. So we could not include generic-asm-offsets.h and asm-offsets.h at the same time. This commit renames the include guard of the former to __GENERIC_ASM_OFFSETS_H__. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Showing 3 changed files with 89 additions and 61 deletions Side-by-side Diff
Kbuild
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 | + | |
7 | +##### | |
8 | +# 1) Generate generic-asm-offsets.h | |
9 | + | |
10 | +generic-offsets-file := include/generated/generic-asm-offsets.h | |
11 | + | |
12 | +always := $(generic-offsets-file) | |
13 | +targets := $(generic-offsets-file) lib/asm-offsets.s | |
14 | + | |
15 | +quiet_cmd_generic-offsets = GEN $@ | |
16 | +define 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" ) > $@ | |
30 | +endef | |
31 | + | |
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) | |
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 | + | |
45 | +ifneq ($(wildcard $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c),) | |
46 | +offsets-file := include/generated/asm-offsets.h | |
47 | +endif | |
48 | + | |
49 | +always += $(offsets-file) | |
50 | +targets += $(offsets-file) | |
51 | +targets += $(CPUDIR)/$(SOC)/asm-offsets.s | |
52 | + | |
53 | + | |
54 | +# Default sed regexp - multiline due to syntax constraints | |
55 | +define sed-y | |
56 | + "/^->/{s:->#\(.*\):/* \1 */:; \ | |
57 | + s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ | |
58 | + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ | |
59 | + s:->::; p;}" | |
60 | +endef | |
61 | + | |
62 | +CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY | |
63 | + | |
64 | +quiet_cmd_offsets = GEN $@ | |
65 | +define cmd_offsets | |
66 | + (set -e; \ | |
67 | + echo "#ifndef __ASM_OFFSETS_H__"; \ | |
68 | + echo "#define __ASM_OFFSETS_H__"; \ | |
69 | + echo "/*"; \ | |
70 | + echo " * DO NOT MODIFY."; \ | |
71 | + echo " *"; \ | |
72 | + echo " * This file was generated by Kbuild"; \ | |
73 | + echo " *"; \ | |
74 | + echo " */"; \ | |
75 | + echo ""; \ | |
76 | + sed -ne $(sed-y) $<; \ | |
77 | + echo ""; \ | |
78 | + echo "#endif" ) > $@ | |
79 | +endef | |
80 | + | |
81 | +# We use internal kbuild rules to avoid the "is up to date" message from make | |
82 | +$(CPUDIR)/$(SOC)/asm-offsets.s: $(CPUDIR)/$(SOC)/asm-offsets.c FORCE | |
83 | + $(Q)mkdir -p $(dir $@) | |
84 | + $(call if_changed_dep,cc_s_c) | |
85 | + | |
86 | +$(obj)/$(offsets-file): $(CPUDIR)/$(SOC)/asm-offsets.s | |
87 | + $(call cmd,offsets) |
Makefile
... | ... | @@ -988,9 +988,8 @@ |
988 | 988 | |
989 | 989 | archprepare: prepare1 scripts_basic |
990 | 990 | |
991 | -prepare0: archprepare FORCE include/generated/generic-asm-offsets.h \ | |
992 | - include/generated/asm-offsets.h | |
993 | - @: | |
991 | +prepare0: archprepare FORCE | |
992 | + $(Q)$(MAKE) $(build)=. | |
994 | 993 | |
995 | 994 | # All the preparing.. |
996 | 995 | prepare: prepare0 |
... | ... | @@ -1114,37 +1113,6 @@ |
1114 | 1113 | echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \ |
1115 | 1114 | false; \ |
1116 | 1115 | fi |
1117 | - | |
1118 | -quiet_cmd_offsets = GEN $@ | |
1119 | - cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@ | |
1120 | - | |
1121 | -include/generated/generic-asm-offsets.h: lib/asm-offsets.s | |
1122 | - $(call cmd,offsets) | |
1123 | - | |
1124 | -quiet_cmd_asm-offsets.s = CC $@ | |
1125 | - cmd_asm-offsets.s = mkdir -p lib; \ | |
1126 | - $(CC) -DDO_DEPS_ONLY \ | |
1127 | - $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ | |
1128 | - -o $@ $< -c -S | |
1129 | - | |
1130 | -lib/asm-offsets.s: $(srctree)/lib/asm-offsets.c include/config.h | |
1131 | - $(call cmd,asm-offsets.s) | |
1132 | - | |
1133 | -include/generated/asm-offsets.h: $(CPUDIR)/$(SOC)/asm-offsets.s | |
1134 | - $(call cmd,offsets) | |
1135 | - | |
1136 | -quiet_cmd_soc_asm-offsets.s = CC $@ | |
1137 | - cmd_soc_asm-offsets.s = mkdir -p $(CPUDIR)/$(SOC); \ | |
1138 | - if [ -f $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c ];then \ | |
1139 | - $(CC) -DDO_DEPS_ONLY \ | |
1140 | - $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ | |
1141 | - -o $@ $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \ | |
1142 | - else \ | |
1143 | - touch $@; \ | |
1144 | - fi | |
1145 | - | |
1146 | -$(CPUDIR)/$(SOC)/asm-offsets.s: include/config.h | |
1147 | - $(call cmd,soc_asm-offsets.s) | |
1148 | 1116 | |
1149 | 1117 | ######################################################################### |
1150 | 1118 |
tools/scripts/make-asm-offsets
1 | -#!/bin/sh | |
2 | - | |
3 | -# Adapted from Linux kernel's "Kbuild": | |
4 | -# commit 1cdf25d704f7951d02a04064c97db547d6021872 | |
5 | -# Author: Christoph Lameter <clameter@sgi.com> | |
6 | - | |
7 | -mkdir -p $(dirname $2) | |
8 | - | |
9 | -# Default sed regexp - multiline due to syntax constraints | |
10 | -SED_CMD="/^->/{s:->#\(.*\):/* \1 */:; \ | |
11 | - s:^->\([^ ]*\) [\$#]*\([-0-9]*\) \(.*\):#define \1 (\2) /* \3 */:; \ | |
12 | - s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ | |
13 | - s:->::; p;}" | |
14 | - | |
15 | -(set -e | |
16 | - echo "#ifndef __ASM_OFFSETS_H__" | |
17 | - echo "#define __ASM_OFFSETS_H__" | |
18 | - echo "/*" | |
19 | - echo " * DO NOT MODIFY." | |
20 | - echo " *" | |
21 | - echo " * This file was generated by $(basename $0)" | |
22 | - echo " *" | |
23 | - echo " */" | |
24 | - echo "" | |
25 | - sed -ne "${SED_CMD}" $1 | |
26 | - echo "" | |
27 | - echo "#endif" ) > $2 |