aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2007-05-06 03:23:45 -0400
committerSam Ravnborg <sam@ravnborg.org>2007-05-06 03:23:45 -0400
commit767e581d759fe6adfef5e676cd1cd8e11f603d1a (patch)
treef208026e00ace8ba32cc4f9c1fc6168af329c167
parent5447d34b080a1e3e312b05a91e87eff4710a1152 (diff)
kbuild: enable use of code from a different dir
To introduce support for source in one directory but output files in another directory during a non O= build prefix all paths with $(src) repsectively $(obj). Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r--scripts/Makefile.build19
-rw-r--r--scripts/Makefile.host14
2 files changed, 16 insertions, 17 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index e2ad2dccccdb..a525112847fd 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -131,13 +131,13 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi)
131quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ 131quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
132cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< 132cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
133 133
134%.s: %.c FORCE 134$(obj)/%.s: $(src)/%.c FORCE
135 $(call if_changed_dep,cc_s_c) 135 $(call if_changed_dep,cc_s_c)
136 136
137quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@ 137quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@
138cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< 138cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $<
139 139
140%.i: %.c FORCE 140$(obj)/%.i: $(src)/%.c FORCE
141 $(call if_changed_dep,cc_i_c) 141 $(call if_changed_dep,cc_i_c)
142 142
143quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ 143quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
@@ -146,7 +146,7 @@ cmd_cc_symtypes_c = \
146 | $(GENKSYMS) -T $@ >/dev/null; \ 146 | $(GENKSYMS) -T $@ >/dev/null; \
147 test -s $@ || rm -f $@ 147 test -s $@ || rm -f $@
148 148
149%.symtypes : %.c FORCE 149$(obj)/%.symtypes : $(src)/%.c FORCE
150 $(call if_changed_dep,cc_symtypes_c) 150 $(call if_changed_dep,cc_symtypes_c)
151 151
152# C (.c) files 152# C (.c) files
@@ -198,14 +198,13 @@ define rule_cc_o_c
198endef 198endef
199 199
200# Built-in and composite module parts 200# Built-in and composite module parts
201 201$(obj)/%.o: $(src)/%.c FORCE
202%.o: %.c FORCE
203 $(call cmd,force_checksrc) 202 $(call cmd,force_checksrc)
204 $(call if_changed_rule,cc_o_c) 203 $(call if_changed_rule,cc_o_c)
205 204
206# Single-part modules are special since we need to mark them in $(MODVERDIR) 205# Single-part modules are special since we need to mark them in $(MODVERDIR)
207 206
208$(single-used-m): %.o: %.c FORCE 207$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE
209 $(call cmd,force_checksrc) 208 $(call cmd,force_checksrc)
210 $(call if_changed_rule,cc_o_c) 209 $(call if_changed_rule,cc_o_c)
211 @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) 210 @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
@@ -215,7 +214,7 @@ quiet_cmd_cc_lst_c = MKLST $@
215 $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ 214 $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
216 System.map $(OBJDUMP) > $@ 215 System.map $(OBJDUMP) > $@
217 216
218%.lst: %.c FORCE 217$(obj)/%.lst: $(src)/%.c FORCE
219 $(call if_changed_dep,cc_lst_c) 218 $(call if_changed_dep,cc_lst_c)
220 219
221# Compile assembler sources (.S) 220# Compile assembler sources (.S)
@@ -229,13 +228,13 @@ $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE)
229quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ 228quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
230cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< 229cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
231 230
232%.s: %.S FORCE 231$(obj)/%.s: $(src)/%.S FORCE
233 $(call if_changed_dep,as_s_S) 232 $(call if_changed_dep,as_s_S)
234 233
235quiet_cmd_as_o_S = AS $(quiet_modtag) $@ 234quiet_cmd_as_o_S = AS $(quiet_modtag) $@
236cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 235cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
237 236
238%.o: %.S FORCE 237$(obj)/%.o: $(src)/%.S FORCE
239 $(call if_changed_dep,as_o_S) 238 $(call if_changed_dep,as_o_S)
240 239
241targets += $(real-objs-y) $(real-objs-m) $(lib-y) 240targets += $(real-objs-y) $(real-objs-m) $(lib-y)
@@ -246,7 +245,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(always)
246quiet_cmd_cpp_lds_S = LDS $@ 245quiet_cmd_cpp_lds_S = LDS $@
247 cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $< 246 cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $<
248 247
249%.lds: %.lds.S FORCE 248$(obj)/%.lds: $(src)/%.lds.S FORCE
250 $(call if_changed_dep,cpp_lds_S) 249 $(call if_changed_dep,cpp_lds_S)
251 250
252# Build the compiled-in targets 251# Build the compiled-in targets
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 575afbe5e370..6943a7a5bb98 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -114,7 +114,7 @@ hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)
114quiet_cmd_host-csingle = HOSTCC $@ 114quiet_cmd_host-csingle = HOSTCC $@
115 cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \ 115 cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \
116 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) 116 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
117$(host-csingle): %: %.c FORCE 117$(host-csingle): $(obj)/%: $(src)/%.c FORCE
118 $(call if_changed_dep,host-csingle) 118 $(call if_changed_dep,host-csingle)
119 119
120# Link an executable based on list of .o files, all plain c 120# Link an executable based on list of .o files, all plain c
@@ -123,14 +123,14 @@ quiet_cmd_host-cmulti = HOSTLD $@
123 cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ 123 cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
124 $(addprefix $(obj)/,$($(@F)-objs)) \ 124 $(addprefix $(obj)/,$($(@F)-objs)) \
125 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) 125 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
126$(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE 126$(host-cmulti): $(obj)/%: $(host-cobjs) $(host-cshlib) FORCE
127 $(call if_changed,host-cmulti) 127 $(call if_changed,host-cmulti)
128 128
129# Create .o file from a single .c file 129# Create .o file from a single .c file
130# host-cobjs -> .o 130# host-cobjs -> .o
131quiet_cmd_host-cobjs = HOSTCC $@ 131quiet_cmd_host-cobjs = HOSTCC $@
132 cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< 132 cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $<
133$(host-cobjs): %.o: %.c FORCE 133$(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE
134 $(call if_changed_dep,host-cobjs) 134 $(call if_changed_dep,host-cobjs)
135 135
136# Link an executable based on list of .o files, a mixture of .c and .cc 136# Link an executable based on list of .o files, a mixture of .c and .cc
@@ -140,20 +140,20 @@ quiet_cmd_host-cxxmulti = HOSTLD $@
140 $(foreach o,objs cxxobjs,\ 140 $(foreach o,objs cxxobjs,\
141 $(addprefix $(obj)/,$($(@F)-$(o)))) \ 141 $(addprefix $(obj)/,$($(@F)-$(o)))) \
142 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) 142 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
143$(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE 143$(host-cxxmulti): $(obj)/%: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE
144 $(call if_changed,host-cxxmulti) 144 $(call if_changed,host-cxxmulti)
145 145
146# Create .o file from a single .cc (C++) file 146# Create .o file from a single .cc (C++) file
147quiet_cmd_host-cxxobjs = HOSTCXX $@ 147quiet_cmd_host-cxxobjs = HOSTCXX $@
148 cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $< 148 cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $<
149$(host-cxxobjs): %.o: %.cc FORCE 149$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE
150 $(call if_changed_dep,host-cxxobjs) 150 $(call if_changed_dep,host-cxxobjs)
151 151
152# Compile .c file, create position independent .o file 152# Compile .c file, create position independent .o file
153# host-cshobjs -> .o 153# host-cshobjs -> .o
154quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ 154quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
155 cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< 155 cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $<
156$(host-cshobjs): %.o: %.c FORCE 156$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
157 $(call if_changed_dep,host-cshobjs) 157 $(call if_changed_dep,host-cshobjs)
158 158
159# Link a shared library, based on position independent .o files 159# Link a shared library, based on position independent .o files
@@ -162,7 +162,7 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
162 cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \ 162 cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \
163 $(addprefix $(obj)/,$($(@F:.so=-objs))) \ 163 $(addprefix $(obj)/,$($(@F:.so=-objs))) \
164 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) 164 $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
165$(host-cshlib): %: $(host-cshobjs) FORCE 165$(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
166 $(call if_changed,host-cshlib) 166 $(call if_changed,host-cshlib)
167 167
168targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ 168targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\