blob: febf59c28faccee600c02fb75048a16ddab7bc5f [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
29if [ -z "$CC" ] ; then
30 CC=gcc
31fi
32
33for 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' Turnerd68b4872009-07-24 16:33:05 +020045 --debug) OPTION_DEBUG=yes
46 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +020047 --install=*) OPTION_TARGETS="$OPTION_TARGETS $optarg";
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080048 ;;
49 --sdl-config=*) SDL_CONFIG=$optarg
50 ;;
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -070051 --mingw) OPTION_MINGW=yes
52 ;;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080053 --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' Turnerab873b72010-03-08 18:33:50 -080065 --static) OPTION_STATIC=yes
66 ;;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080067 *)
68 echo "unknown option '$opt', use --help"
69 exit 1
70 esac
71done
72
73# Print the help message
74#
75if [ "$OPTION_HELP" = "yes" ] ; then
76 cat << EOF
77
78Usage: rebuild.sh [options]
79Options: [defaults in brackets after descriptions]
80EOF
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' Turner377eb2c2010-05-20 15:16:28 -070091 echo " --mingw build Windows executable on Linux"
David 'Digit' Turnerab873b72010-03-08 18:33:50 -080092 echo " --static build a completely static executable"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080093 echo " --verbose verbose configuration"
David 'Digit' Turnerd68b4872009-07-24 16:33:05 +020094 echo " --debug build debug version of the emulator"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080095 echo ""
96 exit 1
97fi
98
David 'Digit' Turner46be4872009-06-04 16:07:01 +020099# 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#
103if [ "$OPTION_TRY_64" != "yes" ] ; then
104 force_32bit_binaries
105fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800106
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700107TARGET_OS=$OS
108if [ "$OPTION_MINGW" == "yes" ] ; then
109 enable_linux_mingw
110 TARGET_OS=windows
111else
112 enable_cygwin
113fi
114
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200115# Are we running in the Android build system ?
116check_android_build
117
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800118
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#
125if [ "$OPTION_NO_PREBUILTS" = "yes" ] ; then
126 IN_ANDROID_BUILD=no
127fi
128
129if [ "$IN_ANDROID_BUILD" = "yes" ] ; then
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200130 locate_android_prebuilt
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800131
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' Turner46be4872009-06-04 16:07:01 +0200139 CCACHE="$ANDROID_PREBUILT/ccache/ccache$EXE"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800140 if [ ! -f $CCACHE ] ; then
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200141 CCACHE="$ANDROID_PREBUILT/ccache$EXE"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800142 fi
143 if [ -f $CCACHE ] ; then
144 CC="$CCACHE $CC"
145 fi
146 log "Prebuilt : CCACHE=$CCACHE"
147 fi
148
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800149 # finally ensure that our new binary is copied to the 'out'
150 # subdirectory as 'emulator'
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200151 HOST_BIN=$(get_android_abs_build_var HOST_OUT_EXECUTABLES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800152 if [ -n "$HOST_BIN" ] ; then
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200153 OPTION_TARGETS="$OPTION_TARGETS $HOST_BIN/emulator$EXE"
154 log "Targets : TARGETS=$OPTION_TARGETS"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800155 fi
David 'Digit' Turnera383d022009-12-03 13:50:00 -0800156
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 Project8b23a6c2009-03-03 19:30:32 -0800165fi # IN_ANDROID_BUILD = no
166
167
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200168# we can build the emulator with Cygwin, so enable it
169enable_cygwin
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800170
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200171setup_toolchain
The Android Open Source Project92c73112009-03-05 14:34:31 -0800172
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800173###
174### SDL Probe
175###
176
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700177if [ -n "$SDL_CONFIG" ] ; then
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200178
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700179 # 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 Project8b23a6c2009-03-03 19:30:32 -0800183
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700184 # 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 Project8b23a6c2009-03-03 19:30:32 -0800187
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700188 log "SDL-probe : SDL_CFLAGS = $SDL_CFLAGS"
189 log "SDL-probe : SDL_LIBS = $SDL_LIBS"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800190
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800191
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700192 EXTRA_CFLAGS="$SDL_CFLAGS"
193 EXTRA_LDFLAGS="$SDL_LIBS"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800194
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700195 case "$OS" in
196 freebsd-*)
197 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -lpthread"
198 ;;
199 esac
Alexey Tarasov08823222009-09-01 02:07:51 +1100200
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700201 cat > $TMPC << EOF
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800202#include <SDL.h>
203#undef main
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200204int main( int argc, char** argv ) {
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800205 return SDL_Init (SDL_INIT_VIDEO);
206}
207EOF
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700208 feature_check_link SDL_LINKING
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200209
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700210 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 Project8b23a6c2009-03-03 19:30:32 -0800218
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700219 # 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 Project8b23a6c2009-03-03 19:30:32 -0800223#include <SDL.h>
224#undef main
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200225int main( int argc, char** argv ) {
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700226 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 Project8b23a6c2009-03-03 19:30:32 -0800233}
234EOF
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700235 feature_check_link SDL_LINKING
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200236
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700237 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 Project8b23a6c2009-03-03 19:30:32 -0800252fi
253
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800254###
255### Audio subsystems probes
256###
257PROBE_COREAUDIO=no
258PROBE_ALSA=no
259PROBE_OSS=no
260PROBE_ESD=no
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700261PROBE_PULSEAUDIO=no
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800262PROBE_WINAUDIO=no
263
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700264case "$TARGET_OS" in
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800265 darwin*) PROBE_COREAUDIO=yes;
266 ;;
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700267 linux-*) PROBE_ALSA=yes; PROBE_OSS=yes; PROBE_ESD=yes; PROBE_PULSEAUDIO=yes;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800268 ;;
Alexey Tarasov08823222009-09-01 02:07:51 +1100269 freebsd-*) PROBE_OSS=yes;
270 ;;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800271 windows) PROBE_WINAUDIO=yes
272 ;;
273esac
274
275ORG_CFLAGS=$CFLAGS
276ORG_LDFLAGS=$LDFLAGS
277
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700278# 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#
285probe_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 Project8b23a6c2009-03-03 19:30:32 -0800304 fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800305 fi
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700306}
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800307
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700308probe_system_library PROBE_ESD ESounD android/config/check-esd.c libesd-dev
309probe_system_library PROBE_ALSA Alsa android/config/check-alsa.c libasound-dev
310probe_system_library PROBE_PULSEAUDIO PulseAudio android/config/check-pulseaudio.c libpulse-dev
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800311
312CFLAGS=$ORG_CFLAGS
313LDFLAGS=$ORG_LDFLAGS
314
315# create the objs directory that is going to contain all generated files
316# including the configuration ones
317#
318mkdir -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
329rm -f $TMPC
330
331# check host endianess
332#
333HOST_BIGENDIAN=no
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700334if [ "$TARGET_OS" = "$OS" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800335cat > $TMPC << EOF
336#include <inttypes.h>
337int main(int argc, char ** argv){
338 volatile uint32_t i=0x01234567;
Marcus Comstedt17d31322010-10-05 21:54:12 +0200339 return (*((uint8_t*)(&i))) == 0x01;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800340}
341EOF
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200342feature_run_exec HOST_BIGENDIAN
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700343fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800344
345# check size of host long bits
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700346HOST_LONGBITS=32
347if [ "$TARGET_OS" = "$OS" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800348cat > $TMPC << EOF
349int main(void) {
350 return sizeof(void*)*8;
351}
352EOF
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200353feature_run_exec HOST_LONGBITS
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700354fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800355
356# check whether we have <byteswap.h>
357#
David Turnerb8fec3e2010-09-09 18:15:23 +0200358feature_check_header HAVE_BYTESWAP_H "<byteswap.h>"
359feature_check_header HAVE_MACHINE_BSWAP_H "<machine/bswap.h>"
360feature_check_header HAVE_FNMATCH_H "<fnmatch.h>"
David Turner80dd1262010-09-09 18:04:49 +0200361
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800362# Build the config.make file
363#
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200364
365create_config_mk
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700366echo "" >> $config_mk
367echo "TARGET_ARCH := arm" >> $config_mk
368echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk
369echo "PREBUILT := $ANDROID_PREBUILT" >> $config_mk
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200370
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800371PWD=`pwd`
372echo "SRC_PATH := $PWD" >> $config_mk
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700373if [ -n "$SDL_CONFIG" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800374echo "SDL_CONFIG := $SDL_CONFIG" >> $config_mk
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700375fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800376echo "CONFIG_COREAUDIO := $PROBE_COREAUDIO" >> $config_mk
377echo "CONFIG_WINAUDIO := $PROBE_WINAUDIO" >> $config_mk
378echo "CONFIG_ESD := $PROBE_ESD" >> $config_mk
379echo "CONFIG_ALSA := $PROBE_ALSA" >> $config_mk
380echo "CONFIG_OSS := $PROBE_OSS" >> $config_mk
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700381echo "CONFIG_PULSEAUDIO := $PROBE_PULSEAUDIO" >> $config_mk
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800382echo "BUILD_STANDALONE_EMULATOR := true" >> $config_mk
David 'Digit' Turnerd68b4872009-07-24 16:33:05 +0200383if [ $OPTION_DEBUG = yes ] ; then
384 echo "BUILD_DEBUG_EMULATOR := true" >> $config_mk
385fi
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800386if [ $OPTION_STATIC = yes ] ; then
387 echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
388fi
389
David 'Digit' Turnera383d022009-12-03 13:50:00 -0800390if [ -n "$ANDROID_SDK_TOOLS_REVISION" ] ; then
391 echo "ANDROID_SDK_TOOLS_REVISION := $ANDROID_SDK_TOOLS_REVISION" >> $config_mk
392fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800393
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700394if [ "$OPTION_MINGW" = "yes" ] ; then
395 echo "" >> $config_mk
396 echo "USE_MINGW := 1" >> $config_mk
397 echo "HOST_OS := windows" >> $config_mk
398fi
399
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800400# Build the config-host.h file
401#
402config_h=objs/config-host.h
403echo "/* This file was autogenerated by '$PROGNAME' */" > $config_h
404echo "#define CONFIG_QEMU_SHAREDIR \"/usr/local/share/qemu\"" >> $config_h
405echo "#define HOST_LONG_BITS $HOST_LONGBITS" >> $config_h
406if [ "$HAVE_BYTESWAP_H" = "yes" ] ; then
David Turnerb8fec3e2010-09-09 18:15:23 +0200407 echo "#define CONFIG_BYTESWAP_H 1" >> $config_h
408fi
409if [ "$HAVE_MACHINE_BYTESWAP_H" = "yes" ] ; then
410 echo "#define CONFIG_MACHINE_BSWAP_H 1" >> $config_h
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800411fi
David Turner80dd1262010-09-09 18:04:49 +0200412if [ "$HAVE_FNMATCH_H" = "yes" ] ; then
413 echo "#define CONFIG_FNMATCH 1" >> $config_h
414fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800415echo "#define CONFIG_GDBSTUB 1" >> $config_h
416echo "#define CONFIG_SLIRP 1" >> $config_h
417echo "#define CONFIG_SKINS 1" >> $config_h
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200418echo "#define CONFIG_TRACE 1" >> $config_h
David 'Digit' Turnerfd3b1a02010-05-10 23:47:54 -0700419
420# only Linux has fdatasync()
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700421case "$TARGET_OS" in
David 'Digit' Turnerfd3b1a02010-05-10 23:47:54 -0700422 linux-*)
423 echo "#define CONFIG_FDATASYNC 1" >> $config_h
424 ;;
425esac
426
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800427# the -nand-limits options can only work on non-windows systems
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700428if [ "$TARGET_OS" != "windows" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800429 echo "#define CONFIG_NAND_LIMITS 1" >> $config_h
430fi
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700431echo "#define QEMU_VERSION \"0.10.50\"" >> $config_h
432echo "#define QEMU_PKGVERSION \"Android\"" >> $config_h
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800433case "$CPU" in
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200434 x86) CONFIG_CPU=I386
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800435 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200436 ppc) CONFIG_CPU=PPC
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800437 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200438 x86_64) CONFIG_CPU=X86_64
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800439 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200440 *) CONFIG_CPU=$CPU
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800441 ;;
442esac
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200443echo "#define HOST_$CONFIG_CPU 1" >> $config_h
Marcus Comstedt17d31322010-10-05 21:54:12 +0200444if [ "$HOST_BIGENDIAN" = "1" ] ; then
445 echo "#define HOST_WORDS_BIGENDIAN 1" >> $config_h
446fi
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200447BSD=0
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700448case "$TARGET_OS" in
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200449 linux-*) CONFIG_OS=LINUX
450 ;;
451 darwin-*) CONFIG_OS=DARWIN
452 BSD=1
453 ;;
Alexey Tarasov08823222009-09-01 02:07:51 +1100454 freebsd-*) CONFIG_OS=FREEBSD
455 BSD=1
456 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200457 windows*) CONFIG_OS=WIN32
458 ;;
459 *) CONFIG_OS=$OS
460esac
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700461
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800462if [ "$OPTION_STATIC" = "yes" ] ; then
463 echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
464 echo "#define CONFIG_STATIC_EXECUTABLE 1" >> $config_h
465fi
466
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700467case $TARGET_OS in
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700468 linux-*|darwin-*)
David 'Digit' Turner3d66dc72010-01-27 18:18:41 -0800469 echo "#define CONFIG_IOVEC 1" >> $config_h
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700470 ;;
471esac
472
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200473echo "#define CONFIG_$CONFIG_OS 1" >> $config_h
474if [ $BSD = 1 ] ; then
David 'Digit' Turner2c538c82010-05-10 16:48:20 -0700475 echo "#define CONFIG_BSD 1" >> $config_h
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200476 echo "#define O_LARGEFILE 0" >> $config_h
477 echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
478fi
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700479
David 'Digit' Turnere92bc562010-09-07 06:21:25 -0700480echo "#define CONFIG_ANDROID 1" >> $config_h
481
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800482log "Generate : $config_h"
483
484echo "Ready to go. Type 'make' to build emulator"