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