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