aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2016-09-27 10:18:46 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-10-03 10:39:09 -0400
commit0c3b7e42616f1f6084cfeb0d443cbff0b2c424a9 (patch)
tree097ca8b3055dcc3e7a935413dc78eb32b1934cec
parent18ef15c675a5d5d97f844ebcf340a2a6c7cf3142 (diff)
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>
-rw-r--r--tools/build/Build.include5
-rw-r--r--tools/build/Makefile6
-rw-r--r--tools/build/Makefile.build19
3 files changed, 26 insertions, 4 deletions
diff --git a/tools/build/Build.include b/tools/build/Build.include
index 4d000bc959b4..02489380d79b 100644
--- a/tools/build/Build.include
+++ b/tools/build/Build.include
@@ -90,3 +90,8 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
90# - per object C flags 90# - per object C flags
91# - BUILD_STR macro to allow '-D"$(variable)"' constructs 91# - BUILD_STR macro to allow '-D"$(variable)"' constructs
92c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj)) 92c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
93
94###
95## HOSTCC C flags
96
97host_c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CHOSTFLAGS) -D"BUILD_STR(s)=\#s" $(CHOSTFLAGS_$(basetarget).o) $(CHOSTFLAGS_$(obj))
diff --git a/tools/build/Makefile b/tools/build/Makefile
index 0d5a0e3a8fa9..653faee2a055 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -14,6 +14,12 @@ endef
14$(call allow-override,CC,$(CROSS_COMPILE)gcc) 14$(call allow-override,CC,$(CROSS_COMPILE)gcc)
15$(call allow-override,LD,$(CROSS_COMPILE)ld) 15$(call allow-override,LD,$(CROSS_COMPILE)ld)
16 16
17HOSTCC ?= gcc
18HOSTLD ?= ld
19HOSTAR ?= ar
20
21export HOSTCC HOSTLD HOSTAR
22
17ifeq ($(V),1) 23ifeq ($(V),1)
18 Q = 24 Q =
19else 25else
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 $@)
58quiet_cmd_cc_o_c = CC $@ 58quiet_cmd_cc_o_c = CC $@
59 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 59 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
60 60
61quiet_cmd_host_cc_o_c = HOSTCC $@
62 cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $<
63
61quiet_cmd_cpp_i_c = CPP $@ 64quiet_cmd_cpp_i_c = CPP $@
62 cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $< 65 cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $<
63 66
@@ -70,16 +73,24 @@ quiet_cmd_gen = GEN $@
70# If there's nothing to link, create empty $@ object. 73# If there's nothing to link, create empty $@ object.
71quiet_cmd_ld_multi = LD $@ 74quiet_cmd_ld_multi = LD $@
72 cmd_ld_multi = $(if $(strip $(obj-y)),\ 75 cmd_ld_multi = $(if $(strip $(obj-y)),\
73 $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@) 76 $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
77
78quiet_cmd_host_ld_multi = HOSTLD $@
79 cmd_host_ld_multi = $(if $(strip $(obj-y)),\
80 $(HOSTLD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@)
81
82ifneq ($(filter $(obj),$(hostprogs)),)
83 host = host_
84endif
74 85
75# Build rules 86# Build rules
76$(OUTPUT)%.o: %.c FORCE 87$(OUTPUT)%.o: %.c FORCE
77 $(call rule_mkdir) 88 $(call rule_mkdir)
78 $(call if_changed_dep,cc_o_c) 89 $(call if_changed_dep,$(host)cc_o_c)
79 90
80$(OUTPUT)%.o: %.S FORCE 91$(OUTPUT)%.o: %.S FORCE
81 $(call rule_mkdir) 92 $(call rule_mkdir)
82 $(call if_changed_dep,cc_o_c) 93 $(call if_changed_dep,$(host)cc_o_c)
83 94
84$(OUTPUT)%.i: %.c FORCE 95$(OUTPUT)%.i: %.c FORCE
85 $(call rule_mkdir) 96 $(call rule_mkdir)
@@ -119,7 +130,7 @@ $(sort $(subdir-obj-y)): $(subdir-y) ;
119 130
120$(in-target): $(obj-y) FORCE 131$(in-target): $(obj-y) FORCE
121 $(call rule_mkdir) 132 $(call rule_mkdir)
122 $(call if_changed,ld_multi) 133 $(call if_changed,$(host)ld_multi)
123 134
124__build: $(in-target) 135__build: $(in-target)
125 @: 136 @: