gen-android-sdk-toolchain.sh: Add --print=<tool> option.

This adds an option to the script to dump the name of a host-specific
tool (e.g. 'x86_64-linux-gcc', with --tool=gcc). The <tool> value
can also be 'binprefix' to print the binprefix only.
diff --git a/scripts/gen-android-sdk-toolchain.sh b/scripts/gen-android-sdk-toolchain.sh
index d1e9509..1e0cedf 100755
--- a/scripts/gen-android-sdk-toolchain.sh
+++ b/scripts/gen-android-sdk-toolchain.sh
@@ -24,6 +24,7 @@
 OPT_HOST=
 OPT_NO_CCACHE=
 OPT_PREFIX=
+OPT_PRINT=
 
 for OPT; do
     OPTARG=$(expr "x$OPT" : "x[^=]*=\\(.*\\)" || true)
@@ -49,6 +50,9 @@
         --prefix=*)
             OPT_PREFIX=$OPTARG
             ;;
+        --print=*)
+            OPT_PRINT=$OPTARG
+            ;;
         --quiet)
             decrement_verbosity
             ;;
@@ -83,7 +87,16 @@
 If you have the 'ccache' program installed, the wrapper will use it
 automatically unless you use the --no-ccache option.
 
-The script will put under <install-dir>/bin/ various 
+The script will put under <install-dir>/ various tools, e.g.
+'x86_64-linux-c++' for the 64-bit Linux compiler.
+
+You can use the --print=<tool> option to print the corresponding name
+or path, *instead* of creating a toolchain. Valid values for <tool> are:
+
+   binprefix       -> Print the binprefix (e.g. 'x86_64-linux-')
+   cc              -> Print the compiler name (e.g. 'x86_64_linux-cc')
+   c++             -> Print the c++ compiler name.
+   ld, ar, as, ... -> Same for other tools.
 
 Valid options:
     --help|-?            Print this message.
@@ -93,6 +106,9 @@
     --binprefix=<prefix> Specify toolchain binprefix [autodetected].
     --host=<system>      Host system to support.
     --prefix=<prefix>    Specify extra include/lib prefix.
+    --print=<tool>       Don't create toolchain, print the corresponding
+                         tool. Note: If <tool> is 'binprefix', then only
+                         prints the binprefix.
     --ccache=<program>   Use specific ccache binary [autodetected].
     --no-ccache          Don't try to probe and use ccache.
 
@@ -404,12 +420,27 @@
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$OPT_PREFIX/lib"
     fi
 
-    if [ "$BINPREFIX" ]; then
-      log "$CURRENT_TEXT Generating ${BINPREFIX%%-} wrapper toolchain in $INSTALL_DIR"
+    if [ "$OPT_PRINT" ]; then
+        # If $BINPREFIX is not empty, ensure it has a trailing -.
+        if [ "$BINPREFIX" ]; then
+            BINPREFIX=${BINPREFIX%%-}-
+        fi
+        case $OPT_PRINT in
+            binprefix)
+                printf "%s\n" "$BINPREFIX"
+                ;;
+            *)
+                printf "%s\n" "${BINPREFIX}$OPT_PRINT"
+                ;;
+        esac
     else
-      log "$CURRENT_TEXT Generating host wrapper toolchain in $INSTALL_DIR"
+        if [ "$BINPREFIX" ]; then
+            log "$CURRENT_TEXT Generating ${BINPREFIX%%-} wrapper toolchain in $INSTALL_DIR"
+        else
+            log "$CURRENT_TEXT Generating host wrapper toolchain in $INSTALL_DIR"
+        fi
+        gen_wrapper_toolchain "$BINPREFIX" "$PREBUILT_TOOLCHAIN_DIR/bin/$TOOLCHAIN_PREFIX" "$INSTALL_DIR"
     fi
-    gen_wrapper_toolchain "$BINPREFIX" "$PREBUILT_TOOLCHAIN_DIR/bin/$TOOLCHAIN_PREFIX" "$INSTALL_DIR"
 }
 
 prepare_build_for_host $HOST