package-release.sh: Add --darwin-ssh=<host> option

It is now possible to package Darwin binaries from Linux,
using SSH to connect to a remote host where the build will
happen. To do so, use --darwin-ssh=<host>.

Alternatively, one can define ANDROID_EMULATOR_DARWIN_SSH
in its environment to get the same effect by default.

+ android-configure.sh: Always try to use the host ccache,
  if available, if USE_CCACHE is not set to 0. Useful to
  speed up remote builds.

+ android-configure.sh/android-rebuild.sh will strip all
  generated binaries, unless --debug is used.

+ Properly cleanup temporary files created by android-configure.sh
  to avoid polluting /tmp with android-<pid>-test* files.

Change-Id: If4147d35e55ca393463e2f1084841f02bac1fd63
diff --git a/android-configure.sh b/android-configure.sh
index 12ed942..1f2c4d1 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -218,7 +218,7 @@
             ;;
     esac
 else
-    if [ -n "$USE_CCACHE" ]; then
+    if [ "$USE_CCACHE" != 0 ]; then
         CCACHE=$(which ccache 2>/dev/null)
     fi
     GLES_PROBE_OS=$TARGET_OS
@@ -448,6 +448,7 @@
             eval $1=no
             log "AudioProbe : $2 seems to be UNUSABLE on this system !!"
         fi
+        clean_temp
     fi
 }
 
@@ -472,7 +473,7 @@
 ####
 
 # because the previous version could be read-only
-rm -f $TMPC
+clean_temp
 
 # check host endianess
 #
@@ -517,6 +518,18 @@
         ;;
 esac
 
+# Strip executables and shared libraries unless --debug is used.
+if [ "$OPTION_DEBUG" != "yes" ]; then
+    case $HOST_OS in
+        darwin)
+            LDFLAGS="$LDFLAGS -Wl,-S"
+            ;;
+        *)
+            LDFLAGS="$LDFLAGS -Wl,--strip-all"
+            ;;
+    esac
+fi
+
 create_config_mk
 echo "" >> $config_mk
 echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk
@@ -693,4 +706,6 @@
 python scripts/qapi-commands.py --output-dir=$AUTOGENERATED_DIR -m < qapi-schema.json
 log "Generate   : $AUTOGENERATED_DIR"
 
+clean_temp
+
 echo "Ready to go. Type 'make' to build emulator"