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