Home | History | Annotate | Download | only in qemu
      1 #!/bin/sh
      2 #
      3 # this script is used to rebuild the Android emulator from sources
      4 # in the current directory. It also contains logic to speed up the
      5 # rebuild if it detects that you're using the Android build system
      6 #
      7 # here's the list of environment variables you can define before
      8 # calling this script to control it (besides options):
      9 #
     10 #
     11 
     12 # first, let's see which system we're running this on
     13 cd `dirname $0`
     14 
     15 # source common functions definitions
     16 . android/build/common.sh
     17 
     18 # Parse options
     19 OPTION_TARGETS=""
     20 OPTION_DEBUG=no
     21 OPTION_IGNORE_AUDIO=no
     22 OPTION_NO_PREBUILTS=no
     23 OPTION_TRY_64=no
     24 OPTION_HELP=no
     25 OPTION_DEBUG=no
     26 OPTION_STATIC=no
     27 OPTION_MINGW=no
     28 
     29 GLES_INCLUDE=
     30 GLES_LIBS=
     31 GLES_SUPPORT=no
     32 GLES_PROBE=yes
     33 
     34 HOST_CC=${CC:-gcc}
     35 OPTION_CC=
     36 
     37 TARGET_ARCH=arm
     38 
     39 for opt do
     40   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
     41   case "$opt" in
     42   --help|-h|-\?) OPTION_HELP=yes
     43   ;;
     44   --verbose)
     45     if [ "$VERBOSE" = "yes" ] ; then
     46         VERBOSE2=yes
     47     else
     48         VERBOSE=yes
     49     fi
     50   ;;
     51   --debug) OPTION_DEBUG=yes
     52   ;;
     53   --install=*) OPTION_TARGETS="$OPTION_TARGETS $optarg";
     54   ;;
     55   --sdl-config=*) SDL_CONFIG=$optarg
     56   ;;
     57   --mingw) OPTION_MINGW=yes
     58   ;;
     59   --cc=*) OPTION_CC="$optarg"
     60   ;;
     61   --no-strip) OPTION_NO_STRIP=yes
     62   ;;
     63   --debug) OPTION_DEBUG=yes
     64   ;;
     65   --ignore-audio) OPTION_IGNORE_AUDIO=yes
     66   ;;
     67   --no-prebuilts) OPTION_NO_PREBUILTS=yes
     68   ;;
     69   --try-64) OPTION_TRY_64=yes
     70   ;;
     71   --static) OPTION_STATIC=yes
     72   ;;
     73   --arch=*) TARGET_ARCH=$optarg
     74   ;;
     75   --gles-include=*) GLES_INCLUDE=$optarg
     76   GLES_SUPPORT=yes
     77   ;;
     78   --gles-libs=*) GLES_LIBS=$optarg
     79   GLES_SUPPORT=yes
     80   ;;
     81   --no-gles) GLES_PROBE=no
     82   ;;
     83   *)
     84     echo "unknown option '$opt', use --help"
     85     exit 1
     86   esac
     87 done
     88 
     89 # Print the help message
     90 #
     91 if [ "$OPTION_HELP" = "yes" ] ; then
     92     cat << EOF
     93 
     94 Usage: rebuild.sh [options]
     95 Options: [defaults in brackets after descriptions]
     96 EOF
     97     echo "Standard options:"
     98     echo "  --help                   print this message"
     99     echo "  --install=FILEPATH       copy emulator executable to FILEPATH [$TARGETS]"
    100     echo "  --cc=PATH                specify C compiler [$HOST_CC]"
    101     echo "  --arch=ARM               specify target architecture [$TARGET_ARCH]"
    102     echo "  --sdl-config=FILE        use specific sdl-config script [$SDL_CONFIG]"
    103     echo "  --no-strip               do not strip emulator executable"
    104     echo "  --debug                  enable debug (-O0 -g) build"
    105     echo "  --ignore-audio           ignore audio messages (may build sound-less emulator)"
    106     echo "  --no-prebuilts           do not use prebuilt libraries and compiler"
    107     echo "  --try-64                 try to build a 64-bit executable (may crash)"
    108     echo "  --mingw                  build Windows executable on Linux"
    109     echo "  --static                 build a completely static executable"
    110     echo "  --verbose                verbose configuration"
    111     echo "  --debug                  build debug version of the emulator"
    112     echo "  --gles-include=PATH      specify path to GLES emulation headers"
    113     echo "  --gles-libs=PATH         specify path to GLES emulation host libraries"
    114     echo "  --no-gles                disable GLES emulation support"
    115     echo ""
    116     exit 1
    117 fi
    118 
    119 # On Linux, try to use our prebuilt toolchain to generate binaries
    120 # that are compatible with Ubuntu 8.04
    121 if [ -z "$CC" -a -z "$OPTION_CC" -a "$HOST_OS" = linux ] ; then
    122     HOST_CC=`dirname $0`/../../prebuilts/tools/gcc-sdk/gcc
    123     if [ -f "$HOST_CC" ] ; then
    124         echo "Using prebuilt toolchain: $HOST_CC"
    125         CC="$HOST_CC"
    126     fi
    127 fi
    128 
    129 echo "OPTION_CC='$OPTION_CC'"
    130 if [ -n "$OPTION_CC" ]; then
    131     echo "Using specified C compiler: $OPTION_CC"
    132     CC="$OPTION_CC"
    133 fi
    134 
    135 if [ -z "$CC" ]; then
    136   CC=$HOST_CC
    137 fi
    138 
    139 # we only support generating 32-bit binaris on 64-bit systems.
    140 # And we may need to add a -Wa,--32 to CFLAGS to let the assembler
    141 # generate 32-bit binaries on Linux x86_64.
    142 #
    143 if [ "$OPTION_TRY_64" != "yes" ] ; then
    144     force_32bit_binaries
    145 fi
    146 
    147 case $OS in
    148     linux-*)
    149         TARGET_DLL_SUFFIX=.so
    150         ;;
    151     darwin-*)
    152         TARGET_DLL_SUFFIX=.dylib
    153         ;;
    154     windows*)
    155         TARGET_DLL_SUFFIX=.dll
    156 esac
    157 
    158 TARGET_OS=$OS
    159 if [ "$OPTION_MINGW" = "yes" ] ; then
    160     enable_linux_mingw
    161     TARGET_OS=windows
    162     TARGET_DLL_SUFFIX=.dll
    163 else
    164     enable_cygwin
    165 fi
    166 
    167 # Are we running in the Android build system ?
    168 check_android_build
    169 
    170 
    171 # Adjust a few things when we're building within the Android build
    172 # system:
    173 #    - locate prebuilt directory
    174 #    - locate and use prebuilt libraries
    175 #    - copy the new binary to the correct location
    176 #
    177 if [ "$OPTION_NO_PREBUILTS" = "yes" ] ; then
    178     IN_ANDROID_BUILD=no
    179 fi
    180 
    181 # This is the list of static and shared host libraries we need to link
    182 # against in order to support OpenGLES emulation properly. Note that in
    183 # the case of a standalone build, we will find these libraries inside the
    184 # platform build tree and copy them into objs/lib/ automatically, unless
    185 # you use --gles-libs to point explicitely to a different directory.
    186 #
    187 if [ "$OPTION_TRY_64" != "yes" ] ; then
    188     GLES_SHARED_LIBRARIES="libOpenglRender libGLES_CM_translator libGLES_V2_translator libEGL_translator"
    189 else
    190     GLES_SHARED_LIBRARIES="lib64OpenglRender lib64GLES_CM_translator lib64GLES_V2_translator lib64EGL_translator"
    191 fi
    192 
    193 if [ "$IN_ANDROID_BUILD" = "yes" ] ; then
    194     locate_android_prebuilt
    195 
    196     # use ccache if USE_CCACHE is defined and the corresponding
    197     # binary is available.
    198     #
    199     # note: located in PREBUILT/ccache/ccache in the new tree layout
    200     #       located in PREBUILT/ccache in the old one
    201     #
    202     if [ -n "$USE_CCACHE" ] ; then
    203         CCACHE="$ANDROID_PREBUILT/ccache/ccache$EXE"
    204         if [ ! -f $CCACHE ] ; then
    205             CCACHE="$ANDROID_PREBUILT/ccache$EXE"
    206         fi
    207         if [ ! -f $CCACHE ] ; then
    208             CCACHE="$ANDROID_PREBUILTS/ccache/ccache$EXE"
    209         fi
    210         if [ -f $CCACHE ] ; then
    211             CC="$CCACHE $CC"
    212             log "Prebuilt   : CCACHE=$CCACHE"
    213 	else
    214             log "Prebuilt   : CCACHE can't be found"
    215         fi
    216     fi
    217 
    218     # finally ensure that our new binary is copied to the 'out'
    219     # subdirectory as 'emulator'
    220     HOST_BIN=$(get_android_abs_build_var HOST_OUT_EXECUTABLES)
    221     if [ "$TARGET_OS" = "windows" ]; then
    222         HOST_BIN=$(echo $HOST_BIN | sed "s%$OS/bin%windows/bin%")
    223     fi
    224     if [ -n "$HOST_BIN" ] ; then
    225         OPTION_TARGETS="$OPTION_TARGETS $HOST_BIN/emulator$EXE"
    226         log "Targets    : TARGETS=$OPTION_TARGETS"
    227     fi
    228 
    229     # find the Android SDK Tools revision number
    230     TOOLS_PROPS=$ANDROID_TOP/sdk/files/tools_source.properties
    231     if [ -f $TOOLS_PROPS ] ; then
    232         ANDROID_SDK_TOOLS_REVISION=`awk -F= '/Pkg.Revision/ { print $2; }' $TOOLS_PROPS 2> /dev/null`
    233         log "Tools      : Found tools revision number $ANDROID_SDK_TOOLS_REVISION"
    234     else
    235         log "Tools      : Could not locate $TOOLS_PROPS !?"
    236     fi
    237 
    238     # Try to find the GLES emulation headers and libraries automatically
    239     if [ "$GLES_PROBE" = "yes" ]; then
    240         GLES_SUPPORT=yes
    241         if [ -z "$GLES_INCLUDE" ]; then
    242             log "GLES       : Probing for headers"
    243             GLES_INCLUDE=$ANDROID_TOP/development/tools/emulator/opengl/host/include
    244             if [ -d "$GLES_INCLUDE" ]; then
    245                 log "GLES       : Headers in $GLES_INCLUDE"
    246             else
    247                 echo "Warning: Could not find OpenGLES emulation include dir: $GLES_INCLUDE"
    248                 echo "Disabling GLES emulation from this build!"
    249                 GLES_SUPPORT=no
    250             fi
    251         fi
    252         if [ -z "$GLES_LIBS" ]; then
    253             log "GLES       : Probing for host libraries"
    254             GLES_LIBS=$(dirname "$HOST_BIN")/lib
    255             if [ -d "$GLES_LIBS" ]; then
    256                 echo "GLES       : Libs in $GLES_LIBS"
    257             else
    258                 echo "Warning: Could nof find OpenGLES emulation libraries in: $GLES_LIBS"
    259                 echo "Disabling GLES emulation from this build!"
    260                 GLES_SUPPORT=no
    261             fi
    262         fi
    263     fi
    264 fi  # IN_ANDROID_BUILD = no
    265 
    266 if [ "$GLES_SUPPORT" = "yes" ]; then
    267     if [ -z "$GLES_INCLUDE" -o -z "$GLES_LIBS" ]; then
    268         echo "ERROR: You must use both --gles-include and --gles-libs at the same time!"
    269         echo "       Or use --no-gles to disable its support from this build."
    270         exit 1
    271     fi
    272 
    273     GLES_HEADER=$GLES_INCLUDE/libOpenglRender/render_api.h
    274     if [ ! -f "$GLES_HEADER" ]; then
    275         echo "ERROR: Missing OpenGLES emulation header file: $GLES_HEADER"
    276         echo "Please fix this by using --gles-include to point to the right directory!"
    277         exit 1
    278     fi
    279 
    280     mkdir -p objs/lib
    281 
    282     for lib in $GLES_SHARED_LIBRARIES; do
    283         GLES_LIB=$GLES_LIBS/${lib}$TARGET_DLL_SUFFIX
    284         if [ ! -f "$GLES_LIB" ]; then
    285             echo "ERROR: Missing OpenGLES emulation host library: $GLES_LIB"
    286             echo "Please fix this by using --gles-libs to point to the right directory!"
    287             if [ "$IN_ANDROID_BUILD" = "true" ]; then
    288                 echo "You might also be missing the library because you forgot to rebuild the whole platform!"
    289             fi
    290             exit 1
    291         fi
    292         cp $GLES_LIB objs/lib
    293         if [ $? != 0 ]; then
    294             echo "ERROR: Could not find required OpenGLES emulation library: $GLES_LIB"
    295             exit 1
    296         else
    297             log "GLES       : Copying $GLES_LIB"
    298         fi
    299     done
    300 fi
    301 
    302 # we can build the emulator with Cygwin, so enable it
    303 enable_cygwin
    304 
    305 setup_toolchain
    306 
    307 ###
    308 ###  SDL Probe
    309 ###
    310 
    311 if [ -n "$SDL_CONFIG" ] ; then
    312 
    313 	# check that we can link statically with the library.
    314 	#
    315 	SDL_CFLAGS=`$SDL_CONFIG --cflags`
    316 	SDL_LIBS=`$SDL_CONFIG --static-libs`
    317 
    318 	# quick hack, remove the -D_GNU_SOURCE=1 of some SDL Cflags
    319 7	# since they break recent Mingw releases
    320 	SDL_CFLAGS=`echo $SDL_CFLAGS | sed -e s/-D_GNU_SOURCE=1//g`
    321 
    322 	log "SDL-probe  : SDL_CFLAGS = $SDL_CFLAGS"
    323 	log "SDL-probe  : SDL_LIBS   = $SDL_LIBS"
    324 
    325 
    326 	EXTRA_CFLAGS="$SDL_CFLAGS"
    327 	EXTRA_LDFLAGS="$SDL_LIBS"
    328 
    329 	case "$OS" in
    330 		freebsd-*)
    331 		EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -lpthread"
    332 		;;
    333 	esac
    334 
    335 	cat > $TMPC << EOF
    336 #include <SDL.h>
    337 #undef main
    338 int main( int argc, char** argv ) {
    339    return SDL_Init (SDL_INIT_VIDEO);
    340 }
    341 EOF
    342 	feature_check_link  SDL_LINKING
    343 
    344 	if [ $SDL_LINKING != "yes" ] ; then
    345 		echo "You provided an explicit sdl-config script, but the corresponding library"
    346 		echo "cannot be statically linked with the Android emulator directly."
    347 		echo "Error message:"
    348 		cat $TMPL
    349 		clean_exit
    350 	fi
    351 	log "SDL-probe  : static linking ok"
    352 
    353 	# now, let's check that the SDL library has the special functions
    354 	# we added to our own sources
    355 	#
    356 	cat > $TMPC << EOF
    357 #include <SDL.h>
    358 #undef main
    359 int main( int argc, char** argv ) {
    360 	int  x, y;
    361 	SDL_Rect  r;
    362 	SDL_WM_GetPos(&x, &y);
    363 	SDL_WM_SetPos(x, y);
    364 	SDL_WM_GetMonitorDPI(&x, &y);
    365 	SDL_WM_GetMonitorRect(&r);
    366 	return SDL_Init (SDL_INIT_VIDEO);
    367 }
    368 EOF
    369 	feature_check_link  SDL_LINKING
    370 
    371 	if [ $SDL_LINKING != "yes" ] ; then
    372 		echo "You provided an explicit sdl-config script in SDL_CONFIG, but the"
    373 		echo "corresponding library doesn't have the patches required to link"
    374 		echo "with the Android emulator. Unsetting SDL_CONFIG will use the"
    375 		echo "sources bundled with the emulator instead"
    376 		echo "Error:"
    377 		cat $TMPL
    378 		clean_exit
    379 	fi
    380 
    381 	log "SDL-probe  : extra features ok"
    382 	clean_temp
    383 
    384 	EXTRA_CFLAGS=
    385 	EXTRA_LDFLAGS=
    386 fi
    387 
    388 ###
    389 ###  Audio subsystems probes
    390 ###
    391 PROBE_COREAUDIO=no
    392 PROBE_ALSA=no
    393 PROBE_OSS=no
    394 PROBE_ESD=no
    395 PROBE_PULSEAUDIO=no
    396 PROBE_WINAUDIO=no
    397 
    398 case "$TARGET_OS" in
    399     darwin*) PROBE_COREAUDIO=yes;
    400     ;;
    401     linux-*) PROBE_ALSA=yes; PROBE_OSS=yes; PROBE_ESD=yes; PROBE_PULSEAUDIO=yes;
    402     ;;
    403     freebsd-*) PROBE_OSS=yes;
    404     ;;
    405     windows) PROBE_WINAUDIO=yes
    406     ;;
    407 esac
    408 
    409 ORG_CFLAGS=$CFLAGS
    410 ORG_LDFLAGS=$LDFLAGS
    411 
    412 if [ "$OPTION_IGNORE_AUDIO" = "yes" ] ; then
    413 PROBE_ESD_ESD=no
    414 PROBE_ALSA=no
    415 PROBE_PULSEAUDIO=no
    416 fi
    417 
    418 # Probe a system library
    419 #
    420 # $1: Variable name (e.g. PROBE_ESD)
    421 # $2: Library name (e.g. "Alsa")
    422 # $3: Path to source file for probe program (e.g. android/config/check-alsa.c)
    423 # $4: Package name (e.g. libasound-dev)
    424 #
    425 probe_system_library ()
    426 {
    427     if [ `var_value $1` = yes ] ; then
    428         CFLAGS="$ORG_CFLAGS"
    429         LDFLAGS="$ORG_LDFLAGS -ldl"
    430         cp -f android/config/check-esd.c $TMPC
    431         compile
    432         if [ $? = 0 ] ; then
    433             log "AudioProbe : $2 seems to be usable on this system"
    434         else
    435             if [ "$OPTION_IGNORE_AUDIO" = no ] ; then
    436                 echo "The $2 development files do not seem to be installed on this system"
    437                 echo "Are you missing the $4 package ?"
    438                 echo "Correct the errors below and try again:"
    439                 cat $TMPL
    440                 clean_exit
    441             fi
    442             eval $1=no
    443             log "AudioProbe : $2 seems to be UNUSABLE on this system !!"
    444         fi
    445     fi
    446 }
    447 
    448 probe_system_library PROBE_ESD        ESounD     android/config/check-esd.c libesd-dev
    449 probe_system_library PROBE_ALSA       Alsa       android/config/check-alsa.c libasound-dev
    450 probe_system_library PROBE_PULSEAUDIO PulseAudio android/config/check-pulseaudio.c libpulse-dev
    451 
    452 CFLAGS=$ORG_CFLAGS
    453 LDFLAGS=$ORG_LDFLAGS
    454 
    455 # create the objs directory that is going to contain all generated files
    456 # including the configuration ones
    457 #
    458 mkdir -p objs
    459 
    460 ###
    461 ###  Compiler probe
    462 ###
    463 
    464 ####
    465 ####  Host system probe
    466 ####
    467 
    468 # because the previous version could be read-only
    469 rm -f $TMPC
    470 
    471 # check host endianess
    472 #
    473 HOST_BIGENDIAN=no
    474 if [ "$TARGET_OS" = "$OS" ] ; then
    475 cat > $TMPC << EOF
    476 #include <inttypes.h>
    477 int main(int argc, char ** argv){
    478         volatile uint32_t i=0x01234567;
    479         return (*((uint8_t*)(&i))) == 0x01;
    480 }
    481 EOF
    482 feature_run_exec HOST_BIGENDIAN
    483 fi
    484 
    485 # check size of host long bits
    486 HOST_LONGBITS=32
    487 if [ "$TARGET_OS" = "$OS" ] ; then
    488 cat > $TMPC << EOF
    489 int main(void) {
    490         return sizeof(void*)*8;
    491 }
    492 EOF
    493 feature_run_exec HOST_LONGBITS
    494 fi
    495 
    496 # check whether we have <byteswap.h>
    497 #
    498 feature_check_header HAVE_BYTESWAP_H      "<byteswap.h>"
    499 feature_check_header HAVE_MACHINE_BSWAP_H "<machine/bswap.h>"
    500 feature_check_header HAVE_FNMATCH_H       "<fnmatch.h>"
    501 
    502 # Build the config.make file
    503 #
    504 
    505 case $TARGET_OS in
    506     windows)
    507         TARGET_EXEEXT=.exe
    508         ;;
    509     *)
    510         TARGET_EXEEXT=
    511         ;;
    512 esac
    513 
    514 create_config_mk
    515 echo "" >> $config_mk
    516 if [ $TARGET_ARCH = arm ] ; then
    517 echo "TARGET_ARCH       := arm" >> $config_mk
    518 fi
    519 
    520 if [ $TARGET_ARCH = x86 ] ; then
    521 echo "TARGET_ARCH       := x86" >> $config_mk
    522 fi
    523 
    524 echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk
    525 echo "HOST_EXEEXT       := $TARGET_EXEEXT" >> $config_mk
    526 echo "PREBUILT          := $ANDROID_PREBUILT" >> $config_mk
    527 echo "PREBUILTS         := $ANDROID_PREBUILTS" >> $config_mk
    528 
    529 PWD=`pwd`
    530 echo "SRC_PATH          := $PWD" >> $config_mk
    531 if [ -n "$SDL_CONFIG" ] ; then
    532 echo "QEMU_SDL_CONFIG   := $SDL_CONFIG" >> $config_mk
    533 fi
    534 echo "CONFIG_COREAUDIO  := $PROBE_COREAUDIO" >> $config_mk
    535 echo "CONFIG_WINAUDIO   := $PROBE_WINAUDIO" >> $config_mk
    536 echo "CONFIG_ESD        := $PROBE_ESD" >> $config_mk
    537 echo "CONFIG_ALSA       := $PROBE_ALSA" >> $config_mk
    538 echo "CONFIG_OSS        := $PROBE_OSS" >> $config_mk
    539 echo "CONFIG_PULSEAUDIO := $PROBE_PULSEAUDIO" >> $config_mk
    540 echo "BUILD_STANDALONE_EMULATOR := true" >> $config_mk
    541 if [ $OPTION_DEBUG = yes ] ; then
    542     echo "BUILD_DEBUG_EMULATOR := true" >> $config_mk
    543 fi
    544 if [ $OPTION_STATIC = yes ] ; then
    545     echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
    546 fi
    547 
    548 if [ -n "$ANDROID_SDK_TOOLS_REVISION" ] ; then
    549     echo "ANDROID_SDK_TOOLS_REVISION := $ANDROID_SDK_TOOLS_REVISION" >> $config_mk
    550 fi
    551 
    552 if [ "$OPTION_MINGW" = "yes" ] ; then
    553     echo "" >> $config_mk
    554     echo "USE_MINGW := 1" >> $config_mk
    555     echo "HOST_OS   := windows" >> $config_mk
    556 fi
    557 
    558 if [ "$GLES_INCLUDE" -a "$GLES_LIBS" ]; then
    559     echo "QEMU_OPENGLES_INCLUDE    := $GLES_INCLUDE" >> $config_mk
    560     echo "QEMU_OPENGLES_LIBS       := $GLES_LIBS"    >> $config_mk
    561 fi
    562 
    563 # Build the config-host.h file
    564 #
    565 config_h=objs/config-host.h
    566 echo "/* This file was autogenerated by '$PROGNAME' */" > $config_h
    567 echo "#define CONFIG_QEMU_SHAREDIR   \"/usr/local/share/qemu\"" >> $config_h
    568 echo "#define HOST_LONG_BITS  $HOST_LONGBITS" >> $config_h
    569 if [ "$HAVE_BYTESWAP_H" = "yes" ] ; then
    570   echo "#define CONFIG_BYTESWAP_H 1" >> $config_h
    571 fi
    572 if [ "$HAVE_MACHINE_BYTESWAP_H" = "yes" ] ; then
    573   echo "#define CONFIG_MACHINE_BSWAP_H 1" >> $config_h
    574 fi
    575 if [ "$HAVE_FNMATCH_H" = "yes" ] ; then
    576   echo "#define CONFIG_FNMATCH  1" >> $config_h
    577 fi
    578 echo "#define CONFIG_GDBSTUB  1" >> $config_h
    579 echo "#define CONFIG_SLIRP    1" >> $config_h
    580 echo "#define CONFIG_SKINS    1" >> $config_h
    581 echo "#define CONFIG_TRACE    1" >> $config_h
    582 
    583 case "$TARGET_OS" in
    584     windows)
    585         echo "#define CONFIG_WIN32  1" >> $config_h
    586         ;;
    587     *)
    588         echo "#define CONFIG_POSIX  1" >> $config_h
    589         ;;
    590 esac
    591 
    592 case "$TARGET_OS" in
    593     linux-*)
    594         echo "#define CONFIG_KVM_GS_RESTORE 1" >> $config_h
    595         ;;
    596 esac
    597 
    598 # only Linux has fdatasync()
    599 case "$TARGET_OS" in
    600     linux-*)
    601         echo "#define CONFIG_FDATASYNC    1" >> $config_h
    602         ;;
    603 esac
    604 
    605 case "$TARGET_OS" in
    606     linux-*|darwin-*)
    607         echo "#define CONFIG_MADVISE  1" >> $config_h
    608         ;;
    609 esac
    610 
    611 # the -nand-limits options can only work on non-windows systems
    612 if [ "$TARGET_OS" != "windows" ] ; then
    613     echo "#define CONFIG_NAND_LIMITS  1" >> $config_h
    614 fi
    615 echo "#define QEMU_VERSION    \"0.10.50\"" >> $config_h
    616 echo "#define QEMU_PKGVERSION \"Android\"" >> $config_h
    617 case "$CPU" in
    618     x86) CONFIG_CPU=I386
    619     ;;
    620     ppc) CONFIG_CPU=PPC
    621     ;;
    622     x86_64) CONFIG_CPU=X86_64
    623     ;;
    624     *) CONFIG_CPU=$CPU
    625     ;;
    626 esac
    627 echo "#define HOST_$CONFIG_CPU    1" >> $config_h
    628 if [ "$HOST_BIGENDIAN" = "1" ] ; then
    629   echo "#define HOST_WORDS_BIGENDIAN 1" >> $config_h
    630 fi
    631 BSD=0
    632 case "$TARGET_OS" in
    633     linux-*) CONFIG_OS=LINUX
    634     ;;
    635     darwin-*) CONFIG_OS=DARWIN
    636               BSD=1
    637     ;;
    638     freebsd-*) CONFIG_OS=FREEBSD
    639               BSD=1
    640     ;;
    641     windows*) CONFIG_OS=WIN32
    642     ;;
    643     *) CONFIG_OS=$OS
    644 esac
    645 
    646 if [ "$OPTION_STATIC" = "yes" ] ; then
    647     echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
    648     echo "#define CONFIG_STATIC_EXECUTABLE  1" >> $config_h
    649 fi
    650 
    651 case $TARGET_OS in
    652     linux-*|darwin-*)
    653         echo "#define CONFIG_IOVEC 1" >> $config_h
    654         ;;
    655 esac
    656 
    657 echo "#define CONFIG_$CONFIG_OS   1" >> $config_h
    658 if [ $BSD = 1 ] ; then
    659     echo "#define CONFIG_BSD       1" >> $config_h
    660     echo "#define O_LARGEFILE      0" >> $config_h
    661     echo "#define MAP_ANONYMOUS    MAP_ANON" >> $config_h
    662 fi
    663 
    664 echo "#define CONFIG_ANDROID       1" >> $config_h
    665 
    666 if [ "$GLES_INCLUDE" -a "$GLES_LIBS" ]; then
    667     echo "#define CONFIG_ANDROID_OPENGLES 1" >> $config_h
    668 fi
    669 
    670 log "Generate   : $config_h"
    671 
    672 echo "Ready to go. Type 'make' to build emulator"
    673