Merge "build-host-gcc.sh: --build-dir option"
diff --git a/build/tools/build-host-gcc.sh b/build/tools/build-host-gcc.sh
index a5a52ab..bb17d81 100755
--- a/build/tools/build-host-gcc.sh
+++ b/build/tools/build-host-gcc.sh
@@ -127,6 +127,9 @@
 NDK_DIR=$ANDROID_NDK_ROOT
 register_var_option "--ndk-dir=<path>" NDK_DIR "Select NDK install directory"
 
+BUILD_DIR=
+register_var_option "--build-dir=<path>" BUILD_DIR "Build GCC into directory"
+
 PACKAGE_DIR=
 register_var_option "--package-dir=<path>" PACKAGE_DIR "Package prebuilt tarballs into directory"
 
@@ -174,6 +177,10 @@
     panic "Please use --toolchain-src-dir=<path> to select toolchain source directory."
 fi
 
+if [ -z "$BUILD_DIR" ]; then
+    BUILD_DIR=/tmp/ndk-$USER/build/host-gcc
+fi
+
 case $DEFAULT_LD in
     gold|bfd)
       ;;
@@ -451,7 +458,6 @@
 
 setup_build ()
 {
-    BUILD_DIR=/tmp/ndk-$USER/build/host-gcc
     run_on_setup mkdir -p "$BUILD_DIR"
     if [ -n "$FORCE" ]; then
         rm -rf "$BUILD_DIR"/*