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