blob: 7f8c79b93f302ec3ccd3af97eb703acf2c516033 [file] [log] [blame]
David 'Digit' Turner46be4872009-06-04 16:07:01 +02001#!/bin/sh
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08002#
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 Project8b23a6c2009-03-03 19:30:32 -08007# 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
13cd `dirname $0`
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080014
David 'Digit' Turner46be4872009-06-04 16:07:01 +020015# source common functions definitions
16. android/build/common.sh
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080017
18# Parse options
19OPTION_TARGETS=""
20OPTION_DEBUG=no
21OPTION_IGNORE_AUDIO=no
22OPTION_NO_PREBUILTS=no
23OPTION_TRY_64=no
24OPTION_HELP=no
David 'Digit' Turnerd68b4872009-07-24 16:33:05 +020025OPTION_DEBUG=no
David 'Digit' Turnerab873b72010-03-08 18:33:50 -080026OPTION_STATIC=no
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -070027OPTION_MINGW=no
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080028
David 'Digit' Turnere3650682010-12-22 14:44:19 +010029HOST_CC=${CC:-gcc}
30OPTION_CC=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080031
David 'Digit' Turner5b2e7c42011-02-07 18:51:07 +010032TARGET_ARCH=arm
33
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080034for opt do
35 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
36 case "$opt" in
37 --help|-h|-\?) OPTION_HELP=yes
38 ;;
39 --verbose)
40 if [ "$VERBOSE" = "yes" ] ; then
41 VERBOSE2=yes
42 else
43 VERBOSE=yes
44 fi
45 ;;
David 'Digit' Turnerd68b4872009-07-24 16:33:05 +020046 --debug) OPTION_DEBUG=yes
47 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +020048 --install=*) OPTION_TARGETS="$OPTION_TARGETS $optarg";
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080049 ;;
50 --sdl-config=*) SDL_CONFIG=$optarg
51 ;;
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -070052 --mingw) OPTION_MINGW=yes
53 ;;
David 'Digit' Turnere3650682010-12-22 14:44:19 +010054 --cc=*) OPTION_CC="$optarg"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080055 ;;
56 --no-strip) OPTION_NO_STRIP=yes
57 ;;
58 --debug) OPTION_DEBUG=yes
59 ;;
60 --ignore-audio) OPTION_IGNORE_AUDIO=yes
61 ;;
62 --no-prebuilts) OPTION_NO_PREBUILTS=yes
63 ;;
64 --try-64) OPTION_TRY_64=yes
65 ;;
David 'Digit' Turnerab873b72010-03-08 18:33:50 -080066 --static) OPTION_STATIC=yes
67 ;;
David 'Digit' Turner5b2e7c42011-02-07 18:51:07 +010068 --arch=*) TARGET_ARCH=$optarg
69 ;;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080070 *)
71 echo "unknown option '$opt', use --help"
72 exit 1
73 esac
74done
75
76# Print the help message
77#
78if [ "$OPTION_HELP" = "yes" ] ; then
79 cat << EOF
80
81Usage: rebuild.sh [options]
82Options: [defaults in brackets after descriptions]
83EOF
84 echo "Standard options:"
85 echo " --help print this message"
86 echo " --install=FILEPATH copy emulator executable to FILEPATH [$TARGETS]"
David 'Digit' Turnere3650682010-12-22 14:44:19 +010087 echo " --cc=PATH specify C compiler [$HOST_CC]"
David 'Digit' Turner5b2e7c42011-02-07 18:51:07 +010088 echo " --arch=ARM specify target architecture [$TARGET_ARCH]"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080089 echo " --sdl-config=FILE use specific sdl-config script [$SDL_CONFIG]"
90 echo " --no-strip do not strip emulator executable"
91 echo " --debug enable debug (-O0 -g) build"
92 echo " --ignore-audio ignore audio messages (may build sound-less emulator)"
93 echo " --no-prebuilts do not use prebuilt libraries and compiler"
94 echo " --try-64 try to build a 64-bit executable (may crash)"
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -070095 echo " --mingw build Windows executable on Linux"
David 'Digit' Turnerab873b72010-03-08 18:33:50 -080096 echo " --static build a completely static executable"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080097 echo " --verbose verbose configuration"
David 'Digit' Turnerd68b4872009-07-24 16:33:05 +020098 echo " --debug build debug version of the emulator"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080099 echo ""
100 exit 1
101fi
102
David 'Digit' Turnere3650682010-12-22 14:44:19 +0100103# On Linux, try to use our 32-bit prebuilt toolchain to generate binaries
104# that are compatible with Ubuntu 8.04
105if [ -z "$CC" -a -z "$OPTION_CC" -a "$HOST_OS" = linux -a "$OPTION_TRY_64" != "yes" ] ; then
106 HOST_CC=`dirname $0`/../../prebuilt/linux-x86/toolchain/i686-linux-glibc2.7-4.4.3/bin/i686-linux-gcc
107 if [ -f "$HOST_CC" ] ; then
108 echo "Using prebuilt 32-bit toolchain: $HOST_CC"
109 CC="$HOST_CC"
110 fi
111fi
112
David 'Digit' Turnerba313e02011-02-09 16:01:53 +0100113echo "OPTION_CC='$OPTION_CC'"
114if [ -n "$OPTION_CC" ]; then
115 echo "Using specified C compiler: $OPTION_CC"
116 CC="$OPTION_CC"
117fi
118
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200119# we only support generating 32-bit binaris on 64-bit systems.
120# And we may need to add a -Wa,--32 to CFLAGS to let the assembler
121# generate 32-bit binaries on Linux x86_64.
122#
123if [ "$OPTION_TRY_64" != "yes" ] ; then
124 force_32bit_binaries
125fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800126
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700127TARGET_OS=$OS
128if [ "$OPTION_MINGW" == "yes" ] ; then
129 enable_linux_mingw
130 TARGET_OS=windows
131else
132 enable_cygwin
133fi
134
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200135# Are we running in the Android build system ?
136check_android_build
137
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800138
139# Adjust a few things when we're building within the Android build
140# system:
141# - locate prebuilt directory
142# - locate and use prebuilt libraries
143# - copy the new binary to the correct location
144#
145if [ "$OPTION_NO_PREBUILTS" = "yes" ] ; then
146 IN_ANDROID_BUILD=no
147fi
148
149if [ "$IN_ANDROID_BUILD" = "yes" ] ; then
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200150 locate_android_prebuilt
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800151
152 # use ccache if USE_CCACHE is defined and the corresponding
153 # binary is available.
154 #
155 # note: located in PREBUILT/ccache/ccache in the new tree layout
156 # located in PREBUILT/ccache in the old one
157 #
158 if [ -n "$USE_CCACHE" ] ; then
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200159 CCACHE="$ANDROID_PREBUILT/ccache/ccache$EXE"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800160 if [ ! -f $CCACHE ] ; then
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200161 CCACHE="$ANDROID_PREBUILT/ccache$EXE"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800162 fi
163 if [ -f $CCACHE ] ; then
164 CC="$CCACHE $CC"
165 fi
166 log "Prebuilt : CCACHE=$CCACHE"
167 fi
168
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800169 # finally ensure that our new binary is copied to the 'out'
170 # subdirectory as 'emulator'
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200171 HOST_BIN=$(get_android_abs_build_var HOST_OUT_EXECUTABLES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800172 if [ -n "$HOST_BIN" ] ; then
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200173 OPTION_TARGETS="$OPTION_TARGETS $HOST_BIN/emulator$EXE"
174 log "Targets : TARGETS=$OPTION_TARGETS"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800175 fi
David 'Digit' Turnera383d022009-12-03 13:50:00 -0800176
177 # find the Android SDK Tools revision number
178 TOOLS_PROPS=$ANDROID_TOP/sdk/files/tools_source.properties
179 if [ -f $TOOLS_PROPS ] ; then
180 ANDROID_SDK_TOOLS_REVISION=`awk -F= '/Pkg.Revision/ { print $2; }' $TOOLS_PROPS 2> /dev/null`
181 log "Tools : Found tools revision number $ANDROID_SDK_TOOLS_REVISION"
182 else
183 log "Tools : Could not locate $TOOLS_PROPS !?"
184 fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800185fi # IN_ANDROID_BUILD = no
186
187
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200188# we can build the emulator with Cygwin, so enable it
189enable_cygwin
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800190
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200191setup_toolchain
The Android Open Source Project92c73112009-03-05 14:34:31 -0800192
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800193###
194### SDL Probe
195###
196
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700197if [ -n "$SDL_CONFIG" ] ; then
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200198
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700199 # check that we can link statically with the library.
200 #
201 SDL_CFLAGS=`$SDL_CONFIG --cflags`
202 SDL_LIBS=`$SDL_CONFIG --static-libs`
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800203
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700204 # quick hack, remove the -D_GNU_SOURCE=1 of some SDL Cflags
David 'Digit' Turner826b9852011-06-01 15:28:14 +02002057 # since they break recent Mingw releases
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700206 SDL_CFLAGS=`echo $SDL_CFLAGS | sed -e s/-D_GNU_SOURCE=1//g`
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800207
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700208 log "SDL-probe : SDL_CFLAGS = $SDL_CFLAGS"
209 log "SDL-probe : SDL_LIBS = $SDL_LIBS"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800210
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800211
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700212 EXTRA_CFLAGS="$SDL_CFLAGS"
213 EXTRA_LDFLAGS="$SDL_LIBS"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800214
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700215 case "$OS" in
216 freebsd-*)
217 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -lpthread"
218 ;;
219 esac
Alexey Tarasov08823222009-09-01 02:07:51 +1100220
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700221 cat > $TMPC << EOF
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800222#include <SDL.h>
223#undef main
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200224int main( int argc, char** argv ) {
David 'Digit' Turner81f74292010-10-14 18:29:45 +0200225 return SDL_Init (SDL_INIT_VIDEO);
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800226}
227EOF
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700228 feature_check_link SDL_LINKING
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200229
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700230 if [ $SDL_LINKING != "yes" ] ; then
231 echo "You provided an explicit sdl-config script, but the corresponding library"
232 echo "cannot be statically linked with the Android emulator directly."
233 echo "Error message:"
234 cat $TMPL
235 clean_exit
236 fi
237 log "SDL-probe : static linking ok"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800238
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700239 # now, let's check that the SDL library has the special functions
240 # we added to our own sources
241 #
242 cat > $TMPC << EOF
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800243#include <SDL.h>
244#undef main
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200245int main( int argc, char** argv ) {
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700246 int x, y;
247 SDL_Rect r;
248 SDL_WM_GetPos(&x, &y);
249 SDL_WM_SetPos(x, y);
250 SDL_WM_GetMonitorDPI(&x, &y);
251 SDL_WM_GetMonitorRect(&r);
David 'Digit' Turner81f74292010-10-14 18:29:45 +0200252 return SDL_Init (SDL_INIT_VIDEO);
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800253}
254EOF
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700255 feature_check_link SDL_LINKING
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200256
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700257 if [ $SDL_LINKING != "yes" ] ; then
258 echo "You provided an explicit sdl-config script in SDL_CONFIG, but the"
259 echo "corresponding library doesn't have the patches required to link"
260 echo "with the Android emulator. Unsetting SDL_CONFIG will use the"
261 echo "sources bundled with the emulator instead"
262 echo "Error:"
263 cat $TMPL
264 clean_exit
265 fi
266
267 log "SDL-probe : extra features ok"
268 clean_temp
269
270 EXTRA_CFLAGS=
271 EXTRA_LDFLAGS=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800272fi
273
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800274###
275### Audio subsystems probes
276###
277PROBE_COREAUDIO=no
278PROBE_ALSA=no
279PROBE_OSS=no
280PROBE_ESD=no
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700281PROBE_PULSEAUDIO=no
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800282PROBE_WINAUDIO=no
283
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700284case "$TARGET_OS" in
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800285 darwin*) PROBE_COREAUDIO=yes;
286 ;;
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700287 linux-*) PROBE_ALSA=yes; PROBE_OSS=yes; PROBE_ESD=yes; PROBE_PULSEAUDIO=yes;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800288 ;;
Alexey Tarasov08823222009-09-01 02:07:51 +1100289 freebsd-*) PROBE_OSS=yes;
290 ;;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800291 windows) PROBE_WINAUDIO=yes
292 ;;
293esac
294
295ORG_CFLAGS=$CFLAGS
296ORG_LDFLAGS=$LDFLAGS
297
David 'Digit' Turner80bc5c82010-10-20 19:04:51 +0200298if [ "$OPTION_IGNORE_AUDIO" = "yes" ] ; then
299PROBE_ESD_ESD=no
300PROBE_ALSA=no
301PROBE_PULSEAUDIO=no
302fi
303
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700304# Probe a system library
305#
306# $1: Variable name (e.g. PROBE_ESD)
307# $2: Library name (e.g. "Alsa")
308# $3: Path to source file for probe program (e.g. android/config/check-alsa.c)
309# $4: Package name (e.g. libasound-dev)
310#
311probe_system_library ()
312{
313 if [ `var_value $1` = yes ] ; then
314 CFLAGS="$ORG_CFLAGS"
315 LDFLAGS="$ORG_LDFLAGS -ldl"
316 cp -f android/config/check-esd.c $TMPC
David 'Digit' Turnera7ef1ac2010-12-10 22:33:51 +0100317 compile
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700318 if [ $? = 0 ] ; then
David 'Digit' Turner80bc5c82010-10-20 19:04:51 +0200319 log "AudioProbe : $2 seems to be usable on this system"
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700320 else
321 if [ "$OPTION_IGNORE_AUDIO" = no ] ; then
David 'Digit' Turner80bc5c82010-10-20 19:04:51 +0200322 echo "The $2 development files do not seem to be installed on this system"
323 echo "Are you missing the $4 package ?"
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700324 echo "Correct the errors below and try again:"
325 cat $TMPL
326 clean_exit
327 fi
328 eval $1=no
David 'Digit' Turner80bc5c82010-10-20 19:04:51 +0200329 log "AudioProbe : $2 seems to be UNUSABLE on this system !!"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800330 fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800331 fi
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700332}
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800333
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700334probe_system_library PROBE_ESD ESounD android/config/check-esd.c libesd-dev
335probe_system_library PROBE_ALSA Alsa android/config/check-alsa.c libasound-dev
336probe_system_library PROBE_PULSEAUDIO PulseAudio android/config/check-pulseaudio.c libpulse-dev
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800337
338CFLAGS=$ORG_CFLAGS
339LDFLAGS=$ORG_LDFLAGS
340
341# create the objs directory that is going to contain all generated files
342# including the configuration ones
343#
344mkdir -p objs
345
346###
347### Compiler probe
348###
349
350####
351#### Host system probe
352####
353
354# because the previous version could be read-only
355rm -f $TMPC
356
357# check host endianess
358#
359HOST_BIGENDIAN=no
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700360if [ "$TARGET_OS" = "$OS" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800361cat > $TMPC << EOF
362#include <inttypes.h>
363int main(int argc, char ** argv){
364 volatile uint32_t i=0x01234567;
Marcus Comstedt17d31322010-10-05 21:54:12 +0200365 return (*((uint8_t*)(&i))) == 0x01;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800366}
367EOF
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200368feature_run_exec HOST_BIGENDIAN
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700369fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800370
371# check size of host long bits
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700372HOST_LONGBITS=32
373if [ "$TARGET_OS" = "$OS" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800374cat > $TMPC << EOF
375int main(void) {
376 return sizeof(void*)*8;
377}
378EOF
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200379feature_run_exec HOST_LONGBITS
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700380fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800381
382# check whether we have <byteswap.h>
383#
David Turnerb8fec3e2010-09-09 18:15:23 +0200384feature_check_header HAVE_BYTESWAP_H "<byteswap.h>"
385feature_check_header HAVE_MACHINE_BSWAP_H "<machine/bswap.h>"
386feature_check_header HAVE_FNMATCH_H "<fnmatch.h>"
David Turner80dd1262010-09-09 18:04:49 +0200387
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800388# Build the config.make file
389#
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200390
David 'Digit' Turner81f74292010-10-14 18:29:45 +0200391case $TARGET_OS in
392 windows)
393 TARGET_EXEEXT=.exe
394 ;;
395 *)
396 TARGET_EXEEXT=
397 ;;
398esac
399
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200400create_config_mk
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700401echo "" >> $config_mk
Jun Nakajima334ab472011-02-02 23:49:59 -0800402if [ $TARGET_ARCH = arm ] ; then
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700403echo "TARGET_ARCH := arm" >> $config_mk
Jun Nakajima334ab472011-02-02 23:49:59 -0800404fi
405
406if [ $TARGET_ARCH = x86 ] ; then
407echo "TARGET_ARCH := x86" >> $config_mk
408fi
409
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700410echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk
David 'Digit' Turner81f74292010-10-14 18:29:45 +0200411echo "HOST_EXEEXT := $TARGET_EXEEXT" >> $config_mk
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700412echo "PREBUILT := $ANDROID_PREBUILT" >> $config_mk
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200413
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800414PWD=`pwd`
415echo "SRC_PATH := $PWD" >> $config_mk
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700416if [ -n "$SDL_CONFIG" ] ; then
David 'Digit' Turnera4026682011-08-24 12:54:01 +0200417echo "QEMU_SDL_CONFIG := $SDL_CONFIG" >> $config_mk
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700418fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800419echo "CONFIG_COREAUDIO := $PROBE_COREAUDIO" >> $config_mk
420echo "CONFIG_WINAUDIO := $PROBE_WINAUDIO" >> $config_mk
421echo "CONFIG_ESD := $PROBE_ESD" >> $config_mk
422echo "CONFIG_ALSA := $PROBE_ALSA" >> $config_mk
423echo "CONFIG_OSS := $PROBE_OSS" >> $config_mk
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700424echo "CONFIG_PULSEAUDIO := $PROBE_PULSEAUDIO" >> $config_mk
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800425echo "BUILD_STANDALONE_EMULATOR := true" >> $config_mk
David 'Digit' Turnerd68b4872009-07-24 16:33:05 +0200426if [ $OPTION_DEBUG = yes ] ; then
427 echo "BUILD_DEBUG_EMULATOR := true" >> $config_mk
428fi
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800429if [ $OPTION_STATIC = yes ] ; then
430 echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
431fi
432
David 'Digit' Turnera383d022009-12-03 13:50:00 -0800433if [ -n "$ANDROID_SDK_TOOLS_REVISION" ] ; then
434 echo "ANDROID_SDK_TOOLS_REVISION := $ANDROID_SDK_TOOLS_REVISION" >> $config_mk
435fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800436
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700437if [ "$OPTION_MINGW" = "yes" ] ; then
438 echo "" >> $config_mk
439 echo "USE_MINGW := 1" >> $config_mk
440 echo "HOST_OS := windows" >> $config_mk
441fi
442
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800443# Build the config-host.h file
444#
445config_h=objs/config-host.h
446echo "/* This file was autogenerated by '$PROGNAME' */" > $config_h
447echo "#define CONFIG_QEMU_SHAREDIR \"/usr/local/share/qemu\"" >> $config_h
448echo "#define HOST_LONG_BITS $HOST_LONGBITS" >> $config_h
449if [ "$HAVE_BYTESWAP_H" = "yes" ] ; then
David Turnerb8fec3e2010-09-09 18:15:23 +0200450 echo "#define CONFIG_BYTESWAP_H 1" >> $config_h
451fi
452if [ "$HAVE_MACHINE_BYTESWAP_H" = "yes" ] ; then
453 echo "#define CONFIG_MACHINE_BSWAP_H 1" >> $config_h
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800454fi
David Turner80dd1262010-09-09 18:04:49 +0200455if [ "$HAVE_FNMATCH_H" = "yes" ] ; then
456 echo "#define CONFIG_FNMATCH 1" >> $config_h
457fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800458echo "#define CONFIG_GDBSTUB 1" >> $config_h
459echo "#define CONFIG_SLIRP 1" >> $config_h
460echo "#define CONFIG_SKINS 1" >> $config_h
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200461echo "#define CONFIG_TRACE 1" >> $config_h
David 'Digit' Turnerfd3b1a02010-05-10 23:47:54 -0700462
David 'Digit' Turner826b9852011-06-01 15:28:14 +0200463case "$TARGET_OS" in
464 windows)
465 echo "#define CONFIG_WIN32 1" >> $config_h
466 ;;
467 *)
468 echo "#define CONFIG_POSIX 1" >> $config_h
469 ;;
470esac
471
472case "$TARGET_OS" in
473 linux-*)
474 echo "#define CONFIG_KVM_GS_RESTORE 1" >> $config_h
475 ;;
476esac
477
David 'Digit' Turnerfd3b1a02010-05-10 23:47:54 -0700478# only Linux has fdatasync()
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700479case "$TARGET_OS" in
David 'Digit' Turnerfd3b1a02010-05-10 23:47:54 -0700480 linux-*)
481 echo "#define CONFIG_FDATASYNC 1" >> $config_h
482 ;;
483esac
484
David 'Digit' Turner280afa02011-05-11 17:37:44 +0200485case "$TARGET_OS" in
486 linux-*|darwin-*)
487 echo "#define CONFIG_MADVISE 1" >> $config_h
488 ;;
489esac
490
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800491# the -nand-limits options can only work on non-windows systems
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700492if [ "$TARGET_OS" != "windows" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800493 echo "#define CONFIG_NAND_LIMITS 1" >> $config_h
494fi
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700495echo "#define QEMU_VERSION \"0.10.50\"" >> $config_h
496echo "#define QEMU_PKGVERSION \"Android\"" >> $config_h
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800497case "$CPU" in
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200498 x86) CONFIG_CPU=I386
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800499 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200500 ppc) CONFIG_CPU=PPC
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800501 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200502 x86_64) CONFIG_CPU=X86_64
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800503 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200504 *) CONFIG_CPU=$CPU
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800505 ;;
506esac
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200507echo "#define HOST_$CONFIG_CPU 1" >> $config_h
Marcus Comstedt17d31322010-10-05 21:54:12 +0200508if [ "$HOST_BIGENDIAN" = "1" ] ; then
509 echo "#define HOST_WORDS_BIGENDIAN 1" >> $config_h
510fi
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200511BSD=0
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700512case "$TARGET_OS" in
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200513 linux-*) CONFIG_OS=LINUX
514 ;;
515 darwin-*) CONFIG_OS=DARWIN
516 BSD=1
517 ;;
Alexey Tarasov08823222009-09-01 02:07:51 +1100518 freebsd-*) CONFIG_OS=FREEBSD
519 BSD=1
520 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200521 windows*) CONFIG_OS=WIN32
522 ;;
523 *) CONFIG_OS=$OS
524esac
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700525
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800526if [ "$OPTION_STATIC" = "yes" ] ; then
527 echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
528 echo "#define CONFIG_STATIC_EXECUTABLE 1" >> $config_h
529fi
530
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700531case $TARGET_OS in
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700532 linux-*|darwin-*)
David 'Digit' Turner3d66dc72010-01-27 18:18:41 -0800533 echo "#define CONFIG_IOVEC 1" >> $config_h
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700534 ;;
535esac
536
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200537echo "#define CONFIG_$CONFIG_OS 1" >> $config_h
538if [ $BSD = 1 ] ; then
David 'Digit' Turner2c538c82010-05-10 16:48:20 -0700539 echo "#define CONFIG_BSD 1" >> $config_h
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200540 echo "#define O_LARGEFILE 0" >> $config_h
541 echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
542fi
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700543
David 'Digit' Turnere92bc562010-09-07 06:21:25 -0700544echo "#define CONFIG_ANDROID 1" >> $config_h
545
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800546log "Generate : $config_h"
547
548echo "Ready to go. Type 'make' to build emulator"