blob: fbc7f0dd3ab42cec50baadc2bcfa95fb863c56b3 [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 ) {
David 'Digit' Turner81f74292010-10-14 18:29:45 +0200205 return SDL_Init (SDL_INIT_VIDEO);
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800206}
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);
David 'Digit' Turner81f74292010-10-14 18:29:45 +0200232 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' Turner80bc5c82010-10-20 19:04:51 +0200278if [ "$OPTION_IGNORE_AUDIO" = "yes" ] ; then
279PROBE_ESD_ESD=no
280PROBE_ALSA=no
281PROBE_PULSEAUDIO=no
282fi
283
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700284# Probe a system library
285#
286# $1: Variable name (e.g. PROBE_ESD)
287# $2: Library name (e.g. "Alsa")
288# $3: Path to source file for probe program (e.g. android/config/check-alsa.c)
289# $4: Package name (e.g. libasound-dev)
290#
291probe_system_library ()
292{
293 if [ `var_value $1` = yes ] ; then
294 CFLAGS="$ORG_CFLAGS"
295 LDFLAGS="$ORG_LDFLAGS -ldl"
296 cp -f android/config/check-esd.c $TMPC
297 compile && link && $TMPE
298 if [ $? = 0 ] ; then
David 'Digit' Turner80bc5c82010-10-20 19:04:51 +0200299 log "AudioProbe : $2 seems to be usable on this system"
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700300 else
301 if [ "$OPTION_IGNORE_AUDIO" = no ] ; then
David 'Digit' Turner80bc5c82010-10-20 19:04:51 +0200302 echo "The $2 development files do not seem to be installed on this system"
303 echo "Are you missing the $4 package ?"
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700304 echo "Correct the errors below and try again:"
305 cat $TMPL
306 clean_exit
307 fi
308 eval $1=no
David 'Digit' Turner80bc5c82010-10-20 19:04:51 +0200309 log "AudioProbe : $2 seems to be UNUSABLE on this system !!"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800310 fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800311 fi
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700312}
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800313
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700314probe_system_library PROBE_ESD ESounD android/config/check-esd.c libesd-dev
315probe_system_library PROBE_ALSA Alsa android/config/check-alsa.c libasound-dev
316probe_system_library PROBE_PULSEAUDIO PulseAudio android/config/check-pulseaudio.c libpulse-dev
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800317
318CFLAGS=$ORG_CFLAGS
319LDFLAGS=$ORG_LDFLAGS
320
321# create the objs directory that is going to contain all generated files
322# including the configuration ones
323#
324mkdir -p objs
325
326###
327### Compiler probe
328###
329
330####
331#### Host system probe
332####
333
334# because the previous version could be read-only
335rm -f $TMPC
336
337# check host endianess
338#
339HOST_BIGENDIAN=no
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700340if [ "$TARGET_OS" = "$OS" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800341cat > $TMPC << EOF
342#include <inttypes.h>
343int main(int argc, char ** argv){
344 volatile uint32_t i=0x01234567;
Marcus Comstedt17d31322010-10-05 21:54:12 +0200345 return (*((uint8_t*)(&i))) == 0x01;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800346}
347EOF
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200348feature_run_exec HOST_BIGENDIAN
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700349fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800350
351# check size of host long bits
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700352HOST_LONGBITS=32
353if [ "$TARGET_OS" = "$OS" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800354cat > $TMPC << EOF
355int main(void) {
356 return sizeof(void*)*8;
357}
358EOF
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200359feature_run_exec HOST_LONGBITS
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700360fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800361
362# check whether we have <byteswap.h>
363#
David Turnerb8fec3e2010-09-09 18:15:23 +0200364feature_check_header HAVE_BYTESWAP_H "<byteswap.h>"
365feature_check_header HAVE_MACHINE_BSWAP_H "<machine/bswap.h>"
366feature_check_header HAVE_FNMATCH_H "<fnmatch.h>"
David Turner80dd1262010-09-09 18:04:49 +0200367
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800368# Build the config.make file
369#
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200370
David 'Digit' Turner81f74292010-10-14 18:29:45 +0200371case $TARGET_OS in
372 windows)
373 TARGET_EXEEXT=.exe
374 ;;
375 *)
376 TARGET_EXEEXT=
377 ;;
378esac
379
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200380create_config_mk
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700381echo "" >> $config_mk
382echo "TARGET_ARCH := arm" >> $config_mk
383echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk
David 'Digit' Turner81f74292010-10-14 18:29:45 +0200384echo "HOST_EXEEXT := $TARGET_EXEEXT" >> $config_mk
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700385echo "PREBUILT := $ANDROID_PREBUILT" >> $config_mk
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200386
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800387PWD=`pwd`
388echo "SRC_PATH := $PWD" >> $config_mk
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700389if [ -n "$SDL_CONFIG" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800390echo "SDL_CONFIG := $SDL_CONFIG" >> $config_mk
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700391fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800392echo "CONFIG_COREAUDIO := $PROBE_COREAUDIO" >> $config_mk
393echo "CONFIG_WINAUDIO := $PROBE_WINAUDIO" >> $config_mk
394echo "CONFIG_ESD := $PROBE_ESD" >> $config_mk
395echo "CONFIG_ALSA := $PROBE_ALSA" >> $config_mk
396echo "CONFIG_OSS := $PROBE_OSS" >> $config_mk
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700397echo "CONFIG_PULSEAUDIO := $PROBE_PULSEAUDIO" >> $config_mk
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800398echo "BUILD_STANDALONE_EMULATOR := true" >> $config_mk
David 'Digit' Turnerd68b4872009-07-24 16:33:05 +0200399if [ $OPTION_DEBUG = yes ] ; then
400 echo "BUILD_DEBUG_EMULATOR := true" >> $config_mk
401fi
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800402if [ $OPTION_STATIC = yes ] ; then
403 echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
404fi
405
David 'Digit' Turnera383d022009-12-03 13:50:00 -0800406if [ -n "$ANDROID_SDK_TOOLS_REVISION" ] ; then
407 echo "ANDROID_SDK_TOOLS_REVISION := $ANDROID_SDK_TOOLS_REVISION" >> $config_mk
408fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800409
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700410if [ "$OPTION_MINGW" = "yes" ] ; then
411 echo "" >> $config_mk
412 echo "USE_MINGW := 1" >> $config_mk
413 echo "HOST_OS := windows" >> $config_mk
414fi
415
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800416# Build the config-host.h file
417#
418config_h=objs/config-host.h
419echo "/* This file was autogenerated by '$PROGNAME' */" > $config_h
420echo "#define CONFIG_QEMU_SHAREDIR \"/usr/local/share/qemu\"" >> $config_h
421echo "#define HOST_LONG_BITS $HOST_LONGBITS" >> $config_h
422if [ "$HAVE_BYTESWAP_H" = "yes" ] ; then
David Turnerb8fec3e2010-09-09 18:15:23 +0200423 echo "#define CONFIG_BYTESWAP_H 1" >> $config_h
424fi
425if [ "$HAVE_MACHINE_BYTESWAP_H" = "yes" ] ; then
426 echo "#define CONFIG_MACHINE_BSWAP_H 1" >> $config_h
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800427fi
David Turner80dd1262010-09-09 18:04:49 +0200428if [ "$HAVE_FNMATCH_H" = "yes" ] ; then
429 echo "#define CONFIG_FNMATCH 1" >> $config_h
430fi
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800431echo "#define CONFIG_GDBSTUB 1" >> $config_h
432echo "#define CONFIG_SLIRP 1" >> $config_h
433echo "#define CONFIG_SKINS 1" >> $config_h
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200434echo "#define CONFIG_TRACE 1" >> $config_h
David 'Digit' Turnerfd3b1a02010-05-10 23:47:54 -0700435
436# only Linux has fdatasync()
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700437case "$TARGET_OS" in
David 'Digit' Turnerfd3b1a02010-05-10 23:47:54 -0700438 linux-*)
439 echo "#define CONFIG_FDATASYNC 1" >> $config_h
440 ;;
441esac
442
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800443# the -nand-limits options can only work on non-windows systems
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700444if [ "$TARGET_OS" != "windows" ] ; then
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800445 echo "#define CONFIG_NAND_LIMITS 1" >> $config_h
446fi
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700447echo "#define QEMU_VERSION \"0.10.50\"" >> $config_h
448echo "#define QEMU_PKGVERSION \"Android\"" >> $config_h
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800449case "$CPU" in
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200450 x86) CONFIG_CPU=I386
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800451 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200452 ppc) CONFIG_CPU=PPC
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800453 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200454 x86_64) CONFIG_CPU=X86_64
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800455 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200456 *) CONFIG_CPU=$CPU
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800457 ;;
458esac
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200459echo "#define HOST_$CONFIG_CPU 1" >> $config_h
Marcus Comstedt17d31322010-10-05 21:54:12 +0200460if [ "$HOST_BIGENDIAN" = "1" ] ; then
461 echo "#define HOST_WORDS_BIGENDIAN 1" >> $config_h
462fi
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200463BSD=0
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700464case "$TARGET_OS" in
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200465 linux-*) CONFIG_OS=LINUX
466 ;;
467 darwin-*) CONFIG_OS=DARWIN
468 BSD=1
469 ;;
Alexey Tarasov08823222009-09-01 02:07:51 +1100470 freebsd-*) CONFIG_OS=FREEBSD
471 BSD=1
472 ;;
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200473 windows*) CONFIG_OS=WIN32
474 ;;
475 *) CONFIG_OS=$OS
476esac
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700477
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800478if [ "$OPTION_STATIC" = "yes" ] ; then
479 echo "CONFIG_STATIC_EXECUTABLE := true" >> $config_mk
480 echo "#define CONFIG_STATIC_EXECUTABLE 1" >> $config_h
481fi
482
David 'Digit' Turner377eb2c2010-05-20 15:16:28 -0700483case $TARGET_OS in
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700484 linux-*|darwin-*)
David 'Digit' Turner3d66dc72010-01-27 18:18:41 -0800485 echo "#define CONFIG_IOVEC 1" >> $config_h
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700486 ;;
487esac
488
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200489echo "#define CONFIG_$CONFIG_OS 1" >> $config_h
490if [ $BSD = 1 ] ; then
David 'Digit' Turner2c538c82010-05-10 16:48:20 -0700491 echo "#define CONFIG_BSD 1" >> $config_h
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200492 echo "#define O_LARGEFILE 0" >> $config_h
493 echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
494fi
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700495
David 'Digit' Turnere92bc562010-09-07 06:21:25 -0700496echo "#define CONFIG_ANDROID 1" >> $config_h
497
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800498log "Generate : $config_h"
499
500echo "Ready to go. Type 'make' to build emulator"