aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2010-03-08 18:33:50 -0800
committerDavid 'Digit' Turner <digit@google.com>2010-03-08 18:33:50 -0800
commitab873b750621bca7eef41869c685dec8c363333a (patch)
tree94ea3d5e4634e4346280be35cd8ed80414a1b614
parent9a0f1fba0cacee05513653a553052e97e475b51c (diff)
downloadexternal_qemu-ab873b750621bca7eef41869c685dec8c363333a.zip
external_qemu-ab873b750621bca7eef41869c685dec8c363333a.tar.gz
external_qemu-ab873b750621bca7eef41869c685dec8c363333a.tar.bz2
Add --static option to android-configure.sh in order to build static emulator executable.
This is needed to run the emulator in restricted environment where libX11.so and even libstdc++.so are not available. Only tested on Linux. The resulting binary will not start unless you use -no-window. Also don't expect any audio output working. Change-Id: Ia736898cd3ae6eb928614a00a1a3e18cc8086a5c
-rw-r--r--Makefile.android9
-rwxr-xr-xandroid-configure.sh13
-rw-r--r--dynlink-static.c49
3 files changed, 70 insertions, 1 deletions
diff --git a/Makefile.android b/Makefile.android
index a5385d4..1929cb3 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -625,7 +625,6 @@ endif
ifeq ($(HOST_OS),linux)
VL_SOURCES += usb-linux.c \
qemu-thread.c
- LOCAL_LDLIBS += -lX11
else
VL_SOURCES += usb-dummy-android.c
endif
@@ -769,6 +768,14 @@ endif
LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
+# Generate a completely static executable if needed.
+# Note that this means no sound and graphics on Linux.
+#
+ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
+ LOCAL_SRC_FILES += dynlink-static.c
+ LOCAL_LDLIBS += -static
+endif
+
LOCAL_MODULE := emulator
include $(BUILD_HOST_EXECUTABLE)
diff --git a/android-configure.sh b/android-configure.sh
index 742fe21..045e56d 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -28,6 +28,7 @@ OPTION_NO_PREBUILTS=no
OPTION_TRY_64=no
OPTION_HELP=no
OPTION_DEBUG=no
+OPTION_STATIC=no
if [ -z "$CC" ] ; then
CC=gcc
@@ -63,6 +64,8 @@ for opt do
;;
--try-64) OPTION_TRY_64=yes
;;
+ --static) OPTION_STATIC=yes
+ ;;
*)
echo "unknown option '$opt', use --help"
exit 1
@@ -87,6 +90,7 @@ EOF
echo " --ignore-audio ignore audio messages (may build sound-less emulator)"
echo " --no-prebuilts do not use prebuilt libraries and compiler"
echo " --try-64 try to build a 64-bit executable (may crash)"
+ echo " --static build a completely static executable"
echo " --verbose verbose configuration"
echo " --debug build debug version of the emulator"
echo ""
@@ -394,6 +398,10 @@ echo "BUILD_STANDALONE_EMULATOR := true" >> $config_mk
if [ $OPTION_DEBUG = yes ] ; then
echo "BUILD_DEBUG_EMULATOR := true" >> $config_mk
fi
+if [ $OPTION_STATIC = yes ] ; then
+ echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
+fi
+
if [ -n "$ANDROID_SDK_TOOLS_REVISION" ] ; then
echo "ANDROID_SDK_TOOLS_REVISION := $ANDROID_SDK_TOOLS_REVISION" >> $config_mk
fi
@@ -443,6 +451,11 @@ case "$OS" in
*) CONFIG_OS=$OS
esac
+if [ "$OPTION_STATIC" = "yes" ] ; then
+ echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
+ echo "#define CONFIG_STATIC_EXECUTABLE 1" >> $config_h
+fi
+
case $OS in
linux-*|darwin-*)
echo "#define HAVE_IOVEC 1" >> $config_h
diff --git a/dynlink-static.c b/dynlink-static.c
new file mode 100644
index 0000000..420f847
--- /dev/null
+++ b/dynlink-static.c
@@ -0,0 +1,49 @@
+/* Copyright (c) 2010 The Android Open Source Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/* dummy dlopen()/dlclose()/dlsym() implementations to be used in static builds */
+#include <stddef.h>
+
+void* dlopen(void)
+{
+ /* Do not return NULL to route around a bug in our SDL configure script */
+ /* mimick succesful load, then all calls to dlsym/dlvsym will fail */
+ return (void*)"XXX";
+}
+
+void dlclose(void)
+{
+}
+
+void* dlsym(void)
+{
+ return NULL;
+}
+
+void* dlvsym(void)
+{
+ return NULL;
+}
+
+const char* dlerror(void)
+{
+ return "Dynamic linking not enabled !";
+}