summaryrefslogtreecommitdiff
path: root/tools/build/Makefile.build
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2016-09-27 17:18:46 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-10-03 17:39:09 +0300
commit0c3b7e42616f1f6084cfeb0d443cbff0b2c424a9 (patch)
tree097ca8b3055dcc3e7a935413dc78eb32b1934cec /tools/build/Makefile.build
parent18ef15c675a5d5d97f844ebcf340a2a6c7cf3142 (diff)
downloadlinux-0c3b7e42616f1f6084cfeb0d443cbff0b2c424a9.tar.xz
tools build: Add support for host programs format
In some cases, like for fixdep and shortly for jevents, we need to build a tool to run on the host that will be used in building a tool, such as perf, that is being cross compiled, so do like the kernel and provide HOSTCC, HOSTLD and HOSTAR to do that. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Requested-by: Andi Kleen <andi@firstfloor.org> Requested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> Cc: linuxppc-dev@lists.ozlabs.org Link: http://lkml.kernel.org/r/20160927141846.GA6589@krava Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/build/Makefile.build')
-rw-r--r--tools/build/Makefile.build19
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build
index 27f3583193e6..190519a94ce5 100644
--- a/tools/build/Makefile.build
+++ b/tools/build/Makefile.build
@@ -58,6 +58,9 @@ quiet_cmd_mkdir = MKDIR $(dir $@)
quiet_cmd_cc_o_c = CC $@
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
+quiet_cmd_host_cc_o_c = HOSTCC $@
+ cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $<
+
quiet_cmd_cpp_i_c = CPP $@
cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $<
@@ -70,16 +73,24 @@ quiet_cmd_gen = GEN $@
# If there's nothing to link, create empty $@ object.
quiet_cmd_ld_multi = LD $@
cmd_ld_multi = $(if $(strip $(obj-y)),\
- $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
+ $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
+
+quiet_cmd_host_ld_multi = HOSTLD $@
+ cmd_host_ld_multi = $(if $(strip $(obj-y)),\
+ $(HOSTLD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@)
+
+ifneq ($(filter $(obj),$(hostprogs)),)
+ host = host_
+endif
# Build rules
$(OUTPUT)%.o: %.c FORCE
$(call rule_mkdir)
- $(call if_changed_dep,cc_o_c)
+ $(call if_changed_dep,$(host)cc_o_c)
$(OUTPUT)%.o: %.S FORCE
$(call rule_mkdir)
- $(call if_changed_dep,cc_o_c)
+ $(call if_changed_dep,$(host)cc_o_c)
$(OUTPUT)%.i: %.c FORCE
$(call rule_mkdir)
@@ -119,7 +130,7 @@ $(sort $(subdir-obj-y)): $(subdir-y) ;
$(in-target): $(obj-y) FORCE
$(call rule_mkdir)
- $(call if_changed,ld_multi)
+ $(call if_changed,$(host)ld_multi)
__build: $(in-target)
@: