tools build: Support compiling C++ source file
authorWang Nan <wangnan0@huawei.com>
Mon, 26 Sep 2016 07:26:55 +0000 (07:26 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 5 Oct 2016 22:58:51 +0000 (19:58 -0300)
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>
tools/build/Build.include
tools/build/Makefile.build

index 02489380d79b0bb8d771d66727852c40255fd7cf..1dcb95e76f70f7ec30b964d44c1c28586fa739a2 100644 (file)
@@ -90,6 +90,7 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)),             \
 # - per object C flags
 # - BUILD_STR macro to allow '-D"$(variable)"' constructs
 c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
+cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
 
 ###
 ## HOSTCC C flags
index 190519a94ce561d2929e2f56f48edc95ac8f2773..99c0ccd2f176592c03140d8e92671ba78aeac8e0 100644 (file)
@@ -61,6 +61,9 @@ quiet_cmd_cc_o_c = CC       $@
 quiet_cmd_host_cc_o_c = HOSTCC   $@
       cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $<
 
+quiet_cmd_cxx_o_c = CXX      $@
+      cmd_cxx_o_c = $(CXX) $(cxx_flags) -c -o $@ $<
+
 quiet_cmd_cpp_i_c = CPP      $@
       cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $<
 
@@ -88,6 +91,10 @@ $(OUTPUT)%.o: %.c FORCE
        $(call rule_mkdir)
        $(call if_changed_dep,$(host)cc_o_c)
 
+$(OUTPUT)%.o: %.cpp FORCE
+       $(call rule_mkdir)
+       $(call if_changed_dep,cxx_o_c)
+
 $(OUTPUT)%.o: %.S FORCE
        $(call rule_mkdir)
        $(call if_changed_dep,$(host)cc_o_c)