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