diff options
author | Wang Nan <wangnan0@huawei.com> | 2016-09-26 03:26:55 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-10-05 18:58:51 -0400 |
commit | f61bdc3304281e9ff9eec4f1ed9fb15bcf4d8a5e (patch) | |
tree | 039e05791992e7c49ceadfbf52535f4d7ecef481 | |
parent | 2ad8327fd0013ee07f056d28faddc2e7f01dd127 (diff) |
tools build: Support compiling C++ source file
Add new rule to compile .cpp file to .o use g++. C++ support is required
for built-in clang and LLVM support.
Linker side support will be introduced by following commits.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1474874832-134786-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/build/Build.include | 1 | ||||
-rw-r--r-- | tools/build/Makefile.build | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/tools/build/Build.include b/tools/build/Build.include index 02489380d79b..1dcb95e76f70 100644 --- a/tools/build/Build.include +++ b/tools/build/Build.include | |||
@@ -90,6 +90,7 @@ 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 |
92 | c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj)) | 92 | c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj)) |
93 | cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj)) | ||
93 | 94 | ||
94 | ### | 95 | ### |
95 | ## HOSTCC C flags | 96 | ## HOSTCC C flags |
diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build index 190519a94ce5..99c0ccd2f176 100644 --- a/tools/build/Makefile.build +++ b/tools/build/Makefile.build | |||
@@ -61,6 +61,9 @@ quiet_cmd_cc_o_c = CC $@ | |||
61 | quiet_cmd_host_cc_o_c = HOSTCC $@ | 61 | quiet_cmd_host_cc_o_c = HOSTCC $@ |
62 | cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $< | 62 | cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $< |
63 | 63 | ||
64 | quiet_cmd_cxx_o_c = CXX $@ | ||
65 | cmd_cxx_o_c = $(CXX) $(cxx_flags) -c -o $@ $< | ||
66 | |||
64 | quiet_cmd_cpp_i_c = CPP $@ | 67 | quiet_cmd_cpp_i_c = CPP $@ |
65 | cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $< | 68 | cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $< |
66 | 69 | ||
@@ -88,6 +91,10 @@ $(OUTPUT)%.o: %.c FORCE | |||
88 | $(call rule_mkdir) | 91 | $(call rule_mkdir) |
89 | $(call if_changed_dep,$(host)cc_o_c) | 92 | $(call if_changed_dep,$(host)cc_o_c) |
90 | 93 | ||
94 | $(OUTPUT)%.o: %.cpp FORCE | ||
95 | $(call rule_mkdir) | ||
96 | $(call if_changed_dep,cxx_o_c) | ||
97 | |||
91 | $(OUTPUT)%.o: %.S FORCE | 98 | $(OUTPUT)%.o: %.S FORCE |
92 | $(call rule_mkdir) | 99 | $(call rule_mkdir) |
93 | $(call if_changed_dep,$(host)cc_o_c) | 100 | $(call if_changed_dep,$(host)cc_o_c) |