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