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