#!/bin/sh # __________ __ ___. # Open \______ \ ____ ____ | | _\_ |__ _______ ___ # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ # \/ \/ \/ \/ \/ # $Id$ # # global CC options for all platforms CCOPTS="-W -Wall -Wundef -O -nostdlib -ffreestanding -Wstrict-prototypes -pipe -std=gnu99" # global LD options for all platforms GLOBAL_LDOPTS="" extradefines="" use_logf="#undef ROCKBOX_HAS_LOGF" use_bootchart="#undef DO_BOOTCHART" scriptver=`echo '$Revision$' | sed -e 's:\\$::g' -e 's/Revision: //'` rbdir="/.rockbox" need_full_path= bindir= libdir= sharedir= app_platform= app_lcd_width= app_lcd_height= # # Begin Function Definitions # input() { read response echo $response } prefixtools () { prefix="$1" CC=${prefix}gcc WINDRES=${prefix}windres DLLTOOL=${prefix}dlltool DLLWRAP=${prefix}dllwrap RANLIB=${prefix}ranlib LD=${prefix}ld AR=${prefix}ar AS=${prefix}as OC=${prefix}objcopy } app_get_platform() { echo "Select your platform: (S)DL, (A)ndroid (default: Android)" if [ -z "$ARG_PLATFORM" ]; then choice=`input` else choice="$ARG_PLATFORM" fi case $choice in s|S*) app_platform="sdl" ;; *|a|A*) app_platform="android" ;; esac echo "Selected $app_platform platform" echo "Enter the LCD width (default: 320)" if [ -z "$ARG_LCDWIDTH" ]; then app_lcd_width=`input` else app_lcd_width="$ARG_LCDWIDTH" fi if [ -z "$app_lcd_width" ]; then app_lcd_width="320"; fi echo "Enter the LCD height (default: 480)" if [ -z "$ARG_LCDHEIGHT" ]; then app_lcd_height=`input` else app_lcd_height="$ARG_LCDHEIGHT" fi if [ -z "$app_lcd_height" ]; then app_lcd_height="480"; fi echo "Selected $app_lcd_width x $app_lcd_height resolution" ARG_LCDWIDTH=$app_lcd_width ARG_LCDHEIGHT=$app_lcd_height app_lcd_width="#define LCD_WIDTH $app_lcd_width" app_lcd_height="#define LCD_HEIGHT $app_lcd_height" # setup files and paths depending on the platform if [ "$app_platform" = "sdl" ]; then if [ -z "$ARG_PREFIX" ]; then sharedir="/usr/local/share/rockbox" bindir="/usr/local/bin" libdir="/usr/local/lib" else if [ -d "$ARG_PREFIX" ]; then if [ -z `echo $ARG_PREFIX | grep "^/"` ]; then ARG_PREFIX=`realpath $ARG_PREFIX` if [ "0" != "$?" ]; then echo "ERROR: Could not get prefix path (is realpath installed?)." exit fi fi sharedir="$ARG_PREFIX/share/rockbox" bindir="$ARG_PREFIX/bin" libdir="$ARG_PREFIX/lib" else echo "ERROR: PREFIX does not exist" exit fi fi output="rockbox" bootoutput="rockbox" elif [ "$app_platform" = "android" ]; then if [ -n "$PREFIX" ]; then echo "WARNING: PREFIX not supported on Android. You can however use --rbdir" fi if [ -z "$ANDROID_SDK_PATH" ]; then echo "ERROR: You need the Android SDK installed and have the ANDROID_SDK_PATH" echo "environment variable point to the root directory of the Android SDK." exit fi if [ -z "$ANDROID_NDK_PATH" ]; then echo "ERROR: You need the Android NDK installed (r5 or higher) and have the ANDROID_NDK_PATH" echo "environment variable point to the root directory of the Android NDK." exit fi sharedir="/data/data/org.rockbox/app_rockbox/rockbox" bindir="/data/data/org.rockbox/lib" libdir="/data/data/org.rockbox/app_rockbox" output="librockbox.so" bootoutput="librockbox.so" fi } findarmgcc() { if [ "$ARG_ARM_EABI" != "0" ]; then prefixtools arm-elf-eabi- gccchoice="4.4.4" else prefixtools arm-elf- gccchoice="4.0.3" fi } # scan the $PATH for the given command findtool(){ file="$1" IFS=":" for path in $PATH do # echo "checks for $file in $path" >&2 if test -f "$path/$file"; then echo "$path/$file" return fi done # check whether caller wants literal return value if not found if [ "$2" = "--lit" ]; then echo "$file" fi } # scan the $PATH for sdl-config - check whether for a (cross-)win32 # sdl as requested findsdl(){ file="sdl-config" winbuild="$1" IFS=":" for path in $PATH do #echo "checks for $file in $path" >&2 if test -f "$path/$file"; then if [ "0" != `$path/$file --libs |grep -c mwindows` ]; then if [ "yes" = "${winbuild}" ]; then echo "$path/$file" return fi else if [ "yes" != "${winbuild}" ]; then echo "$path/$file" return fi fi fi done } appcc () { if [ "$1" = "sdl" ]; then simcc "sdl-app" elif [ "$1" = "android" ]; then app_type=$1 androidcc fi } simcc () { # default tool setup for native building prefixtools "$CROSS_COMPILE" ARG_ARM_THUMB=0 # can't use thumb in native builds app_type=$1 winbuild="" GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib// -e s/-Wundef// -e s/-O//` GCCOPTS="$GCCOPTS -fno-builtin -g" GCCOPTIMIZE='' LDOPTS='-lm' # button-sdl.c uses sqrt() # default output binary name, don't override app_get_platform() if [ "$app_type" != "sdl-app" ]; then output="rockboxui" fi # default share option, override below if needed SHARED_FLAG="-shared" if [ "$win32crosscompile" = "yes" ]; then LDOPTS="$LDOPTS -mconsole" output="$output.exe" winbuild="yes" else case $uname in CYGWIN*) echo "Cygwin host detected" LDOPTS="$LDOPTS -mconsole" output="$output.exe" winbuild="yes" ;; MINGW*) echo "MinGW host detected" LDOPTS="$LDOPTS -mconsole" output="$output.exe" winbuild="yes" ;; Linux) echo "Linux host detected" LDOPTS="$LDOPTS -ldl" ;; FreeBSD) echo "FreeBSD host detected" LDOPTS="$LDOPTS -ldl" ;; Darwin) echo "Darwin host detected" LDOPTS="$LDOPTS -ldl" SHARED_FLAG="-dynamiclib -Wl\,-single_module" ;; SunOS) echo "*Solaris host detected" GCCOPTS="$GCCOPTS -fPIC" LDOPTS="$LDOPTS -ldl" ;; *) echo "[ERROR] Unsupported system: $uname, fix configure and retry" exit 1 ;; esac fi [ "$winbuild" != "yes" ] && GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" sdl=`findsdl $winbuild` if [ -n `echo $app_type | grep "sdl"` ]; then if [ -z "$sdl" ]; then echo "configure didn't find sdl-config, which indicates that you" echo "don't have SDL (properly) installed. Please correct and" echo "re-run configure!" exit 2 else # generic sdl-config checker GCCOPTS="$GCCOPTS `$sdl --cflags`" LDOPTS="$LDOPTS `$sdl --libs`" fi fi GCCOPTS="$GCCOPTS -I\$(SIMDIR)" if test "X$win32crosscompile" != "Xyes"; then case `uname -m` in x86_64|amd64) # fPIC is needed to make shared objects link # setting visibility to hidden is necessary to avoid strange crashes # due to symbol clashing GCCOPTS="$GCCOPTS -fPIC -fvisibility=hidden" # x86_64 supports MMX by default ;; i686) echo "Enabling MMX support" GCCOPTS="$GCCOPTS -mmmx" ;; esac id=$$ cat >$tmpdir/conftest-$id.c < int main(int argc, char **argv) { int var=0; char *varp = (char *)&var; *varp=1; printf("%d\n", var); return 0; } EOF $CC -o $tmpdir/conftest-$id $tmpdir/conftest-$id.c 2>/dev/null # when cross compiling, the endianess cannot be detected because the above program doesn't run # on the local machine. assume little endian but print a warning endian=`$tmpdir/conftest-$id 2> /dev/null` if [ "$endian" != "" ] && [ $endian -gt "1" ]; then # big endian endian="big" else # little endian endian="little" fi if [ "$CROSS_COMPILE" != "" ]; then echo "WARNING: Cross Compiling, cannot detect endianess. Assuming little endian!" fi if [ "$app_type" = "sdl-sim" ]; then echo "Simulator environment deemed $endian endian" elif [ "$app_type" = "sdl-app" ]; then echo "Application environment deemed $endian endian" elif [ "$app_type" = "checkwps" ]; then echo "CheckWPS environment deemed $endian endian" fi # use wildcard here to make it work even if it was named *.exe like # on cygwin rm -f $tmpdir/conftest-$id* else # We are crosscompiling # add cross-compiler option(s) prefixtools i586-mingw32msvc- LDOPTS="$LDOPTS -mconsole" output="rockboxui.exe" endian="little" # windows is little endian echo "Enabling MMX support" GCCOPTS="$GCCOPTS -mmmx" fi } # # functions for setting up cross-compiler names and options # also set endianess and what the exact recommended gcc version is # the gcc version should most likely match what versions we build with # rockboxdev.sh # shcc () { prefixtools sh-elf- GCCOPTS="$CCOPTS -m1" GCCOPTIMIZE="-fomit-frame-pointer -fschedule-insns" endian="big" gccchoice="4.0.3" } calmrisccc () { prefixtools calmrisc16-unknown-elf- GCCOPTS="-Wl\,--no-check-sections $CCOPTS" GCCOPTIMIZE="-fomit-frame-pointer" endian="big" } coldfirecc () { prefixtools m68k-elf- GCCOPTS="$CCOPTS -m5206e -Wa\,-m5249 -malign-int -mstrict-align" GCCOPTIMIZE="-fomit-frame-pointer" endian="big" gccchoice="3.4.6" } arm7tdmicc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm7tdmi" if test "X$1" != "Xshort" -a "$ARG_ARM_EABI" = "0"; then GCCOPTS="$GCCOPTS -mlong-calls" fi GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm9tdmicc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm9tdmi" if test "$modelname" != "gigabeatfx" -a "$t_manufacturer" != "as3525" -a "$ARG_ARM_EABI" = "0"; then GCCOPTS="$GCCOPTS -mlong-calls" fi GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm940tbecc () { findarmgcc GCCOPTS="$CCOPTS -mbig-endian -mcpu=arm940t" if test "$ARG_ARM_EABI" = "0"; then GCCOPTS="$GCCOPTS -mlong-calls" fi GCCOPTIMIZE="-fomit-frame-pointer" endian="big" } arm940tcc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm940t" if test "$ARG_ARM_EABI" = "0"; then GCCOPTS="$GCCOPTS -mlong-calls" fi GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm946cc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm9e" if test "$ARG_ARM_EABI" = "0"; then GCCOPTS="$GCCOPTS -mlong-calls" fi GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm926ejscc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm926ej-s" if test "$t_manufacturer" != "as3525" -a "$ARG_ARM_EABI" = "0"; then GCCOPTS="$GCCOPTS -mlong-calls" fi GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm1136jfscc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm1136jf-s" if test "$modelname" != "gigabeats" -a "$ARG_ARM_EABI" = "0"; then GCCOPTS="$GCCOPTS -mlong-calls" fi GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm1176jzscc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm1176jz-s" if test "$ARG_ARM_EABI" = "0"; then GCCOPTS="$GCCOPTS -mlong-calls" fi GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } mipselcc () { prefixtools mipsel-elf- # mips is predefined, but we want it for paths. use __mips instead GCCOPTS="$CCOPTS -march=mips32 -mtune=r4600 -mno-mips16 -mno-long-calls -Umips" GCCOPTS="$GCCOPTS -ffunction-sections -msoft-float -G 0 -Wno-parentheses" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" gccchoice="4.1.2" } androidcc () { gccchoice="4.4.3" gcctarget="arm-linux-androideabi-" gccprefix=$ANDROID_NDK_PATH/toolchains/$gcctarget$gccchoice/prebuilt/linux-x86 PATH=$PATH:$gccprefix/bin prefixtools $gcctarget GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib// -e s/-Wundef//` GCCOPTS="$GCCOPTS -ffunction-sections -march=armv5te -mtune=xscale -msoft-float -fomit-frame-pointer \ --sysroot=$ANDROID_NDK_PATH/platforms/android-4/arch-arm" GLOBAL_LDOPTS="$GLOBAL_LDOPTS -nostdlib -lc -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack \ --sysroot=$ANDROID_NDK_PATH/platforms/android-4/arch-arm" LDOPTS="$LDOPTS -shared -nostdlib -ldl -llog" extradefines="$extradefines -DANDROID" endian="little" SHARED_FLAG="-shared" } whichadvanced () { atype=`echo "$1" | cut -c 2-` ################################################################## # Prompt for specific developer options # if [ "$atype" ]; then interact= else interact=1 echo "" printf "Enter your developer options (press only enter when done)\n\ (D)EBUG, (L)ogf, Boot(c)hart, (S)imulator, (P)rofiling, (V)oice, (W)in32 crosscompile,\n\ (T)est plugins, S(m)all C lib:" if [ "$memory" = "2" ]; then printf ", (8)MB MOD" fi if [ "$modelname" = "archosplayer" ]; then printf ", Use (A)TA poweroff" fi if [ "$t_model" = "ondio" ]; then printf ", (B)acklight MOD" fi if [ "$modelname" = "iaudiom5" ]; then printf ", (F)M radio MOD" fi if [ "$modelname" = "iriverh120" ]; then printf ", (R)TC MOD" fi echo "" fi cont=1 while [ $cont = "1" ]; do if [ "$interact" ]; then option=`input` else option=`echo "$atype" | cut -c 1` fi case $option in [Dd]) if [ "yes" = "$profile" ]; then echo "Debug is incompatible with profiling" else echo "DEBUG build enabled" use_debug="yes" fi ;; [Ll]) echo "logf() support enabled" logf="yes" ;; [Mm]) echo "Using Rockbox' small C library" extradefines="$extradefines -DHAVE_ROCKBOX_C_LIBRARY" ;; [Tt]) echo "Including test plugins" extradefines="$extradefines -DHAVE_TEST_PLUGINS" ;; [Cc]) echo "bootchart enabled (logf also enabled)" bootchart="yes" logf="yes" ;; [Ss]) echo "Simulator build enabled" simulator="yes" ;; [Pp]) if [ "yes" = "$use_debug" ]; then echo "Profiling is incompatible with debug" else echo "Profiling support is enabled" profile="yes" fi ;; [Vv]) echo "Voice build selected" voice="yes" ;; 8) if [ "$memory" = "2" ]; then memory="8" echo "Memory size selected: 8MB" fi ;; [Aa]) if [ "$modelname" = "archosplayer" ]; then have_ata_poweroff="#define HAVE_ATA_POWER_OFF" echo "ATA power off enabled" fi ;; [Bb]) if [ "$t_model" = "ondio" ]; then have_backlight="#define HAVE_BACKLIGHT" echo "Backlight functions enabled" fi ;; [Ff]) if [ "$modelname" = "iaudiom5" ]; then have_fmradio_in="#define HAVE_FMRADIO_IN" echo "FM radio functions enabled" fi ;; [Rr]) if [ "$modelname" = "iriverh120" ]; then config_rtc="#define CONFIG_RTC RTC_DS1339_DS3231" have_rtc_alarm="#define HAVE_RTC_ALARM" echo "RTC functions enabled (DS1339/DS3231)" fi ;; [Ww]) echo "Enabling Windows 32 cross-compiling" win32crosscompile="yes" ;; "") # Match enter press when finished with advanced options cont=0 ;; *) echo "[ERROR] Option $option unsupported" ;; esac if [ "$interact" ]; then btype="$btype$option" else atype=`echo "$atype" | cut -c 2-` [ "$atype" ] || cont=0 fi done echo "done" if [ "yes" = "$voice" ]; then # Ask about languages to build picklang voicelanguage=`whichlang` echo "Voice language set to $voicelanguage" # Configure encoder and TTS engine for each language for thislang in `echo $voicelanguage | sed 's/,/ /g'`; do voiceconfig "$thislang" done fi if [ "yes" = "$use_debug" ]; then debug="-DDEBUG" GCCOPTS="$GCCOPTS -g -DDEBUG" fi if [ "yes" = "$logf" ]; then use_logf="#define ROCKBOX_HAS_LOGF 1" fi if [ "yes" = "$bootchart" ]; then use_bootchart="#define DO_BOOTCHART 1" fi if [ "yes" = "$simulator" ]; then debug="-DDEBUG" extradefines="$extradefines -DSIMULATOR" archosrom="" flash="" fi if [ "yes" = "$profile" ]; then extradefines="$extradefines -DRB_PROFILE" PROFILE_OPTS="-finstrument-functions" fi } # Configure voice settings voiceconfig () { thislang=$1 if [ ! "$ARG_TTS" ]; then echo "Building $thislang voice for $modelname. Select options" echo "" fi if [ -n "`findtool flite`" ]; then FLITE="F(l)ite " FLITE_OPTS="" DEFAULT_TTS="flite" DEFAULT_TTS_OPTS=$FLITE_OPTS DEFAULT_NOISEFLOOR="500" DEFAULT_CHOICE="L" fi if [ -n "`findtool espeak`" ]; then ESPEAK="(e)Speak " ESPEAK_OPTS="" DEFAULT_TTS="espeak" DEFAULT_TTS_OPTS=$ESPEAK_OPTS DEFAULT_NOISEFLOOR="500" DEFAULT_CHOICE="e" fi if [ -n "`findtool festival`" ]; then FESTIVAL="(F)estival " case "$thislang" in "italiano") FESTIVAL_OPTS="--language italian" ;; "espanol") FESTIVAL_OPTS="--language spanish" ;; "finnish") FESTIVAL_OPTS="--language finnish" ;; "czech") FESTIVAL_OPTS="--language czech" ;; *) FESTIVAL_OPTS="" ;; esac DEFAULT_TTS="festival" DEFAULT_TTS_OPTS=$FESTIVAL_OPTS DEFAULT_NOISEFLOOR="500" DEFAULT_CHOICE="F" fi if [ -n "`findtool swift`" ]; then SWIFT="S(w)ift " SWIFT_OPTS="" DEFAULT_TTS="swift" DEFAULT_TTS_OPTS=$SWIFT_OPTS DEFAULT_NOISEFLOOR="500" DEFAULT_CHOICE="w" fi # Allow SAPI if Windows is in use if [ -n "`findtool winver`" ]; then SAPI="(S)API " SAPI_OPTS="" DEFAULT_TTS="sapi" DEFAULT_TTS_OPTS=$SAPI_OPTS DEFAULT_NOISEFLOOR="500" DEFAULT_CHOICE="S" fi if [ "$FESTIVAL" = "$FLITE" ] && [ "$FLITE" = "$ESPEAK" ] && [ "$ESPEAK" = "$SAPI" ] && [ "$SAPI" = "$SWIFT" ]; then echo "You need Festival, eSpeak or Flite in your path, or SAPI available to build voice files" exit 3 fi if [ "$ARG_TTS" ]; then option=$ARG_TTS else echo "TTS engine to use: ${FLITE}${FESTIVAL}${ESPEAK}${SAPI}${SWIFT}(${DEFAULT_CHOICE})?" option=`input` fi advopts="$advopts --tts=$option" case "$option" in [Ll]) TTS_ENGINE="flite" NOISEFLOOR="500" # TODO: check this value TTS_OPTS=$FLITE_OPTS ;; [Ee]) TTS_ENGINE="espeak" NOISEFLOOR="500" TTS_OPTS=$ESPEAK_OPTS ;; [Ff]) TTS_ENGINE="festival" NOISEFLOOR="500" TTS_OPTS=$FESTIVAL_OPTS ;; [Ss]) TTS_ENGINE="sapi" NOISEFLOOR="500" TTS_OPTS=$SAPI_OPTS ;; [Ww]) TTS_ENGINE="swift" NOISEFLOOR="500" TTS_OPTS=$SWIFT_OPTS ;; *) TTS_ENGINE=$DEFAULT_TTS TTS_OPTS=$DEFAULT_TTS_OPTS NOISEFLOOR=$DEFAULT_NOISEFLOOR esac echo "Using $TTS_ENGINE for TTS" # Select which voice to use for Festival if [ "$TTS_ENGINE" = "festival" ]; then voicelist=`echo "(voice.list)"|festival -i 2>/dev/null |tr "\n" " "|sed -e 's/.*festival> (\(.*\)) festival>/\1/'|sort` for voice in $voicelist; do TTS_FESTIVAL_VOICE="$voice" # Default choice break done if [ "$ARG_VOICE" ]; then CHOICE=$ARG_VOICE else i=1 for voice in $voicelist; do printf "%3d. %s\n" "$i" "$voice" i=`expr $i + 1` done printf "Please select which Festival voice to use (default is $TTS_FESTIVAL_VOICE): " CHOICE=`input` fi i=1 for voice in $voicelist; do if [ "$i" = "$CHOICE" -o "$voice" = "$CHOICE" ]; then TTS_FESTIVAL_VOICE="$voice" fi i=`expr $i + 1` done advopts="$advopts --voice=$CHOICE" echo "Festival voice set to $TTS_FESTIVAL_VOICE" echo "(voice_$TTS_FESTIVAL_VOICE)" > festival-prolog.scm fi # Read custom tts options from command line if [ "$ARG_TTSOPTS" ]; then TTS_OPTS="$ARG_TTSOPTS" advopts="$advopts --ttsopts='$TTS_OPTS'" echo "$TTS_ENGINE options set to $TTS_OPTS" fi if [ "$swcodec" = "yes" ]; then ENCODER="rbspeexenc" ENC_CMD="rbspeexenc" ENC_OPTS="-q 4 -c 10" else if [ -n "`findtool lame`" ]; then ENCODER="lame" ENC_CMD="lame" ENC_OPTS="--resample 12 -t -m m -h -V 9.999 -S -B 64 --vbr-new" else echo "You need LAME in the system path to build voice files for" echo "HWCODEC targets." exit 4 fi fi echo "Using $ENCODER for encoding voice clips" # Read custom encoder options from command line if [ "$ARG_ENCOPTS" ]; then ENC_OPTS="$ARG_ENCOPTS" advopts="$advopts --encopts='$ENC_OPTS'" echo "$ENCODER options set to $ENC_OPTS" fi TEMPDIR="${pwd}" if [ -n "`findtool cygpath`" ]; then TEMPDIR=`cygpath . -a -w` fi } picklang() { # figure out which languages that are around for file in $rootdir/apps/lang/*.lang; do clean=`basename $file .lang` langs="$langs $clean" done if [ "$ARG_LANG" ]; then pick=$ARG_LANG else echo "Select a number for the language to use (default is english)" # FIXME The multiple-language feature is currently broken # echo "You may enter a comma-separated list of languages to build" num=1 for one in $langs; do echo "$num. $one" num=`expr $num + 1` done pick=`input` fi advopts="$advopts --language=$pick" } whichlang() { output="" # Allow the user to pass a comma-separated list of langauges for thispick in `echo $pick | sed 's/,/ /g'`; do num=1 for one in $langs; do # Accept both the language number and name if [ "$num" = "$thispick" ] || [ "$thispick" = "$one" ]; then if [ "$output" = "" ]; then output=$one else output=$output,$one fi fi num=`expr $num + 1` done done if [ -z "$output" ]; then # pick a default output="english" fi echo $output } help() { echo "Rockbox configure script." echo "Invoke this in a directory to generate a Makefile to build Rockbox" echo "Do *NOT* run this within the tools directory!" echo "" cat </dev/null 2>&1 ; } then echo "WEEEEEEEEP. Don't run this configure script within the tools directory." echo "It will only cause you pain and grief. Instead do this:" echo "" echo " cd .." echo " mkdir build-dir" echo " cd build-dir" echo " ../tools/configure" echo "" echo "Much happiness will arise from this. Enjoy" exit 5 fi fi # get our current directory pwd=`pwd`; if { echo $pwd | grep " "; } then echo "You're running this script in a path that contains space. The build" echo "system is unfortunately not clever enough to deal with this. Please" echo "run the script from a different path, rename the path or fix the build" echo "system!" exit 6 fi if [ -z "$rootdir" ]; then ################################################################## # Figure out where the source code root is! # rootdir=`dirname $0`/../ ##################################################################### # Convert the possibly relative directory name to an absolute version # now=`pwd` cd $rootdir rootdir=`pwd` # cd back to the build dir cd $now fi apps="apps" appsdir='\$(ROOTDIR)/apps' firmdir='\$(ROOTDIR)/firmware' toolsdir='\$(ROOTDIR)/tools' ################################################################## # Figure out target platform # if [ "$ARG_TARGET" ]; then buildfor=$ARG_TARGET else echo "Enter target platform:" cat <&1 | sed -e 's/[^0-9.-]//g'` else ldver=`$LD --version | head -n 1 | sed -e 's/[^0-9.]//g'` fi if [ -z "$gccver" ]; then echo "[WARNING] The compiler you must use ($CC) is not in your path!" echo "[WARNING] this may cause your build to fail since we cannot do the" echo "[WARNING] checks we want now." else # gccver should now be "3.3.5", "3.4.3", "2.95.3-6" and similar, but don't # DEPEND on it num1=`echo $gccver | cut -d . -f1` num2=`echo $gccver | cut -d . -f2` gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null` # This makes: # 3.3.X => 303 # 3.4.X => 304 # 2.95.3 => 295 echo "Using $CC $gccver ($gccnum)" if test "$gccnum" -ge "400"; then # gcc 4.0 is just *so* much pickier on arguments that differ in signedness # so we ignore that warnings for now # -Wno-pointer-sign GCCOPTS="$GCCOPTS -Wno-pointer-sign" fi if test "$gccnum" -ge "402"; then # disable warning about "warning: initialized field overwritten" as gcc 4.2 # and later would throw it for several valid cases GCCOPTS="$GCCOPTS -Wno-override-init" fi case $prefix in ""|"$CROSS_COMPILE") # simulator ;; i586-mingw32msvc-) # cross-compile for win32 ;; *) # Verify that the cross-compiler is of a recommended version! if test "$gccver" != "$gccchoice"; then echo "WARNING: Your cross-compiler $CC $gccver is not of the recommended" echo "WARNING: version $gccchoice!" echo "WARNING: This may cause your build to fail since it may be a version" echo "WARNING: that isn't functional or known to not be the best choice." echo "WARNING: If you suffer from build problems, you know that this is" echo "WARNING: a likely source for them..." fi ;; esac fi echo "Using $LD $ldver" # check the compiler for SH platforms if test "$CC" = "sh-elf-gcc"; then if test "$gccnum" -lt "400"; then echo "WARNING: Consider upgrading your compiler to the 4.0.X series!" echo "WARNING: http://www.rockbox.org/twiki/bin/view/Main/CrossCompiler" else # figure out patch status gccpatch=`$CC --version`; if { echo $gccpatch | grep "rockbox" >/dev/null 2>&1; } then echo "gcc $gccver is rockbox patched" # then convert -O to -Os to get smaller binaries! GCCOPTS=`echo $GCCOPTS | sed 's/ -O / -Os /'` else echo "WARNING: You use an unpatched gcc compiler: $gccver" echo "WARNING: http://www.rockbox.org/twiki/bin/view/Main/CrossCompiler" fi fi fi if test "$CC" = "m68k-elf-gcc"; then # convert -O to -Os to get smaller binaries! GCCOPTS=`echo $GCCOPTS | sed 's/ -O / -Os /'` fi if [ "$ARG_CCACHE" = "1" ]; then echo "Enable ccache for building" ccache="ccache" elif [ "$ARG_CCACHE" != "0" ]; then ccache=`findtool ccache` if test -n "$ccache"; then echo "Found and uses ccache ($ccache)" fi fi # figure out the full path to the various commands if possible HOSTCC=`findtool gcc --lit` HOSTAR=`findtool ar --lit` CC=`findtool ${CC} --lit` LD=`findtool ${AR} --lit` AR=`findtool ${AR} --lit` AS=`findtool ${AS} --lit` OC=`findtool ${OC} --lit` WINDRES=`findtool ${WINDRES} --lit` DLLTOOL=`findtool ${DLLTOOL} --lit` DLLWRAP=`findtool ${DLLWRAP} --lit` RANLIB=`findtool ${RANLIB} --lit` if test -n "$ccache"; then CC="$ccache $CC" fi if test "$ARG_ARM_THUMB" = "1"; then extradefines="$extradefines -DUSE_THUMB" CC="$toolsdir/thumb-cc.py $CC" fi if test "X$endian" = "Xbig"; then defendian="ROCKBOX_BIG_ENDIAN" else defendian="ROCKBOX_LITTLE_ENDIAN" fi if [ "$ARG_RBDIR" != "" ]; then if [ -z `echo $ARG_RBDIR | grep '^/'` ]; then rbdir="/"$ARG_RBDIR else rbdir=$ARG_RBDIR fi echo "Using alternate rockbox dir: ${rbdir}" fi sed > autoconf.h \ -e "s<@ENDIAN@<${defendian} Makefile \ -e "s<@ROOTDIR@<${rootdir}