From 46be48730333120a7b939116cef075e61c12c703 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Thu, 4 Jun 2009 16:07:01 +0200 Subject: Add our modified SDL sources under distrib/sdl-1.2.12 Fix distrib/make-distrib.sh script to work with git Fix distrib/build-emulator.sh to accomodate for new SDL configure script Handle Tiger SDK usage in SDL configure script --- android-configure.sh | 415 +++++++++++---------------------------------------- 1 file changed, 88 insertions(+), 327 deletions(-) (limited to 'android-configure.sh') diff --git a/android-configure.sh b/android-configure.sh index 7542e9b..7a94ec2 100755 --- a/android-configure.sh +++ b/android-configure.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # this script is used to rebuild the Android emulator from sources # in the current directory. It also contains logic to speed up the @@ -16,113 +16,9 @@ # first, let's see which system we're running this on cd `dirname $0` -PROGNAME=`basename $0` -# this function will be used to execute commands and eventually -# dump them if VERBOSE is 'yes' -VERBOSE=yes -VERBOSE2=no - -function log() -{ - if [ "$VERBOSE" = "yes" ] ; then - echo "$1" - fi -} - -function log2() -{ - if [ "$VERBOSE2" = "yes" ] ; then - echo "$1" - fi -} - -function execute() -{ - log2 "Running: $*" - $* -} - -function compile() -{ - log2 "Object : $CC -o $TMPO -c $CFLAGS $TMPC" - $CC -o $TMPO -c $CFLAGS $TMPC 2> $TMPL -} - -function link() -{ - log2 "Link : $LD $LDFLAGS -o $TMPE $TMPO" - $LD $LDFLAGS -o $TMPE $TMPO 2> $TMPL -} - -function compile-exec-run() -{ - log2 "RunExec : $CC -o $TMPE $CFLAGS $TMPC" - compile - if [ $? != 0 ] ; then - echo "Failure to compile test program" - cat $TMPL - exit 1 - fi - link - if [ $? != 0 ] ; then - echo "Failure to link test program" - cat $TMPL - exit 1 - fi - $TMPE -} - -OS=`uname -s` -CPU=`uname -m` -EXE="" -case "$CPU" in - i?86) CPU=x86 - ;; -esac - -case "$OS" in - Darwin) - OS=darwin-$CPU - ;; - Linux) - # note that building on x86_64 is handled later - OS=linux-$CPU - ;; - *_NT-*) - OS=windows - EXE=.exe - ;; -esac - -# Are we running in the Android build system ? -unset TOP -if [ -n "$ANDROID_PRODUCT_OUT" ] ; then - TOP=`cd $ANDROID_PRODUCT_OUT/../../../.. && pwd` - log "TOP found at $TOP" - # $TOP/config/envsetup.make is for the old tree layout - # $TOP/build/envsetup.sh is for the new one - ANDROID_CONFIG_MK=$TOP/config/envsetup.make - if [ ! -f $ANDROID_CONFIG_MK ] ; then - ANDROID_CONFIG_MK=$TOP/build/core/config.mk - fi - if [ ! -f $ANDROID_CONFIG_MK ] ; then - echo "Cannot find build system root (TOP)" - echo "defaulting to non-Android build" - unset TOP - fi -fi - -# normalize the TOP variable, we don't want any trailing / -IN_ANDROID_BUILD=no -if [ -n "$TOP" ] ; then - TOPDIR=`dirname $TOP` - if [ "$TOPDIR" != "." ] ; then - TOP=$TOPDIR/`basename $TOP` - fi - IN_ANDROID_BUILD=yes - log "In Android Build" -fi +# source common functions definitions +. android/build/common.sh # Parse options OPTION_TARGETS="" @@ -148,7 +44,7 @@ for opt do VERBOSE=yes fi ;; - --install=*) OPTION_TARGETS="$TARGETS $optarg"; + --install=*) OPTION_TARGETS="$OPTION_TARGETS $optarg"; ;; --sdl-config=*) SDL_CONFIG=$optarg ;; @@ -193,17 +89,17 @@ EOF exit 1 fi -# Various probes are going to need to run a small C program -TMPC=/tmp/android-qemu-$$.c -TMPO=/tmp/android-qemu-$$.o -TMPE=/tmp/android-qemu-$$$EXE -TMPL=/tmp/android-qemu-$$.log +# we only support generating 32-bit binaris on 64-bit systems. +# And we may need to add a -Wa,--32 to CFLAGS to let the assembler +# generate 32-bit binaries on Linux x86_64. +# +if [ "$OPTION_TRY_64" != "yes" ] ; then + force_32bit_binaries +fi + +# Are we running in the Android build system ? +check_android_build -function clean-exit () -{ - rm -f $TMPC $TMPO $TMPL $TMPE - exit 1 -} # Adjust a few things when we're building within the Android build # system: @@ -216,44 +112,7 @@ if [ "$OPTION_NO_PREBUILTS" = "yes" ] ; then fi if [ "$IN_ANDROID_BUILD" = "yes" ] ; then - - # Get the value of a build variable as an absolute path. - function get_abs_build_var() - { - (cd $TOP && CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core make -f $ANDROID_CONFIG_MK dumpvar-abs-$1) - } - - # locate prebuilt directory - PREBUILT_HOST_TAG=$OS - case $OS in - linux-*) - # Linux is a special case because in the old tree layout - # we simply used 'Linux' as the prebuilt host tag, but - # are now using "linux-x86" in the new layout - # check which one should be used - # - if [ -d $TOP/prebuilt/Linux ] ; then - PREBUILT_HOST_TAG=Linux - fi - ;; - esac - PREBUILT=$TOP/prebuilt/$PREBUILT_HOST_TAG - if [ ! -d $PREBUILT ] ; then - # this can happen when building on x86_64 - case $OS in - linux-x86_64) - PREBUILT_HOST_TAG=linux-x86 - PREBUILT=$TOP/prebuilt/$PREBUILT_HOST_TAG - log "Forcing usage of 32-bit prebuilts" - ;; - *) - esac - if [ ! -d $PREBUILT ] ; then - echo "Can't find the prebuilt directory $PREBUILT in Android build" - exit 1 - fi - fi - log "Prebuilt : PREBUILT=$PREBUILT" + locate_android_prebuilt # use ccache if USE_CCACHE is defined and the corresponding # binary is available. @@ -262,9 +121,9 @@ if [ "$IN_ANDROID_BUILD" = "yes" ] ; then # located in PREBUILT/ccache in the old one # if [ -n "$USE_CCACHE" ] ; then - CCACHE="$PREBUILT/ccache/ccache$EXE" + CCACHE="$ANDROID_PREBUILT/ccache/ccache$EXE" if [ ! -f $CCACHE ] ; then - CCACHE="$PREBUILT/ccache$EXE" + CCACHE="$ANDROID_PREBUILT/ccache$EXE" fi if [ -f $CCACHE ] ; then CC="$CCACHE $CC" @@ -272,119 +131,44 @@ if [ "$IN_ANDROID_BUILD" = "yes" ] ; then log "Prebuilt : CCACHE=$CCACHE" fi - # if the user didn't specify a sdl-config script, get the prebuilt one + # if the user didn't specify an sdl-config script, get the prebuilt one if [ -z "$SDL_CONFIG" -a "$OPTION_NO_PREBUILTS" = "no" ] ; then # always use our own static libSDL by default - SDL_CONFIG=$PREBUILT/sdl/bin/sdl-config + SDL_CONFIG=$ANDROID_PREBUILT/sdl/bin/sdl-config log "Prebuilt : SDL_CONFIG=$SDL_CONFIG" fi # finally ensure that our new binary is copied to the 'out' # subdirectory as 'emulator' - HOST_BIN=$(get_abs_build_var HOST_OUT_EXECUTABLES) + HOST_BIN=$(get_android_abs_build_var HOST_OUT_EXECUTABLES) if [ -n "$HOST_BIN" ] ; then - TARGETS="$TARGETS $HOST_BIN/emulator$EXE" - log "Targets : TARGETS=$TARGETS" + OPTION_TARGETS="$OPTION_TARGETS $HOST_BIN/emulator$EXE" + log "Targets : TARGETS=$OPTION_TARGETS" fi fi # IN_ANDROID_BUILD = no -#### -#### Compiler checks -#### -#### -if [ -z "$CC" ] ; then - CC=gcc - if [ $CPU = "powerpc" ] ; then - CC=gcc-3.3 - fi -fi - -cat > $TMPC < $TMPC <" echo "option." - clean-exit + clean_exit fi fi @@ -411,26 +195,25 @@ SDL_CFLAGS=`echo $SDL_CFLAGS | sed -e s/-D_GNU_SOURCE=1//g` log "SDL-probe : SDL_CFLAGS = $SDL_CFLAGS" log "SDL-probe : SDL_LIBS = $SDL_LIBS" -OLD_CFLAGS=$CFLAGS -OLD_LDFLAGS=$LDFLAGS -CFLAGS="$CFLAGS $SDL_CFLAGS" -LDFLAGS="$LDFLAGS $SDL_LIBS" +EXTRA_CFLAGS="$SDL_CFLAGS" +EXTRA_LDFLAGS="$SDL_LIBS" cat > $TMPC << EOF #include #undef main -int main( void ) { +int main( int argc, char** argv ) { return SDL_Init (SDL_INIT_VIDEO); } EOF -compile -if [ $? != 0 ] ; then +feature_check_link SDL_LINKING + +if [ $SDL_LINKING != "yes" ] ; then echo "You provided an explicit sdl-config script, but the corresponding library" echo "cannot be statically linked with the Android emulator directly." echo "Error message:" cat $TMPL - clean-exit + clean_exit fi log "SDL-probe : static linking ok" @@ -440,30 +223,33 @@ log "SDL-probe : static linking ok" cat > $TMPC << EOF #include #undef main -int main( void ) { +int main( int argc, char** argv ) { int x, y; + SDL_Rect r; SDL_WM_GetPos(&x, &y); SDL_WM_SetPos(x, y); + SDL_WM_GetMonitorDPI(&x, &y); + SDL_WM_GetMonitorRect(&r); return SDL_Init (SDL_INIT_VIDEO); } EOF -compile -if [ $? != 0 ] ; then +feature_check_link SDL_LINKING + +if [ $SDL_LINKING != "yes" ] ; then echo "You provided an explicit sdl-config script in SDL_CONFIG, but the" echo "corresponding library doesn't have the patches required to link" echo "with the Android emulator. Unsetting SDL_CONFIG will use the" echo "sources bundled with the emulator instead" echo "Error:" cat $TMPL - clean-exit + clean_exit fi log "SDL-probe : extra features ok" -rm -f $TMPL $TMPC $TMPE - -CFLAGS=$OLD_CFLAGS -LDFLAGS=$OLD_LDFLAGS +clean_temp +EXTRA_CFLAGS= +EXTRA_LDFLAGS= ### ### Audio subsystems probes @@ -499,7 +285,7 @@ if [ "$PROBE_ESD" = yes ] ; then echo "Are you missing the libesd-dev package ?" echo "Correct the errors below and try again:" cat $TMPL - clean-exit + clean_exit fi PROBE_ESD=no log "AudioProbe : ESD seems to be UNUSABLE on this system !!" @@ -519,7 +305,7 @@ if [ "$PROBE_ALSA" = yes ] ; then echo "Are you missing the libasound-dev package ?" echo "Correct the erros below and try again" cat $TMPL - clean-exit + clean_exit fi PROBE_ALSA=no log "AudioProbe : ALSA seems to be UNUSABLE on this system !!" @@ -555,79 +341,36 @@ int main(int argc, char ** argv){ return (*((uint8_t*)(&i))) == 0x67; } EOF -compile-exec-run && HOST_BIGENDIAN=yes -log "Host : HOST_BIGENDIAN=$HOST_BIGENDIAN" +feature_run_exec HOST_BIGENDIAN # check size of host long bits -HOST_LONGBITS=32 cat > $TMPC << EOF int main(void) { return sizeof(void*)*8; } EOF -compile-exec-run -HOST_LONGBITS=$? -log "Host : HOST_LONGBITS=$HOST_LONGBITS" +feature_run_exec HOST_LONGBITS # check whether we have # -HAVE_BYTESWAP_H=yes -cat > $TMPC << EOF -#include -EOF -compile -if [ $? != 0 ] ; then - HAVE_BYTESWAP_H=no -fi -log "Host : HAVE_BYTESWAP_H=$HAVE_BYTESWAP_H" +feature_check_header HAVE_BYTESWAP_H "" # Build the config.make file # -rm -rf objs -mkdir -p objs -config_mk=objs/config.make -echo "# This file was autogenerated by $PROGNAME" > $config_mk -echo "TARGET_ARCH := arm" >> $config_mk -case $OS in - linux-*) HOST_OS=linux - ;; - darwin-*) HOST_OS=darwin - ;; - *) HOST_OS=$OS -esac -echo "OS := $OS" >> $config_mk -echo "HOST_OS := $HOST_OS" >> $config_mk -case $CPU in - i?86) HOST_ARCH=x86 - ;; - amd64) HOST_ARCH=x86_64 - ;; - powerpc) HOST_ARCH=ppc - ;; - *) HOST_ARCH=$CPU -esac -echo "HOST_ARCH := $HOST_ARCH" >> $config_mk + +create_config_mk + PWD=`pwd` +echo "TARGET_ARCH := arm" >> $config_mk echo "SRC_PATH := $PWD" >> $config_mk -echo "CC := $CC" >> $config_mk -echo "HOST_CC := $CC" >> $config_mk -echo "LD := $LD" >> $config_mk -echo "NO_PREBUILT := $OPTION_NO_PREBUILTS" >> $config_mk -echo "HOST_PREBUILT_TAG := $PREBUILT_HOST_TAG" >> $config_mk -echo "PREBUILT := $PREBUILT" >> $config_mk -echo "CFLAGS := $CFLAGS" >> $config_mk -echo "LDFLAGS := $LDFLAGS" >> $config_mk echo "SDL_CONFIG := $SDL_CONFIG" >> $config_mk echo "CONFIG_COREAUDIO := $PROBE_COREAUDIO" >> $config_mk echo "CONFIG_WINAUDIO := $PROBE_WINAUDIO" >> $config_mk echo "CONFIG_ESD := $PROBE_ESD" >> $config_mk echo "CONFIG_ALSA := $PROBE_ALSA" >> $config_mk echo "CONFIG_OSS := $PROBE_OSS" >> $config_mk -echo "" >> $config_mk echo "BUILD_STANDALONE_EMULATOR := true" >> $config_mk -echo "HOST_PREBUILT_TAG := $PREBUILT_HOST_TAG" >> $config_mk -log "Generate : $config_mk" # Build the config-host.h file # @@ -641,22 +384,40 @@ fi echo "#define CONFIG_GDBSTUB 1" >> $config_h echo "#define CONFIG_SLIRP 1" >> $config_h echo "#define CONFIG_SKINS 1" >> $config_h +echo "#define CONFIG_TRACE 1" >> $config_h # the -nand-limits options can only work on non-windows systems if [ "$OS" != "windows" ] ; then echo "#define CONFIG_NAND_LIMITS 1" >> $config_h fi echo "#define QEMU_VERSION \"0.8.2\"" >> $config_h case "$CPU" in - i386) HOST_CPU=I386 + x86) CONFIG_CPU=I386 ;; - powerpc) HOST_CPU=PPC + ppc) CONFIG_CPU=PPC ;; - x86_64|amd64) HOST_CPU=X86_64 + x86_64) CONFIG_CPU=X86_64 ;; - *) HOST_CPU=$CPU + *) CONFIG_CPU=$CPU ;; esac -echo "#define HOST_$HOST_CPU 1" >> $config_h +echo "#define HOST_$CONFIG_CPU 1" >> $config_h +BSD=0 +case "$OS" in + linux-*) CONFIG_OS=LINUX + ;; + darwin-*) CONFIG_OS=DARWIN + BSD=1 + ;; + windows*) CONFIG_OS=WIN32 + ;; + *) CONFIG_OS=$OS +esac +echo "#define CONFIG_$CONFIG_OS 1" >> $config_h +if [ $BSD = 1 ] ; then + echo "#define _BSD 1" >> $config_h + echo "#define O_LARGEFILE 0" >> $config_h + echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h +fi log "Generate : $config_h" echo "Ready to go. Type 'make' to build emulator" -- cgit v1.1