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 |
| 23 | OPTION_TRY_64=no |
| 24 | OPTION_HELP=no |
David 'Digit' Turner | d68b487 | 2009-07-24 16:33:05 +0200 | [diff] [blame] | 25 | OPTION_DEBUG=no |
David 'Digit' Turner | ab873b7 | 2010-03-08 18:33:50 -0800 | [diff] [blame] | 26 | OPTION_STATIC=no |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 27 | OPTION_MINGW=no |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 28 | |
| 29 | if [ -z "$CC" ] ; then |
| 30 | CC=gcc |
| 31 | fi |
| 32 | |
| 33 | for opt do |
| 34 | optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` |
| 35 | case "$opt" in |
| 36 | --help|-h|-\?) OPTION_HELP=yes |
| 37 | ;; |
| 38 | --verbose) |
| 39 | if [ "$VERBOSE" = "yes" ] ; then |
| 40 | VERBOSE2=yes |
| 41 | else |
| 42 | VERBOSE=yes |
| 43 | fi |
| 44 | ;; |
David 'Digit' Turner | d68b487 | 2009-07-24 16:33:05 +0200 | [diff] [blame] | 45 | --debug) OPTION_DEBUG=yes |
| 46 | ;; |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 47 | --install=*) OPTION_TARGETS="$OPTION_TARGETS $optarg"; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 48 | ;; |
| 49 | --sdl-config=*) SDL_CONFIG=$optarg |
| 50 | ;; |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 51 | --mingw) OPTION_MINGW=yes |
| 52 | ;; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 53 | --cc=*) CC="$optarg" ; HOSTCC=$CC |
| 54 | ;; |
| 55 | --no-strip) OPTION_NO_STRIP=yes |
| 56 | ;; |
| 57 | --debug) OPTION_DEBUG=yes |
| 58 | ;; |
| 59 | --ignore-audio) OPTION_IGNORE_AUDIO=yes |
| 60 | ;; |
| 61 | --no-prebuilts) OPTION_NO_PREBUILTS=yes |
| 62 | ;; |
| 63 | --try-64) OPTION_TRY_64=yes |
| 64 | ;; |
David 'Digit' Turner | ab873b7 | 2010-03-08 18:33:50 -0800 | [diff] [blame] | 65 | --static) OPTION_STATIC=yes |
| 66 | ;; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 67 | *) |
| 68 | echo "unknown option '$opt', use --help" |
| 69 | exit 1 |
| 70 | esac |
| 71 | done |
| 72 | |
| 73 | # Print the help message |
| 74 | # |
| 75 | if [ "$OPTION_HELP" = "yes" ] ; then |
| 76 | cat << EOF |
| 77 | |
| 78 | Usage: rebuild.sh [options] |
| 79 | Options: [defaults in brackets after descriptions] |
| 80 | EOF |
| 81 | echo "Standard options:" |
| 82 | echo " --help print this message" |
| 83 | echo " --install=FILEPATH copy emulator executable to FILEPATH [$TARGETS]" |
| 84 | echo " --cc=PATH specify C compiler [$CC]" |
| 85 | echo " --sdl-config=FILE use specific sdl-config script [$SDL_CONFIG]" |
| 86 | echo " --no-strip do not strip emulator executable" |
| 87 | echo " --debug enable debug (-O0 -g) build" |
| 88 | echo " --ignore-audio ignore audio messages (may build sound-less emulator)" |
| 89 | echo " --no-prebuilts do not use prebuilt libraries and compiler" |
| 90 | echo " --try-64 try to build a 64-bit executable (may crash)" |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 91 | echo " --mingw build Windows executable on Linux" |
David 'Digit' Turner | ab873b7 | 2010-03-08 18:33:50 -0800 | [diff] [blame] | 92 | echo " --static build a completely static executable" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 93 | echo " --verbose verbose configuration" |
David 'Digit' Turner | d68b487 | 2009-07-24 16:33:05 +0200 | [diff] [blame] | 94 | echo " --debug build debug version of the emulator" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 95 | echo "" |
| 96 | exit 1 |
| 97 | fi |
| 98 | |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 99 | # we only support generating 32-bit binaris on 64-bit systems. |
| 100 | # And we may need to add a -Wa,--32 to CFLAGS to let the assembler |
| 101 | # generate 32-bit binaries on Linux x86_64. |
| 102 | # |
| 103 | if [ "$OPTION_TRY_64" != "yes" ] ; then |
| 104 | force_32bit_binaries |
| 105 | fi |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 106 | |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 107 | TARGET_OS=$OS |
| 108 | if [ "$OPTION_MINGW" == "yes" ] ; then |
| 109 | enable_linux_mingw |
| 110 | TARGET_OS=windows |
| 111 | else |
| 112 | enable_cygwin |
| 113 | fi |
| 114 | |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 115 | # Are we running in the Android build system ? |
| 116 | check_android_build |
| 117 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 118 | |
| 119 | # Adjust a few things when we're building within the Android build |
| 120 | # system: |
| 121 | # - locate prebuilt directory |
| 122 | # - locate and use prebuilt libraries |
| 123 | # - copy the new binary to the correct location |
| 124 | # |
| 125 | if [ "$OPTION_NO_PREBUILTS" = "yes" ] ; then |
| 126 | IN_ANDROID_BUILD=no |
| 127 | fi |
| 128 | |
| 129 | if [ "$IN_ANDROID_BUILD" = "yes" ] ; then |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 130 | locate_android_prebuilt |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 131 | |
| 132 | # use ccache if USE_CCACHE is defined and the corresponding |
| 133 | # binary is available. |
| 134 | # |
| 135 | # note: located in PREBUILT/ccache/ccache in the new tree layout |
| 136 | # located in PREBUILT/ccache in the old one |
| 137 | # |
| 138 | if [ -n "$USE_CCACHE" ] ; then |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 139 | CCACHE="$ANDROID_PREBUILT/ccache/ccache$EXE" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 140 | if [ ! -f $CCACHE ] ; then |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 141 | CCACHE="$ANDROID_PREBUILT/ccache$EXE" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 142 | fi |
| 143 | if [ -f $CCACHE ] ; then |
| 144 | CC="$CCACHE $CC" |
| 145 | fi |
| 146 | log "Prebuilt : CCACHE=$CCACHE" |
| 147 | fi |
| 148 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 149 | # finally ensure that our new binary is copied to the 'out' |
| 150 | # subdirectory as 'emulator' |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 151 | HOST_BIN=$(get_android_abs_build_var HOST_OUT_EXECUTABLES) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 152 | if [ -n "$HOST_BIN" ] ; then |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 153 | OPTION_TARGETS="$OPTION_TARGETS $HOST_BIN/emulator$EXE" |
| 154 | log "Targets : TARGETS=$OPTION_TARGETS" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 155 | fi |
David 'Digit' Turner | a383d02 | 2009-12-03 13:50:00 -0800 | [diff] [blame] | 156 | |
| 157 | # find the Android SDK Tools revision number |
| 158 | TOOLS_PROPS=$ANDROID_TOP/sdk/files/tools_source.properties |
| 159 | if [ -f $TOOLS_PROPS ] ; then |
| 160 | ANDROID_SDK_TOOLS_REVISION=`awk -F= '/Pkg.Revision/ { print $2; }' $TOOLS_PROPS 2> /dev/null` |
| 161 | log "Tools : Found tools revision number $ANDROID_SDK_TOOLS_REVISION" |
| 162 | else |
| 163 | log "Tools : Could not locate $TOOLS_PROPS !?" |
| 164 | fi |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 165 | fi # IN_ANDROID_BUILD = no |
| 166 | |
| 167 | |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 168 | # we can build the emulator with Cygwin, so enable it |
| 169 | enable_cygwin |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 170 | |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 171 | setup_toolchain |
The Android Open Source Project | 92c7311 | 2009-03-05 14:34:31 -0800 | [diff] [blame] | 172 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 173 | ### |
| 174 | ### SDL Probe |
| 175 | ### |
| 176 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 177 | if [ -n "$SDL_CONFIG" ] ; then |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 178 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 179 | # check that we can link statically with the library. |
| 180 | # |
| 181 | SDL_CFLAGS=`$SDL_CONFIG --cflags` |
| 182 | SDL_LIBS=`$SDL_CONFIG --static-libs` |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 183 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 184 | # quick hack, remove the -D_GNU_SOURCE=1 of some SDL Cflags |
| 185 | # since they break recent Mingw releases |
| 186 | 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] | 187 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 188 | log "SDL-probe : SDL_CFLAGS = $SDL_CFLAGS" |
| 189 | log "SDL-probe : SDL_LIBS = $SDL_LIBS" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 190 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 191 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 192 | EXTRA_CFLAGS="$SDL_CFLAGS" |
| 193 | EXTRA_LDFLAGS="$SDL_LIBS" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 194 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 195 | case "$OS" in |
| 196 | freebsd-*) |
| 197 | EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -lpthread" |
| 198 | ;; |
| 199 | esac |
Alexey Tarasov | 0882322 | 2009-09-01 02:07:51 +1100 | [diff] [blame] | 200 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 201 | cat > $TMPC << EOF |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 202 | #include <SDL.h> |
| 203 | #undef main |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 204 | int main( int argc, char** argv ) { |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 205 | return SDL_Init (SDL_INIT_VIDEO); |
| 206 | } |
| 207 | EOF |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 208 | feature_check_link SDL_LINKING |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 209 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 210 | if [ $SDL_LINKING != "yes" ] ; then |
| 211 | echo "You provided an explicit sdl-config script, but the corresponding library" |
| 212 | echo "cannot be statically linked with the Android emulator directly." |
| 213 | echo "Error message:" |
| 214 | cat $TMPL |
| 215 | clean_exit |
| 216 | fi |
| 217 | log "SDL-probe : static linking ok" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 218 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 219 | # now, let's check that the SDL library has the special functions |
| 220 | # we added to our own sources |
| 221 | # |
| 222 | cat > $TMPC << EOF |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 223 | #include <SDL.h> |
| 224 | #undef main |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 225 | int main( int argc, char** argv ) { |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 226 | int x, y; |
| 227 | SDL_Rect r; |
| 228 | SDL_WM_GetPos(&x, &y); |
| 229 | SDL_WM_SetPos(x, y); |
| 230 | SDL_WM_GetMonitorDPI(&x, &y); |
| 231 | SDL_WM_GetMonitorRect(&r); |
| 232 | return SDL_Init (SDL_INIT_VIDEO); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 233 | } |
| 234 | EOF |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 235 | feature_check_link SDL_LINKING |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 236 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 237 | if [ $SDL_LINKING != "yes" ] ; then |
| 238 | echo "You provided an explicit sdl-config script in SDL_CONFIG, but the" |
| 239 | echo "corresponding library doesn't have the patches required to link" |
| 240 | echo "with the Android emulator. Unsetting SDL_CONFIG will use the" |
| 241 | echo "sources bundled with the emulator instead" |
| 242 | echo "Error:" |
| 243 | cat $TMPL |
| 244 | clean_exit |
| 245 | fi |
| 246 | |
| 247 | log "SDL-probe : extra features ok" |
| 248 | clean_temp |
| 249 | |
| 250 | EXTRA_CFLAGS= |
| 251 | EXTRA_LDFLAGS= |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 252 | fi |
| 253 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 254 | ### |
| 255 | ### Audio subsystems probes |
| 256 | ### |
| 257 | PROBE_COREAUDIO=no |
| 258 | PROBE_ALSA=no |
| 259 | PROBE_OSS=no |
| 260 | PROBE_ESD=no |
David 'Digit' Turner | 415a4b1 | 2010-07-28 12:20:14 -0700 | [diff] [blame] | 261 | PROBE_PULSEAUDIO=no |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 262 | PROBE_WINAUDIO=no |
| 263 | |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 264 | case "$TARGET_OS" in |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 265 | darwin*) PROBE_COREAUDIO=yes; |
| 266 | ;; |
David 'Digit' Turner | 415a4b1 | 2010-07-28 12:20:14 -0700 | [diff] [blame] | 267 | 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] | 268 | ;; |
Alexey Tarasov | 0882322 | 2009-09-01 02:07:51 +1100 | [diff] [blame] | 269 | freebsd-*) PROBE_OSS=yes; |
| 270 | ;; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 271 | windows) PROBE_WINAUDIO=yes |
| 272 | ;; |
| 273 | esac |
| 274 | |
| 275 | ORG_CFLAGS=$CFLAGS |
| 276 | ORG_LDFLAGS=$LDFLAGS |
| 277 | |
David 'Digit' Turner | 415a4b1 | 2010-07-28 12:20:14 -0700 | [diff] [blame] | 278 | # Probe a system library |
| 279 | # |
| 280 | # $1: Variable name (e.g. PROBE_ESD) |
| 281 | # $2: Library name (e.g. "Alsa") |
| 282 | # $3: Path to source file for probe program (e.g. android/config/check-alsa.c) |
| 283 | # $4: Package name (e.g. libasound-dev) |
| 284 | # |
| 285 | probe_system_library () |
| 286 | { |
| 287 | if [ `var_value $1` = yes ] ; then |
| 288 | CFLAGS="$ORG_CFLAGS" |
| 289 | LDFLAGS="$ORG_LDFLAGS -ldl" |
| 290 | cp -f android/config/check-esd.c $TMPC |
| 291 | compile && link && $TMPE |
| 292 | if [ $? = 0 ] ; then |
| 293 | log "AudioProbe : $1 seems to be usable on this system" |
| 294 | else |
| 295 | if [ "$OPTION_IGNORE_AUDIO" = no ] ; then |
| 296 | echo "the $1 development files do not seem to be installed on this system" |
| 297 | echo "Are you missing the $3 package ?" |
| 298 | echo "Correct the errors below and try again:" |
| 299 | cat $TMPL |
| 300 | clean_exit |
| 301 | fi |
| 302 | eval $1=no |
| 303 | log "AudioProbe : $1 seems to be UNUSABLE on this system !!" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 304 | fi |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 305 | fi |
David 'Digit' Turner | 415a4b1 | 2010-07-28 12:20:14 -0700 | [diff] [blame] | 306 | } |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 307 | |
David 'Digit' Turner | 415a4b1 | 2010-07-28 12:20:14 -0700 | [diff] [blame] | 308 | probe_system_library PROBE_ESD ESounD android/config/check-esd.c libesd-dev |
| 309 | probe_system_library PROBE_ALSA Alsa android/config/check-alsa.c libasound-dev |
| 310 | 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] | 311 | |
| 312 | CFLAGS=$ORG_CFLAGS |
| 313 | LDFLAGS=$ORG_LDFLAGS |
| 314 | |
| 315 | # create the objs directory that is going to contain all generated files |
| 316 | # including the configuration ones |
| 317 | # |
| 318 | mkdir -p objs |
| 319 | |
| 320 | ### |
| 321 | ### Compiler probe |
| 322 | ### |
| 323 | |
| 324 | #### |
| 325 | #### Host system probe |
| 326 | #### |
| 327 | |
| 328 | # because the previous version could be read-only |
| 329 | rm -f $TMPC |
| 330 | |
| 331 | # check host endianess |
| 332 | # |
| 333 | HOST_BIGENDIAN=no |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 334 | if [ "$TARGET_OS" = "$OS" ] ; then |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 335 | cat > $TMPC << EOF |
| 336 | #include <inttypes.h> |
| 337 | int main(int argc, char ** argv){ |
| 338 | volatile uint32_t i=0x01234567; |
| 339 | return (*((uint8_t*)(&i))) == 0x67; |
| 340 | } |
| 341 | EOF |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 342 | feature_run_exec HOST_BIGENDIAN |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 343 | fi |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 344 | |
| 345 | # check size of host long bits |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 346 | HOST_LONGBITS=32 |
| 347 | if [ "$TARGET_OS" = "$OS" ] ; then |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 348 | cat > $TMPC << EOF |
| 349 | int main(void) { |
| 350 | return sizeof(void*)*8; |
| 351 | } |
| 352 | EOF |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 353 | feature_run_exec HOST_LONGBITS |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 354 | fi |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 355 | |
| 356 | # check whether we have <byteswap.h> |
| 357 | # |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 358 | feature_check_header HAVE_BYTESWAP_H "<byteswap.h>" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 359 | |
| 360 | # Build the config.make file |
| 361 | # |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 362 | |
| 363 | create_config_mk |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 364 | echo "" >> $config_mk |
| 365 | echo "TARGET_ARCH := arm" >> $config_mk |
| 366 | echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk |
| 367 | echo "PREBUILT := $ANDROID_PREBUILT" >> $config_mk |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 368 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 369 | PWD=`pwd` |
| 370 | echo "SRC_PATH := $PWD" >> $config_mk |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 371 | if [ -n "$SDL_CONFIG" ] ; then |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 372 | echo "SDL_CONFIG := $SDL_CONFIG" >> $config_mk |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 373 | fi |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 374 | echo "CONFIG_COREAUDIO := $PROBE_COREAUDIO" >> $config_mk |
| 375 | echo "CONFIG_WINAUDIO := $PROBE_WINAUDIO" >> $config_mk |
| 376 | echo "CONFIG_ESD := $PROBE_ESD" >> $config_mk |
| 377 | echo "CONFIG_ALSA := $PROBE_ALSA" >> $config_mk |
| 378 | echo "CONFIG_OSS := $PROBE_OSS" >> $config_mk |
David 'Digit' Turner | 415a4b1 | 2010-07-28 12:20:14 -0700 | [diff] [blame] | 379 | echo "CONFIG_PULSEAUDIO := $PROBE_PULSEAUDIO" >> $config_mk |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 380 | echo "BUILD_STANDALONE_EMULATOR := true" >> $config_mk |
David 'Digit' Turner | d68b487 | 2009-07-24 16:33:05 +0200 | [diff] [blame] | 381 | if [ $OPTION_DEBUG = yes ] ; then |
| 382 | echo "BUILD_DEBUG_EMULATOR := true" >> $config_mk |
| 383 | fi |
David 'Digit' Turner | ab873b7 | 2010-03-08 18:33:50 -0800 | [diff] [blame] | 384 | if [ $OPTION_STATIC = yes ] ; then |
| 385 | echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk |
| 386 | fi |
| 387 | |
David 'Digit' Turner | a383d02 | 2009-12-03 13:50:00 -0800 | [diff] [blame] | 388 | if [ -n "$ANDROID_SDK_TOOLS_REVISION" ] ; then |
| 389 | echo "ANDROID_SDK_TOOLS_REVISION := $ANDROID_SDK_TOOLS_REVISION" >> $config_mk |
| 390 | fi |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 391 | |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 392 | if [ "$OPTION_MINGW" = "yes" ] ; then |
| 393 | echo "" >> $config_mk |
| 394 | echo "USE_MINGW := 1" >> $config_mk |
| 395 | echo "HOST_OS := windows" >> $config_mk |
| 396 | fi |
| 397 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 398 | # Build the config-host.h file |
| 399 | # |
| 400 | config_h=objs/config-host.h |
| 401 | echo "/* This file was autogenerated by '$PROGNAME' */" > $config_h |
| 402 | echo "#define CONFIG_QEMU_SHAREDIR \"/usr/local/share/qemu\"" >> $config_h |
| 403 | echo "#define HOST_LONG_BITS $HOST_LONGBITS" >> $config_h |
| 404 | if [ "$HAVE_BYTESWAP_H" = "yes" ] ; then |
| 405 | echo "#define HAVE_BYTESWAP_H 1" >> $config_h |
| 406 | fi |
| 407 | echo "#define CONFIG_GDBSTUB 1" >> $config_h |
| 408 | echo "#define CONFIG_SLIRP 1" >> $config_h |
| 409 | echo "#define CONFIG_SKINS 1" >> $config_h |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 410 | echo "#define CONFIG_TRACE 1" >> $config_h |
David 'Digit' Turner | fd3b1a0 | 2010-05-10 23:47:54 -0700 | [diff] [blame] | 411 | |
| 412 | # only Linux has fdatasync() |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 413 | case "$TARGET_OS" in |
David 'Digit' Turner | fd3b1a0 | 2010-05-10 23:47:54 -0700 | [diff] [blame] | 414 | linux-*) |
| 415 | echo "#define CONFIG_FDATASYNC 1" >> $config_h |
| 416 | ;; |
| 417 | esac |
| 418 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 419 | # the -nand-limits options can only work on non-windows systems |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 420 | if [ "$TARGET_OS" != "windows" ] ; then |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 421 | echo "#define CONFIG_NAND_LIMITS 1" >> $config_h |
| 422 | fi |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 423 | echo "#define QEMU_VERSION \"0.10.50\"" >> $config_h |
| 424 | echo "#define QEMU_PKGVERSION \"Android\"" >> $config_h |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 425 | case "$CPU" in |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 426 | x86) CONFIG_CPU=I386 |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 427 | ;; |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 428 | ppc) CONFIG_CPU=PPC |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 429 | ;; |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 430 | x86_64) CONFIG_CPU=X86_64 |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 431 | ;; |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 432 | *) CONFIG_CPU=$CPU |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 433 | ;; |
| 434 | esac |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 435 | echo "#define HOST_$CONFIG_CPU 1" >> $config_h |
| 436 | BSD=0 |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 437 | case "$TARGET_OS" in |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 438 | linux-*) CONFIG_OS=LINUX |
| 439 | ;; |
| 440 | darwin-*) CONFIG_OS=DARWIN |
| 441 | BSD=1 |
| 442 | ;; |
Alexey Tarasov | 0882322 | 2009-09-01 02:07:51 +1100 | [diff] [blame] | 443 | freebsd-*) CONFIG_OS=FREEBSD |
| 444 | BSD=1 |
| 445 | ;; |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 446 | windows*) CONFIG_OS=WIN32 |
| 447 | ;; |
| 448 | *) CONFIG_OS=$OS |
| 449 | esac |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 450 | |
David 'Digit' Turner | ab873b7 | 2010-03-08 18:33:50 -0800 | [diff] [blame] | 451 | if [ "$OPTION_STATIC" = "yes" ] ; then |
| 452 | echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk |
| 453 | echo "#define CONFIG_STATIC_EXECUTABLE 1" >> $config_h |
| 454 | fi |
| 455 | |
David 'Digit' Turner | 377eb2c | 2010-05-20 15:16:28 -0700 | [diff] [blame] | 456 | case $TARGET_OS in |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 457 | linux-*|darwin-*) |
David 'Digit' Turner | 3d66dc7 | 2010-01-27 18:18:41 -0800 | [diff] [blame] | 458 | echo "#define CONFIG_IOVEC 1" >> $config_h |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 459 | ;; |
| 460 | esac |
| 461 | |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 462 | echo "#define CONFIG_$CONFIG_OS 1" >> $config_h |
| 463 | if [ $BSD = 1 ] ; then |
David 'Digit' Turner | 2c538c8 | 2010-05-10 16:48:20 -0700 | [diff] [blame] | 464 | echo "#define CONFIG_BSD 1" >> $config_h |
David 'Digit' Turner | 46be487 | 2009-06-04 16:07:01 +0200 | [diff] [blame] | 465 | echo "#define O_LARGEFILE 0" >> $config_h |
| 466 | echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h |
| 467 | fi |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 468 | |
David 'Digit' Turner | e92bc56 | 2010-09-07 06:21:25 -0700 | [diff] [blame^] | 469 | echo "#define CONFIG_ANDROID 1" >> $config_h |
| 470 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 471 | log "Generate : $config_h" |
| 472 | |
| 473 | echo "Ready to go. Type 'make' to build emulator" |