aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xandroid-configure.sh39
-rw-r--r--android/build/common.sh70
2 files changed, 102 insertions, 7 deletions
diff --git a/android-configure.sh b/android-configure.sh
index 1cf5008..50119db 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -24,6 +24,7 @@ OPTION_TRY_64=no
OPTION_HELP=no
OPTION_DEBUG=no
OPTION_STATIC=no
+OPTION_MINGW=no
if [ -z "$CC" ] ; then
CC=gcc
@@ -47,6 +48,8 @@ for opt do
;;
--sdl-config=*) SDL_CONFIG=$optarg
;;
+ --mingw) OPTION_MINGW=yes
+ ;;
--cc=*) CC="$optarg" ; HOSTCC=$CC
;;
--no-strip) OPTION_NO_STRIP=yes
@@ -85,6 +88,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 " --mingw build Windows executable on Linux"
echo " --static build a completely static executable"
echo " --verbose verbose configuration"
echo " --debug build debug version of the emulator"
@@ -100,6 +104,14 @@ if [ "$OPTION_TRY_64" != "yes" ] ; then
force_32bit_binaries
fi
+TARGET_OS=$OS
+if [ "$OPTION_MINGW" == "yes" ] ; then
+ enable_linux_mingw
+ TARGET_OS=windows
+else
+ enable_cygwin
+fi
+
# Are we running in the Android build system ?
check_android_build
@@ -248,7 +260,7 @@ PROBE_OSS=no
PROBE_ESD=no
PROBE_WINAUDIO=no
-case "$OS" in
+case "$TARGET_OS" in
darwin*) PROBE_COREAUDIO=yes;
;;
linux-*) PROBE_ALSA=yes; PROBE_OSS=yes; PROBE_ESD=yes;
@@ -324,6 +336,7 @@ rm -f $TMPC
# check host endianess
#
HOST_BIGENDIAN=no
+if [ "$TARGET_OS" = "$OS" ] ; then
cat > $TMPC << EOF
#include <inttypes.h>
int main(int argc, char ** argv){
@@ -332,14 +345,18 @@ int main(int argc, char ** argv){
}
EOF
feature_run_exec HOST_BIGENDIAN
+fi
# check size of host long bits
+HOST_LONGBITS=32
+if [ "$TARGET_OS" = "$OS" ] ; then
cat > $TMPC << EOF
int main(void) {
return sizeof(void*)*8;
}
EOF
feature_run_exec HOST_LONGBITS
+fi
# check whether we have <byteswap.h>
#
@@ -349,10 +366,12 @@ feature_check_header HAVE_BYTESWAP_H "<byteswap.h>"
#
create_config_mk
-add_android_config_mk
+echo "" >> $config_mk
+echo "TARGET_ARCH := arm" >> $config_mk
+echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk
+echo "PREBUILT := $ANDROID_PREBUILT" >> $config_mk
PWD=`pwd`
-echo "TARGET_ARCH := arm" >> $config_mk
echo "SRC_PATH := $PWD" >> $config_mk
if [ -n "$SDL_CONFIG" ] ; then
echo "SDL_CONFIG := $SDL_CONFIG" >> $config_mk
@@ -374,6 +393,12 @@ if [ -n "$ANDROID_SDK_TOOLS_REVISION" ] ; then
echo "ANDROID_SDK_TOOLS_REVISION := $ANDROID_SDK_TOOLS_REVISION" >> $config_mk
fi
+if [ "$OPTION_MINGW" = "yes" ] ; then
+ echo "" >> $config_mk
+ echo "USE_MINGW := 1" >> $config_mk
+ echo "HOST_OS := windows" >> $config_mk
+fi
+
# Build the config-host.h file
#
config_h=objs/config-host.h
@@ -389,14 +414,14 @@ echo "#define CONFIG_SKINS 1" >> $config_h
echo "#define CONFIG_TRACE 1" >> $config_h
# only Linux has fdatasync()
-case "$OS" in
+case "$TARGET_OS" in
linux-*)
echo "#define CONFIG_FDATASYNC 1" >> $config_h
;;
esac
# the -nand-limits options can only work on non-windows systems
-if [ "$OS" != "windows" ] ; then
+if [ "$TARGET_OS" != "windows" ] ; then
echo "#define CONFIG_NAND_LIMITS 1" >> $config_h
fi
echo "#define QEMU_VERSION \"0.10.50\"" >> $config_h
@@ -413,7 +438,7 @@ case "$CPU" in
esac
echo "#define HOST_$CONFIG_CPU 1" >> $config_h
BSD=0
-case "$OS" in
+case "$TARGET_OS" in
linux-*) CONFIG_OS=LINUX
;;
darwin-*) CONFIG_OS=DARWIN
@@ -432,7 +457,7 @@ if [ "$OPTION_STATIC" = "yes" ] ; then
echo "#define CONFIG_STATIC_EXECUTABLE 1" >> $config_h
fi
-case $OS in
+case $TARGET_OS in
linux-*|darwin-*)
echo "#define CONFIG_IOVEC 1" >> $config_h
;;
diff --git a/android/build/common.sh b/android/build/common.sh
index 289e74a..6c62977 100644
--- a/android/build/common.sh
+++ b/android/build/common.sh
@@ -190,6 +190,34 @@ force_32bit_binaries ()
fi
}
+# Enable linux-mingw32 compilation. This allows you to build
+# windows executables on a Linux machine, which is considerably
+# faster than using Cygwin / MSys to do the same job.
+#
+enable_linux_mingw ()
+{
+ # Are we on Linux ?
+ log "Mingw : Checking for Linux host"
+ if [ "$HOST_OS" != "linux" ] ; then
+ echo "Sorry, but mingw compilation is only supported on Linux !"
+ exit 1
+ fi
+ # Do we have the binaries installed
+ log "Mingw : Checking for mingw32 installation"
+ MINGW32_PREFIX=i586-mingw32msvc
+ find_program MINGW32_CC $MINGW32_PREFIX-gcc
+ if [ -z "$MINGW32_CC" ] ; then
+ echo "ERROR: It looks like $MINGW32_PREFIX-gcc is not in your path"
+ echo "Please install the mingw32 package !"
+ exit 1
+ fi
+ log2 "Mingw : Found $MINGW32_CC"
+ CC=$MINGW32_CC
+ LD=$MINGW32_CC
+ AR=$MINGW32_PREFIX-ar
+ FORCE_32BIT=no
+}
+
# Cygwin is normally not supported, unless you call this function
#
enable_cygwin ()
@@ -265,6 +293,11 @@ EOF
fi
fi
log "LD : linker check ok ($LD)"
+
+ if [ -z "$AR" ]; then
+ AR=ar
+ fi
+ log "AR : archiver ($AR)"
}
# try to compile the current source file in $TMPC into an object
@@ -512,6 +545,7 @@ create_config_mk ()
echo "CC := $CC" >> $config_mk
echo "HOST_CC := $CC" >> $config_mk
echo "LD := $LD" >> $config_mk
+ echo "AR := $AR" >> $config_mk
echo "CFLAGS := $CFLAGS" >> $config_mk
echo "LDFLAGS := $LDFLAGS" >> $config_mk
}
@@ -523,3 +557,39 @@ add_android_config_mk ()
echo "HOST_PREBUILT_TAG := $HOST_TAG" >> $config_mk
echo "PREBUILT := $ANDROID_PREBUILT" >> $config_mk
}
+
+# Find pattern $1 in string $2
+# This is to be used in if statements as in:
+#
+# if pattern_match <pattern> <string>; then
+# ...
+# fi
+#
+pattern_match ()
+{
+ echo "$2" | grep -q -E -e "$1"
+}
+
+# Find if a given shell program is available.
+# We need to take care of the fact that the 'which <foo>' command
+# may return either an empty string (Linux) or something like
+# "no <foo> in ..." (Darwin). Also, we need to redirect stderr
+# to /dev/null for Cygwin
+#
+# $1: variable name
+# $2: program name
+#
+# Result: set $1 to the full path of the corresponding command
+# or to the empty/undefined string if not available
+#
+find_program ()
+{
+ local PROG
+ PROG=`which $2 2>/dev/null`
+ if [ -n "$PROG" ] ; then
+ if pattern_match '^no ' "$PROG"; then
+ PROG=
+ fi
+ fi
+ eval $1="$PROG"
+}