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 13cd `dirname $0` 14 15# source common functions definitions 16. android/build/common.sh 17 18# Parse options 19OPTION_TARGETS="" 20OPTION_DEBUG=no 21OPTION_IGNORE_AUDIO=no 22OPTION_NO_PREBUILTS=no 23OPTION_OUT_DIR= 24OPTION_HELP=no 25OPTION_STATIC=no 26OPTION_MINGW=no 27 28GLES_DIR= 29GLES_SUPPORT=no 30GLES_PROBE=yes 31 32PCBIOS_PROBE=yes 33 34HOST_CC=${CC:-gcc} 35OPTION_CC= 36 37for opt do 38 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` 39 case "$opt" in 40 --help|-h|-\?) OPTION_HELP=yes 41 ;; 42 --verbose) 43 if [ "$VERBOSE" = "yes" ] ; then 44 VERBOSE2=yes 45 else 46 VERBOSE=yes 47 fi 48 ;; 49 --debug) OPTION_DEBUG=yes 50 ;; 51 --install=*) OPTION_TARGETS="$OPTION_TARGETS $optarg"; 52 ;; 53 --sdl-config=*) SDL_CONFIG=$optarg 54 ;; 55 --mingw) OPTION_MINGW=yes 56 ;; 57 --cc=*) OPTION_CC="$optarg" 58 ;; 59 --no-strip) OPTION_NO_STRIP=yes 60 ;; 61 --out-dir=*) OPTION_OUT_DIR=$optarg 62 ;; 63 --ignore-audio) OPTION_IGNORE_AUDIO=yes 64 ;; 65 --no-prebuilts) OPTION_NO_PREBUILTS=yes 66 ;; 67 --static) OPTION_STATIC=yes 68 ;; 69 --gles-dir=*) GLES_DIR=$optarg 70 ;; 71 --no-gles) GLES_PROBE=no 72 ;; 73 --no-pcbios) PCBIOS_PROBE=no 74 ;; 75 --no-tests) 76 # Ignore this option, only used by android-rebuild.sh 77 ;; 78 *) 79 echo "unknown option '$opt', use --help" 80 exit 1 81 esac 82done 83 84# Print the help message 85# 86if [ "$OPTION_HELP" = "yes" ] ; then 87 cat << EOF 88 89Usage: rebuild.sh [options] 90Options: [defaults in brackets after descriptions] 91EOF 92 echo "Standard options:" 93 echo " --help print this message" 94 echo " --install=FILEPATH copy emulator executable to FILEPATH [$TARGETS]" 95 echo " --cc=PATH specify C compiler [$HOST_CC]" 96 echo " --sdl-config=FILE use specific sdl-config script [$SDL_CONFIG]" 97 echo " --no-strip do not strip emulator executable" 98 echo " --debug enable debug (-O0 -g) build" 99 echo " --ignore-audio ignore audio messages (may build sound-less emulator)" 100 echo " --no-prebuilts do not use prebuilt libraries and compiler" 101 echo " --out-dir=<path> use specific output directory [objs/]" 102 echo " --mingw build Windows executable on Linux" 103 echo " --static build a completely static executable" 104 echo " --verbose verbose configuration" 105 echo " --debug build debug version of the emulator" 106 echo " --gles-dir=PATH specify path to GLES host emulation sources [auto-detected]" 107 echo " --no-gles disable GLES emulation support" 108 echo " --no-pcbios disable copying of PC Bios files" 109 echo " --no-tests don't run unit test suite" 110 echo "" 111 exit 1 112fi 113 114# On Linux, try to use our prebuilt toolchain to generate binaries 115# that are compatible with Ubuntu 10.4 116if [ -z "$CC" -a -z "$OPTION_CC" -a "$HOST_OS" = linux ] ; then 117 PREBUILTS_HOST_GCC=$(dirname $0)/../../prebuilts/gcc/linux-x86/host 118 # NOTE: GCC 4.8 is currently disabled because this breaks MIPS emulation 119 # For some odd reason. Remove the 'DISABLED_' prefix below to re-enable it, 120 # e.g. once the MIPS backend has been updated to a more recent version. 121 # This only affects Linux emulator binaries. 122 PROBE_HOST_CC=$PREBUILTS_HOST_GCC/DISABLED_x86_64-linux-glibc2.11-4.8/bin/x86_64-linux-gcc 123 if [ ! -f "$PROBE_HOST_CC" ]; then 124 PROBE_HOST_CC=$PREBUILTS_HOST_GCC/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux-gcc 125 if [ ! -f "$PROBE_HOST_CC" ] ; then 126 PROBE_HOST_CC=$(dirname $0)/../../prebuilts/tools/gcc-sdk/gcc 127 fi 128 fi 129 if [ -f "$PROBE_HOST_CC" ] ; then 130 echo "Using prebuilt toolchain: $PROBE_HOST_CC" 131 CC="$PROBE_HOST_CC" 132 fi 133fi 134 135if [ -n "$OPTION_CC" ]; then 136 echo "Using specified C compiler: $OPTION_CC" 137 CC="$OPTION_CC" 138fi 139 140if [ -z "$CC" ]; then 141 CC=$HOST_CC 142fi 143 144# By default, generate 32-bit binaries, the Makefile have targets that 145# generate 64-bit ones by using -m64 on the command-line. 146force_32bit_binaries 147 148case $OS in 149 linux-*) 150 TARGET_DLL_SUFFIX=.so 151 ;; 152 darwin-*) 153 TARGET_DLL_SUFFIX=.dylib 154 ;; 155 windows*) 156 TARGET_DLL_SUFFIX=.dll 157esac 158 159TARGET_OS=$OS 160 161setup_toolchain 162 163BUILD_AR=$AR 164BUILD_CC=$CC 165BUILD_CXX=$CC 166BUILD_LD=$LD 167BUILD_AR=$AR 168BUILD_CFLAGS=$CFLAGS 169BUILD_CXXFLAGS=$CXXFLAGS 170BUILD_LDFLAGS=$LDFLAGS 171 172if [ "$OPTION_MINGW" = "yes" ] ; then 173 enable_linux_mingw 174 TARGET_OS=windows 175 TARGET_DLL_SUFFIX=.dll 176else 177 enable_cygwin 178fi 179 180if [ "$OPTION_OUT_DIR" ]; then 181 OUT_DIR="$OPTION_OUT_DIR" 182 mkdir -p "$OUT_DIR" || panic "Could not create output directory: $OUT_DIR" 183else 184 OUT_DIR=objs 185 log "Auto-config: --out-dir=objs" 186fi 187 188# Are we running in the Android build system ? 189check_android_build 190 191 192# Adjust a few things when we're building within the Android build 193# system: 194# - locate prebuilt directory 195# - locate and use prebuilt libraries 196# - copy the new binary to the correct location 197# 198if [ "$OPTION_NO_PREBUILTS" = "yes" ] ; then 199 IN_ANDROID_BUILD=no 200fi 201 202if [ "$IN_ANDROID_BUILD" = "yes" ] ; then 203 locate_android_prebuilt 204 205 # use ccache if USE_CCACHE is defined and the corresponding 206 # binary is available. 207 # 208 if [ -n "$USE_CCACHE" ] ; then 209 CCACHE="$ANDROID_PREBUILT/ccache/ccache$EXE" 210 if [ ! -f $CCACHE ] ; then 211 CCACHE="$ANDROID_PREBUILTS/ccache/ccache$EXE" 212 fi 213 fi 214 215 # finally ensure that our new binary is copied to the 'out' 216 # subdirectory as 'emulator' 217 HOST_BIN=$(get_android_abs_build_var HOST_OUT_EXECUTABLES) 218 if [ "$TARGET_OS" = "windows" ]; then 219 HOST_BIN=$(echo $HOST_BIN | sed "s%$OS/bin%windows/bin%") 220 fi 221 if [ -n "$HOST_BIN" ] ; then 222 OPTION_TARGETS="$OPTION_TARGETS $HOST_BIN/emulator$EXE" 223 log "Targets : TARGETS=$OPTION_TARGETS" 224 fi 225 226 # find the Android SDK Tools revision number 227 TOOLS_PROPS=$ANDROID_TOP/sdk/files/tools_source.properties 228 if [ -f $TOOLS_PROPS ] ; then 229 ANDROID_SDK_TOOLS_REVISION=`awk -F= '/Pkg.Revision/ { print $2; }' $TOOLS_PROPS 2> /dev/null` 230 log "Tools : Found tools revision number $ANDROID_SDK_TOOLS_REVISION" 231 else 232 log "Tools : Could not locate $TOOLS_PROPS !?" 233 fi 234else 235 if [ "$USE_CCACHE" != 0 ]; then 236 CCACHE=$(which ccache 2>/dev/null) 237 fi 238fi # IN_ANDROID_BUILD = no 239 240if [ -n "$CCACHE" -a -f "$CCACHE" ] ; then 241 CC="$CCACHE $CC" 242 log "Prebuilt : CCACHE=$CCACHE" 243else 244 log "Prebuilt : CCACHE can't be found" 245 CCACHE= 246fi 247 248# Try to find the GLES emulation headers and libraries automatically 249if [ "$GLES_PROBE" = "yes" ]; then 250 GLES_SUPPORT=yes 251 if [ -z "$GLES_DIR" ]; then 252 GLES_DIR=../../sdk/emulator/opengl 253 log2 "GLES : Probing source dir: $GLES_DIR" 254 if [ ! -d "$GLES_DIR" ]; then 255 GLES_DIR=../opengl 256 log2 "GLES : Probing source dir: $GLES_DIR" 257 if [ ! -d "$GLES_DIR" ]; then 258 GLES_DIR= 259 fi 260 fi 261 if [ -z "$GLES_DIR" ]; then 262 echo "GLES : Could not find GPU emulation sources!" 263 GLES_SUPPORT=no 264 else 265 echo "GLES : Found GPU emulation sources: $GLES_DIR" 266 GLES_SUPPORT=yes 267 fi 268 fi 269fi 270 271if [ "$PCBIOS_PROBE" = "yes" ]; then 272 PCBIOS_DIR=$(dirname "$0")/../../prebuilts/qemu-kernel/x86/pc-bios 273 if [ ! -d "$PCBIOS_DIR" ]; then 274 log2 "PC Bios : Probing $PCBIOS_DIR (missing)" 275 PCBIOS_DIR=../pc-bios 276 fi 277 log2 "PC Bios : Probing $PCBIOS_DIR" 278 if [ ! -d "$PCBIOS_DIR" ]; then 279 log "PC Bios : Could not find prebuilts directory." 280 else 281 mkdir -p $OUT_DIR/lib/pc-bios 282 for BIOS_FILE in bios.bin vgabios-cirrus.bin; do 283 log "PC Bios : Copying $BIOS_FILE" 284 cp -f $PCBIOS_DIR/$BIOS_FILE $OUT_DIR/lib/pc-bios/$BIOS_FILE 285 done 286 fi 287fi 288 289# For OS X, detect the location of the SDK to use. 290if [ "$HOST_OS" = darwin ]; then 291 OSX_VERSION=$(sw_vers -productVersion) 292 OSX_SDK_SUPPORTED="10.6 10.7 10.8" 293 OSX_SDK_INSTALLED_LIST=$(xcodebuild -showsdks 2>/dev/null | grep macosx | sed -e "s/.*macosx//g" | sort -n) 294 if [ -z "$OSX_SDK_INSTALLED_LIST" ]; then 295 echo "ERROR: Please install XCode on this machine!" 296 exit 1 297 fi 298 log "OSX: Installed SDKs: $OSX_SDK_INSTALLED_LIST" 299 300 OSX_SDK_VERSION=$(echo "$OSX_SDK_INSTALLED_LIST" | tr ' ' '\n' | head -1) 301 log "OSX: Using SDK version $OSX_SDK_VERSION" 302 303 XCODE_PATH=$(xcode-select -print-path 2>/dev/null) 304 log "OSX: XCode path: $XCODE_PATH" 305 306 OSX_SDK_ROOT=$XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OSX_SDK_VERSION}.sdk 307 log "OSX: Looking for $OSX_SDK_ROOT" 308 if [ ! -d "$OSX_SDK_ROOT" ]; then 309 OSX_SDK_ROOT=/Developer/SDKs/MaxOSX${OSX_SDK_VERSION}.sdk 310 log "OSX: Looking for $OSX_SDK_ROOT" 311 if [ ! -d "$OSX_SDK_ROOT" ]; then 312 echo "ERROR: Could not find SDK $OSX_SDK_VERSION at $OSX_SDK_ROOT" 313 exit 1 314 fi 315 fi 316 echo "OSX SDK : Found at $OSX_SDK_ROOT" 317fi 318 319# we can build the emulator with Cygwin, so enable it 320enable_cygwin 321 322setup_toolchain 323 324### 325### SDL Probe 326### 327 328if [ -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 355int main( int argc, char** argv ) { 356 return SDL_Init (SDL_INIT_VIDEO); 357} 358EOF 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 376int 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} 385EOF 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= 403fi 404 405### 406### Audio subsystems probes 407### 408PROBE_COREAUDIO=no 409PROBE_ALSA=no 410PROBE_OSS=no 411PROBE_ESD=no 412PROBE_PULSEAUDIO=no 413PROBE_WINAUDIO=no 414 415case "$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 ;; 424esac 425 426ORG_CFLAGS=$CFLAGS 427ORG_LDFLAGS=$LDFLAGS 428 429if [ "$OPTION_IGNORE_AUDIO" = "yes" ] ; then 430PROBE_ESD_ESD=no 431PROBE_ALSA=no 432PROBE_PULSEAUDIO=no 433fi 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# 442probe_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 "You can ignore this error with --ignore-audio, otherwise correct" 456 echo "the issue(s) below and try again:" 457 cat $TMPL 458 clean_exit 459 fi 460 eval $1=no 461 log "AudioProbe : $2 seems to be UNUSABLE on this system !!" 462 fi 463 clean_temp 464 fi 465} 466 467probe_system_library PROBE_ESD ESounD android/config/check-esd.c libesd-dev 468probe_system_library PROBE_ALSA Alsa android/config/check-alsa.c libasound-dev 469probe_system_library PROBE_PULSEAUDIO PulseAudio android/config/check-pulseaudio.c libpulse-dev 470 471CFLAGS=$ORG_CFLAGS 472LDFLAGS=$ORG_LDFLAGS 473 474# create the objs directory that is going to contain all generated files 475# including the configuration ones 476# 477mkdir -p $OUT_DIR 478 479### 480### Compiler probe 481### 482 483#### 484#### Host system probe 485#### 486 487# because the previous version could be read-only 488clean_temp 489 490# check host endianess 491# 492HOST_BIGENDIAN=no 493if [ "$TARGET_OS" = "$OS" ] ; then 494cat > $TMPC << EOF 495#include <inttypes.h> 496int main(int argc, char ** argv){ 497 volatile uint32_t i=0x01234567; 498 return (*((uint8_t*)(&i))) == 0x01; 499} 500EOF 501feature_run_exec HOST_BIGENDIAN 502fi 503 504# check whether we have <byteswap.h> 505# 506feature_check_header HAVE_BYTESWAP_H "<byteswap.h>" 507feature_check_header HAVE_MACHINE_BSWAP_H "<machine/bswap.h>" 508feature_check_header HAVE_FNMATCH_H "<fnmatch.h>" 509 510# check for Mingw version. 511MINGW_VERSION= 512if [ "$TARGET_OS" = "windows" ]; then 513log "Mingw : Probing for GCC version." 514GCC_VERSION=$($CC -v 2>&1 | awk '$1 == "gcc" && $2 == "version" { print $3; }') 515GCC_MAJOR=$(echo "$GCC_VERSION" | cut -f1 -d.) 516GCC_MINOR=$(echo "$GCC_VERSION" | cut -f2 -d.) 517log "Mingw : Found GCC version $GCC_MAJOR.$GCC_MINOR [$GCC_VERSION]" 518MINGW_GCC_VERSION=$(( $GCC_MAJOR * 100 + $GCC_MINOR )) 519fi 520# Build the config.make file 521# 522 523case $OS in 524 windows) 525 HOST_EXEEXT=.exe 526 HOST_DLLEXT=.dll 527 ;; 528 darwin) 529 HOST_EXEEXT= 530 HOST_DLLEXT=.dylib 531 ;; 532 *) 533 HOST_EXEEXT= 534 HOST_DLLEXT= 535 ;; 536esac 537 538case $TARGET_OS in 539 windows) 540 TARGET_EXEEXT=.exe 541 TARGET_DLLEXT=.dll 542 ;; 543 darwin) 544 TARGET_EXEXT= 545 TARGET_DLLEXT=.dylib 546 ;; 547 *) 548 TARGET_EXEEXT= 549 TARGET_DLLEXT=.so 550 ;; 551esac 552 553# Strip executables and shared libraries unless --debug is used. 554if [ "$OPTION_DEBUG" != "yes" -a "$OPTION_NO_STRIP" != "yes" ]; then 555 case $HOST_OS in 556 darwin) 557 LDFLAGS="$LDFLAGS -Wl,-S" 558 ;; 559 *) 560 LDFLAGS="$LDFLAGS -Wl,--strip-all" 561 ;; 562 esac 563fi 564 565create_config_mk "$OUT_DIR" 566echo "" >> $config_mk 567echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk 568echo "HOST_EXEEXT := $TARGET_EXEEXT" >> $config_mk 569echo "HOST_DLLEXT := $TARGET_DLLEXT" >> $config_mk 570echo "PREBUILT := $ANDROID_PREBUILT" >> $config_mk 571echo "PREBUILTS := $ANDROID_PREBUILTS" >> $config_mk 572 573echo "" >> $config_mk 574echo "BUILD_OS := $HOST_OS" >> $config_mk 575echo "BUILD_ARCH := $HOST_ARCH" >> $config_mk 576echo "BUILD_EXEEXT := $HOST_EXEEXT" >> $config_mk 577echo "BUILD_DLLEXT := $HOST_DLLEXT" >> $config_mk 578echo "BUILD_AR := $BUILD_AR" >> $config_mk 579echo "BUILD_CC := $BUILD_CC" >> $config_mk 580echo "BUILD_CXX := $BUILD_CXX" >> $config_mk 581echo "BUILD_LD := $BUILD_LD" >> $config_mk 582echo "BUILD_CFLAGS := $BUILD_CFLAGS" >> $config_mk 583echo "BUILD_LDFLAGS := $BUILD_LDFLAGS" >> $config_mk 584 585PWD=`pwd` 586echo "SRC_PATH := $PWD" >> $config_mk 587if [ -n "$SDL_CONFIG" ] ; then 588echo "QEMU_SDL_CONFIG := $SDL_CONFIG" >> $config_mk 589fi 590echo "CONFIG_COREAUDIO := $PROBE_COREAUDIO" >> $config_mk 591echo "CONFIG_WINAUDIO := $PROBE_WINAUDIO" >> $config_mk 592echo "CONFIG_ESD := $PROBE_ESD" >> $config_mk 593echo "CONFIG_ALSA := $PROBE_ALSA" >> $config_mk 594echo "CONFIG_OSS := $PROBE_OSS" >> $config_mk 595echo "CONFIG_PULSEAUDIO := $PROBE_PULSEAUDIO" >> $config_mk 596echo "BUILD_STANDALONE_EMULATOR := true" >> $config_mk 597if [ $OPTION_DEBUG = yes ] ; then 598 echo "BUILD_DEBUG_EMULATOR := true" >> $config_mk 599fi 600if [ $OPTION_STATIC = yes ] ; then 601 echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk 602fi 603if [ "$GLES_SUPPORT" = "yes" ]; then 604 echo "EMULATOR_BUILD_EMUGL := true" >> $config_mk 605 echo "EMULATOR_EMUGL_SOURCES_DIR := $GLES_DIR" >> $config_mk 606fi 607 608if [ -n "$ANDROID_SDK_TOOLS_REVISION" ] ; then 609 echo "ANDROID_SDK_TOOLS_REVISION := $ANDROID_SDK_TOOLS_REVISION" >> $config_mk 610fi 611 612if [ "$OPTION_MINGW" = "yes" ] ; then 613 echo "" >> $config_mk 614 echo "USE_MINGW := 1" >> $config_mk 615 echo "HOST_OS := windows" >> $config_mk 616 echo "HOST_MINGW_VERSION := $MINGW_GCC_VERSION" >> $config_mk 617fi 618 619if [ "$HOST_OS" = "darwin" ]; then 620 echo "mac_sdk_root := $OSX_SDK_ROOT" >> $config_mk 621 echo "mac_sdk_version := $OSX_SDK_VERSION" >> $config_mk 622fi 623 624# Build the config-host.h file 625# 626config_h=$OUT_DIR/config-host.h 627cat > $config_h <<EOF 628/* This file was autogenerated by '$PROGNAME' */ 629 630#define CONFIG_QEMU_SHAREDIR "/usr/local/share/qemu" 631 632EOF 633 634if [ "$HAVE_BYTESWAP_H" = "yes" ] ; then 635 echo "#define CONFIG_BYTESWAP_H 1" >> $config_h 636fi 637if [ "$HAVE_MACHINE_BYTESWAP_H" = "yes" ] ; then 638 echo "#define CONFIG_MACHINE_BSWAP_H 1" >> $config_h 639fi 640if [ "$HAVE_FNMATCH_H" = "yes" ] ; then 641 echo "#define CONFIG_FNMATCH 1" >> $config_h 642fi 643echo "#define CONFIG_GDBSTUB 1" >> $config_h 644echo "#define CONFIG_SLIRP 1" >> $config_h 645echo "#define CONFIG_SKINS 1" >> $config_h 646echo "#define CONFIG_TRACE 1" >> $config_h 647 648case "$TARGET_OS" in 649 windows) 650 echo "#define CONFIG_WIN32 1" >> $config_h 651 ;; 652 *) 653 echo "#define CONFIG_POSIX 1" >> $config_h 654 ;; 655esac 656 657case "$TARGET_OS" in 658 linux-*) 659 echo "#define CONFIG_KVM_GS_RESTORE 1" >> $config_h 660 ;; 661esac 662 663# only Linux has fdatasync() 664case "$TARGET_OS" in 665 linux-*) 666 echo "#define CONFIG_FDATASYNC 1" >> $config_h 667 ;; 668esac 669 670case "$TARGET_OS" in 671 linux-*|darwin-*) 672 echo "#define CONFIG_MADVISE 1" >> $config_h 673 ;; 674esac 675 676# the -nand-limits options can only work on non-windows systems 677if [ "$TARGET_OS" != "windows" ] ; then 678 echo "#define CONFIG_NAND_LIMITS 1" >> $config_h 679fi 680echo "#define QEMU_VERSION \"0.10.50\"" >> $config_h 681echo "#define QEMU_PKGVERSION \"Android\"" >> $config_h 682case "$CPU" in 683 x86) CONFIG_CPU=I386 684 ;; 685 ppc) CONFIG_CPU=PPC 686 ;; 687 x86_64) CONFIG_CPU=X86_64 688 ;; 689 *) CONFIG_CPU=$CPU 690 ;; 691esac 692if [ "$HOST_BIGENDIAN" = "1" ] ; then 693 echo "#define HOST_WORDS_BIGENDIAN 1" >> $config_h 694fi 695BSD=0 696case "$TARGET_OS" in 697 linux-*) CONFIG_OS=LINUX 698 ;; 699 darwin-*) CONFIG_OS=DARWIN 700 BSD=1 701 ;; 702 freebsd-*) CONFIG_OS=FREEBSD 703 BSD=1 704 ;; 705 windows*) CONFIG_OS=WIN32 706 ;; 707 *) CONFIG_OS=$OS 708esac 709 710if [ "$OPTION_STATIC" = "yes" ] ; then 711 echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk 712 echo "#define CONFIG_STATIC_EXECUTABLE 1" >> $config_h 713fi 714 715case $TARGET_OS in 716 linux-*|darwin-*) 717 echo "#define CONFIG_IOVEC 1" >> $config_h 718 ;; 719esac 720 721echo "#define CONFIG_$CONFIG_OS 1" >> $config_h 722if [ $BSD = 1 ] ; then 723 echo "#define CONFIG_BSD 1" >> $config_h 724 echo "#define O_LARGEFILE 0" >> $config_h 725 echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h 726fi 727 728case "$TARGET_OS" in 729 linux-*) 730 echo "#define CONFIG_SIGNALFD 1" >> $config_h 731 ;; 732esac 733 734echo "#define CONFIG_ANDROID 1" >> $config_h 735 736log "Generate : $config_h" 737 738# Generate the QAPI headers and sources from qapi-schema.json 739# Ideally, this would be done in our Makefiles, but as far as I 740# understand, the platform build doesn't support a single tool 741# that generates several sources files, nor the standalone one. 742export PYTHONDONTWRITEBYTECODE=1 743AUTOGENERATED_DIR=qapi-auto-generated 744python scripts/qapi-types.py qapi.types --output-dir=$AUTOGENERATED_DIR -b < qapi-schema.json 745python scripts/qapi-visit.py --output-dir=$AUTOGENERATED_DIR -b < qapi-schema.json 746python scripts/qapi-commands.py --output-dir=$AUTOGENERATED_DIR -m < qapi-schema.json 747log "Generate : $AUTOGENERATED_DIR" 748 749clean_temp 750 751echo "Ready to go. Type 'make' to build emulator" 752