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