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