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