Skip to content

Commit

Permalink
TOOLS: Fix configure compiler tests when cross-compiling.
Browse files Browse the repository at this point in the history
This is a sync to the scummvm configure script functions and may require
further changes, but trying to ensure native compilation is not
affected.
  • Loading branch information
digitall committed Nov 23, 2012
1 parent 36cb689 commit 683ae8b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions configure
Expand Up @@ -509,7 +509,7 @@ echo_n "Looking for C++ compiler... "

# Check whether the given command is a working C++ compiler
test_compiler() {
cat <<EOF >tmp_cxx_compiler.cpp
cat > tmp_cxx_compiler.cpp << EOF
class Foo { int a; };
int main(int argc, char **argv) {
Foo *a = new Foo(); delete a; return 0;
Expand All @@ -518,15 +518,24 @@ EOF

echo "testing compiler: $1" >> "$TMPLOG"

eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp
if test -n "$_host"; then
# In cross-compiling mode, we cannot run the result
eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO.o -c tmp_cxx_compiler.cpp" 2> /dev/null && cc_check_clean tmp_cxx_compiler.cpp
else
eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp
fi
}

# Prepare a list of candidates for the C++ compiler
if test -n "$CXX" && test_compiler "$CXX"; then
# Use the compiler specified in CXX
echo $CXX
else
compilers="g++ c++"
if test -n "$_host"; then
compilers="$_host_alias-g++ $_host_alias-c++ $_host-g++ $_host-c++"
else
compilers="g++ c++"
fi

# Iterate over all candidates, pick the first working one
CXX=
Expand Down

0 comments on commit 683ae8b

Please sign in to comment.