The cxx_compiler function should not blindly return clang++ as the C++ compiler if $(CC) contains "clang".

Instead, it should perform a textual replacement of $(CC) from "clang" to "clang++".  The same is true
for "llvm-gcc" to "llvm-g++" and for "gcc" to "g++".  This way, we keep the path component of the $(CC)
passed in from the user and do not end up with a mixed toolchains with different paths.

Ditto for a newly added function called cxx_linker.

llvm-svn: 123451
This commit is contained in:
Johnny Chen 2011-01-14 18:19:53 +00:00
parent 9f40713ebc
commit bdb4efcf17
1 changed files with 7 additions and 4 deletions

View File

@ -31,8 +31,11 @@ OBJECTS =
EXE = a.out
DSYM = $(EXE).dSYM
# Function that returns the counterpart C++ compiler.
cxx_compiler = $(if $(findstring clang,$(1)), clang++, $(if $(findstring llvm-gcc,$(1)), llvm-g++, g++))
# Function that returns the counterpart C++ compiler, given $(CC) as arg.
cxx_compiler = $(if $(findstring clang,$(1)), $(subst clang,clang++,$(1)), $(if $(findstring llvm-gcc,$(1)), $(subst llvm-gcc,llvm-g++,$(1)), $(subst gcc,g++,$(1))))
# Function that returns the C++ linker, given $(CC) as arg.
cxx_linker = $(if $(findstring clang,$(1)), $(subst clang,g++,$(1)), $(if $(findstring llvm-gcc,$(1)), $(subst llvm-gcc,g++,$(1)), $(subst gcc,g++,$(1))))
#----------------------------------------------------------------------
# dylib settings
@ -55,7 +58,7 @@ endif
ifneq "$(strip $(CXX_SOURCES))" ""
OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o))
CXX = $(call cxx_compiler,$(CC))
LD = g++
LD = $(call cxx_linker,$(CC))
endif
#----------------------------------------------------------------------
@ -72,7 +75,7 @@ endif
ifneq "$(strip $(OBJCXX_SOURCES))" ""
OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))
CXX = $(call cxx_compiler,$(CC))
LD = g++
LD = $(call cxx_linker,$(CC))
ifeq $(findstring lobjc,$(LDFLAGS)) ""
LDFLAGS +=-lobjc
endif