#!/bin/sh # __________ __ ___. # Open \______ \ ____ ____ | | _\_ |__ _______ ___ # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ # \/ \/ \/ \/ \/ # # global CC options for all platforms CCOPTS="-W -Wall -Wextra -Wundef -Os -nostdlib -ffreestanding -Wstrict-prototypes -pipe -std=gnu99 -funit-at-a-time -fno-delete-null-pointer-checks -fno-strict-overflow" # LD options for the core LDOPTS="" # LD options for the core + plugins GLOBAL_LDOPTS="" LDMAP_OPT="-Map" extradefines="" use_logf="#undef ROCKBOX_HAS_LOGF" use_bootchart="#undef DO_BOOTCHART" use_logf_serial="#undef LOGF_SERIAL" scriptver=`echo '$Revision$' | sed -e 's:\\$::g' -e 's/Revision: //'` rbdir="/.rockbox" bindir= libdir= sharedir= sdl_config=sdl2-config arm_thumb_boot= thread_support="ASSEMBLER_THREADS" sysfont="08-Schumacher-Clean" app_lcd_width= app_lcd_height= app_lcd_orientation= # Properly retain command line arguments containing spaces cmdline= for arg in "$@"; do case "$arg" in *\ *) cmdline="$cmdline \"$arg\"";; *) cmdline="$cmdline $arg";; esac done # # Begin Function Definitions # input() { read response echo $response } prefixtools () { prefix="$1" if [ -n "$ARG_COMPILER_PREFIX" ]; then echo "WARNING: asked to override target toolchain $1 with $ARG_COMPILER_PREFIX" echo "WARNING: overriding the toolchain means you are running an untested configuration" echo "WARNING: you build might be broken because of that" prefix="$ARG_COMPILER_PREFIX" fi CC=${prefix}gcc CPP=${prefix}cpp WINDRES=${prefix}windres DLLTOOL=${prefix}dlltool DLLWRAP=${prefix}dllwrap RANLIB=${prefix}gcc-ranlib LD=${prefix}ld AR=${prefix}gcc-ar AS=${prefix}as OC=${prefix}objcopy } app_set_paths () { # setup files and paths depending on the platform 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 directory $ARG_PREFIX does not exist" exit fi fi } # Set the application LCD size according to the following priorities: # 1) If --lcdwidth and --lcdheight are set, use them # 2) If a size is passed to the app_set_lcd_size() function, use that # 3) Otherwise ask the user app_set_lcd_size () { if [ -z "$ARG_LCDWIDTH" ]; then ARG_LCDWIDTH=$1 fi if [ -z "$ARG_LCDHEIGHT" ]; then ARG_LCDHEIGHT=$2 fi 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 if [ $app_lcd_width -gt $app_lcd_height ]; then lcd_orientation="landscape" else lcd_orientation="portrait" fi echo "Selected $app_lcd_width x $app_lcd_height resolution ($lcd_orientation)" 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" } findarmgcc() { prefixtools arm-elf-eabi- gccchoice="4.9.4" } # 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(){ files=${sdl_config} if [ -n "$CROSS_COMPILE" ]; then # ${sdl_config} might (not) be prefixed for cross compiles so try both. files="${CROSS_COMPILE}${sdl_config}:${files}" fi winbuild="$1" paths2check="$PATH" if [ -n "$CROSS_COMPILE" ]; then # add cross compile sys-root-directories to search in: sysroot=$($CPP --print-sysroot 2>&1) if [ $? -eq 0 ]; then subdirs="bin:mingw/bin:sbin:mingw/sbin" IFS=":" for subdir in $subdirs do if [ -e "${sysroot}/${subdir}" ]; then paths2check="${sysroot}/${subdir}:${paths2check}" fi done else echo "WARNING: unable to get sys-root directory from your cross-compiler" >&2 echo "WARNING: $CPP --print-sysroot returns" >&2 echo "WARNING: ${sysroot}" >&2 fi fi # search for the correct ${sdl_config} IFS=":" for path in $paths2check do for file in $files do 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 done } # check for availability of sigaltstack to support our thread engine check_sigaltstack() { cat >$tmpdir/check_threads.c < int main(int argc, char **argv) { #ifndef NULL #define NULL (void*)0 #endif sigaltstack(NULL, NULL); return 0; } EOF $CC -o $tmpdir/check_threads $tmpdir/check_threads.c 1> /dev/null result=$? rm -rf $tmpdir/check_threads* echo $result } # check for availability of Fiber on Win32 to support our thread engine check_fiber() { cat >$tmpdir/check_threads.c < int main(int argc, char **argv) { ConvertThreadToFiber(NULL); return 0; } EOF $CC -o $tmpdir/check_threads $tmpdir/check_threads.c 2>/dev/null result=$? rm -rf $tmpdir/check_threads* echo $result } simcc () { # default tool setup for native building prefixtools "$CROSS_COMPILE" ARG_ARM_THUMB=0 # can't use thumb in native builds # unset arch if already set shcc() and friends arch= arch_version= app_type=$1 winbuild="" macbuild="" GCCOPTS=`echo $CCOPTS | sed -e s/\ -ffreestanding// -e s/\ -nostdlib// -e s/\ -Wundef//` if [ "yes" = "$use_debug" ]; then GCCOPTS=`echo $GCCOPTS | sed -e s/\ -Os/\ -Og/` fi GCCOPTS="$GCCOPTS -fno-builtin -g" if [ "$ARG_ADDR_SAN" = "1" ] ; then # Use AddressSanitizer! echo "Using AddressSanitizer" GCCOPTS="$GCCOPTS -fsanitize=address -fPIC" LDOPTS="$LDOPTS -fsanitize=address -lasan" fi if [ "$ARG_UBSAN" = "1" ] ; then echo "Using UBSan" GCCOPTS="$GCCOPTS -fsanitize=undefined -fPIC" LDOPTS="$LDOPTS -fsanitize=undefined" fi # Some linux setups like to warn about unused results. They are correct, # but cleaning this up is a lot of work. GCCOPTS="$GCCOPTS -Wno-unused-result" GCCOPTIMIZE='' LDOPTS="$LDOPTS -lm" # button-sdl.c uses sqrt() sigaltstack="" fibers="" endian="" # endianess of the dap doesnt matter here # build a 32-bit simulator if [ "$ARG_32BIT" = "1" ]; then echo "Building 32-bit simulator" GCCOPTS="$GCCOPTS -m32" LDOPTS="$LDOPTS -m32" fi # 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_LDFLAGS="-shared" SHARED_CFLAGS="-fPIC -fvisibility=hidden" if [ "$win32crosscompile" = "yes" ]; then # We are crosscompiling # add cross-compiler option(s) GCCOPTS="$GCCOPTS -Wno-format" LDOPTS="$LDOPTS -mconsole -static" GLOBAL_LDOPTS=`echo $GLOBAL_LDOPTS | sed -e s/\-Wl,-z,defs//` LDOPTS=`echo $LDOPTS | sed -e s/-ldl// -e s/-lrt// -e s/-lasound//` output="$output.exe" winbuild="yes" if [ -z "$CROSS_COMPILE" ]; then if [ "$win64" = "yes" ]; then CROSS_COMPILE=${CROSS_COMPILE:-"x86_64-w64-mingw32-"} else # different possible names; try to find the correct one: names="i686-w64-mingw32 i686-pc-mingw32 i586-mingw32msvc" for name in $names do if which "${name}-gcc" >/dev/null 2>&1 ; then CROSS_COMPILE="${name}-" break fi done if [ -z "$CROSS_COMPILE" ]; then echo "WARNING: unable to find cross-compiler for 32-bit Windows environment!" echo "WARNING: it's none of \"$names\"." echo "WARNING: set your compiler prefix with CROSS_COMPILE=\"your-prefix-\" and" echo "WARNING: re-run configure again!" exit 2 fi fi fi SHARED_CFLAGS='' prefixtools "$CROSS_COMPILE" fibers=`check_fiber` endian="little" # windows is little endian echo "Enabling MMX support" # -mno-ms-bitfields is a workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 # mingw-gcc >= 4.7 defaults to -mms-bitfields which breaks __attribute__((packed)) # disable it explicitly for the time being (it doesn't appear to be required for us) GCCOPTS="$GCCOPTS -mmmx -mno-ms-bitfields" else case $uname in CYGWIN*) echo "Cygwin host detected" fibers=`check_fiber` LDOPTS="$LDOPTS -mconsole" output="$output.exe" winbuild="yes" SHARED_CFLAGS='' ;; MINGW*) echo "MinGW host detected" fibers=`check_fiber` LDOPTS="$LDOPTS -mconsole" output="$output.exe" winbuild="yes" ;; Linux) sigaltstack=`check_sigaltstack` echo "Linux host detected" LDOPTS="$LDOPTS -ldl" # newer glibc implementations use byteswap.h if echo "#include " | gcc -E - > /dev/null 2>&1; then echo "Using byteswap.h" extradefines="$extradefines -DOS_USE_BYTESWAP_H" fi ;; FreeBSD) sigaltstack=`check_sigaltstack` echo "FreeBSD host detected" LDOPTS="$LDOPTS" ;; Darwin) sigaltstack=`check_sigaltstack` echo "Darwin host detected" if $CC --version | grep -q "clang"; then CC=gcc-15 AR=gcc-ar-15 CPP=cpp-15 fi LDOPTS="$LDOPTS -ldl" SHARED_LDFLAGS="-dynamiclib -Wl,-no_warn_duplicate_libraries" LDMAP_OPT="-map" macbuild="yes" ;; SunOS) sigaltstack=`check_sigaltstack` echo "*Solaris host detected" GCCOPTS="$GCCOPTS -fPIC" LDOPTS="$LDOPTS -ldl" ;; *) echo "[ERROR] Unsupported system: $uname, fix configure and retry" exit 1 ;; esac fi if [ "$winbuild" != "yes" ] && [ "$macbuild" != "yes" ]; then GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" if [ "`uname -m`" = "i686" ]; then echo "Enabling MMX support" GCCOPTS="$GCCOPTS -mmmx" fi fi 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 echo Using $sdl - version `$sdl --version` # generic ${sdl_config} checker sdlccopts=$($sdl --cflags) if $sdl --static-libs > /dev/null 2>&1 ; then sdlldopts=$(CC="$CC" $sdl --static-libs) else echo "Your ${sdl_config} does not know about static libs, falling back to shared library" sdlldopts=$($sdl --libs) # if [ "$win32crosscompile" = "yes" ] ; then LDOPTS=`echo $LDOPTS | sed -e s/-static//` # fi fi GCCOPTS="$GCCOPTS ${sdlccopts}" LDOPTS="$LDOPTS ${sdlldopts}" fi fi GCCOPTS="$GCCOPTS -I\$(SIMDIR)" # x86_64 supports MMX by default if [ "$endian" = "" ]; then 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 fi if [ "$CROSS_COMPILE" != "" ]; then echo "WARNING: Cross Compiling, cannot detect endianess. Assuming $endian 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* # AddressSanitizer requires SDL threads if [ "$ARG_ADDR_SAN" = "1" ] ; then ARG_THREAD_SUPPORT=1 fi if [ "$ARG_UBSAN" = "1" ] ; then ARG_THREAD_SUPPORT=1 fi thread_support= if [ -z "$ARG_THREAD_SUPPORT" ] || [ "$ARG_THREAD_SUPPORT" = "0" ]; then if [ "$sigaltstack" = "0" ]; then thread_support="HAVE_SIGALTSTACK_THREADS" LDOPTS="$LDOPTS -lpthread" # pthread needed echo "Selected sigaltstack threads" elif [ "$fibers" = "0" ]; then thread_support="HAVE_WIN32_FIBER_THREADS" echo "Selected Win32 Fiber threads" fi fi if [ -n `echo $app_type | grep "sdl"` ] && [ -z "$thread_support" ] \ && [ "$ARG_THREAD_SUPPORT" != "0" ]; then thread_support="HAVE_SDL_THREADS" if [ "$ARG_THREAD_SUPPORT" = "1" ]; then echo "Selected SDL threads" else echo "WARNING: Falling back to SDL threads" fi 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 # coldfirecc () { prefixtools m68k-elf- GCCOPTS="$CCOPTS -mcpu=5249 -malign-int -mstrict-align" GCCOPTIMIZE="-fomit-frame-pointer" endian="big" gccchoice="4.9.4" } arm7tdmicc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm7tdmi" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm9tdmicc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm9tdmi" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm940tbecc () { findarmgcc GCCOPTS="$CCOPTS -mbig-endian -mcpu=arm940t" GCCOPTIMIZE="-fomit-frame-pointer" endian="big" } arm940tcc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm940t" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm946cc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm9e" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm926ejscc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm926ej-s" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm1136jfscc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm1136jf-s -mfloat-abi=softfp" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm1176jzscc () { findarmgcc GCCOPTS="$CCOPTS -mcpu=arm1176jz-s" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } arm7ejscc () { findarmgcc GCCOPTS="$CCOPTS -march=armv5te" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" } armcortexm7cc () { findarmgcc GCCOPTS="$CCOPTS -march=armv7e-m -mcpu=cortex-m7" 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.9.4" } mipsr2elcc () { prefixtools mipsel-elf- # mips is predefined, but we want it for paths. use __mips instead GCCOPTS="$CCOPTS -march=mips32r2 -mno-mips16 -mno-long-calls -Umips" GCCOPTS="$GCCOPTS -ffunction-sections -msoft-float -G 0 -Wno-parentheses" GCCOPTIMIZE="-fomit-frame-pointer" endian="little" gccchoice="4.9.4" } maemocc () { # Scratchbox sets up "gcc" based on the active target prefixtools "" GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib// -e s/-Wundef//` GCCOPTS="$GCCOPTS -fno-builtin -g -I\$(SIMDIR)" GCCOPTIMIZE='' LDOPTS="-lm -ldl $LDOPTS" GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" SHARED_LDFLAGS="-shared" SHARED_CFLAGS='' endian="little" thread_support="HAVE_SIGALTSTACK_THREADS" is_n900=0 # Determine maemo version if pkg-config --atleast-version=5 maemo-version; then if [ "$1" == "4" ]; then echo "ERROR: Maemo 4 SDK required." exit 1 fi extradefines="$extradefines -DMAEMO5" echo "Found N900 maemo version" is_n900=1 elif pkg-config --atleast-version=4 maemo-version; then if [ "$1" == "5" ]; then echo "ERROR: Maemo 5 SDK required." exit 1 fi extradefines="$extradefines -DMAEMO4" echo "Found N8xx maemo version" else echo "Unable to determine maemo version. Is the maemo-version-dev package installed?" exit 1 fi # SDL if [ $is_n900 -eq 1 ]; then GCCOPTS="$GCCOPTS `pkg-config --cflags sdl`" LDOPTS="$LDOPTS `pkg-config --libs sdl`" else GCCOPTS="$GCCOPTS `${sdl_config} --cflags`" LDOPTS="$LDOPTS `${sdl_config} --libs`" fi # glib and libosso support GCCOPTS="$GCCOPTS `pkg-config --cflags libosso glib-2.0 gthread-2.0`" LDOPTS="$LDOPTS `pkg-config --libs libosso glib-2.0 gthread-2.0`" # libhal support: Battery monitoring GCCOPTS="$GCCOPTS `pkg-config --cflags hal`" LDOPTS="$LDOPTS `pkg-config --libs hal`" GCCOPTS="$GCCOPTS -O2 -fno-strict-aliasing" if [ $is_n900 -eq 1 ]; then # gstreamer support: Audio output. GCCOPTS="$GCCOPTS `pkg-config --cflags gstreamer-base-0.10 gstreamer-plugins-base-0.10 gstreamer-app-0.10`" LDOPTS="$LDOPTS `pkg-config --libs gstreamer-base-0.10 gstreamer-plugins-base-0.10 gstreamer-app-0.10`" # N900 specific: libplayback support GCCOPTS="$GCCOPTS `pkg-config --cflags libplayback-1`" LDOPTS="$LDOPTS `pkg-config --libs libplayback-1`" # N900 specific: Enable ARMv7 NEON support if sb-conf show -A |grep -q -i arm; then echo "Detected ARM target" GCCOPTS="$GCCOPTS -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp" extradefines="$extradefines -DMAEMO_ARM_BUILD" else echo "Detected x86 target" fi else # N8xx specific: Enable armv5te instructions if sb-conf show -A |grep -q -i arm; then echo "Detected ARM target" GCCOPTS="$GCCOPTS -mcpu=arm1136jf-s -mfloat-abi=softfp -mfpu=vfp" extradefines="$extradefines -DMAEMO_ARM_BUILD" else echo "Detected x86 target" fi fi } pandoracc () { # Note: The new "Ivanovic" pandora toolchain is not able to compile rockbox. # You have to use the sebt3 toolchain: # http://www.gp32x.com/board/index.php?/topic/58490-yactfeau/ PNDSDK="/usr/local/angstrom/arm" if [ ! -x $PNDSDK/bin/arm-angstrom-linux-gnueabi-gcc ]; then echo "Pandora SDK gcc not found in $PNDSDK/bin/arm-angstrom-linux-gnueabi-gcc" exit fi PATH=$PNDSDK/bin:$PATH:$PNDSDK/arm-angstrom-linux-gnueabi/usr/bin PKG_CONFIG_PATH=$PNDSDK/arm-angstrom-linux-gnueabi/usr/lib/pkgconfig LDOPTS="-L$PNDSDK/arm-angstrom-linux-gnueabi/usr/lib -Wl,-rpath,$PNDSDK/arm-angstrom-linux-gnueabi/usr/lib $LDOPTS" PKG_CONFIG="pkg-config" GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib// -e s/-Wundef//` GCCOPTS="$GCCOPTS -fno-builtin -g -I\$(SIMDIR)" GCCOPTIMIZE='' LDOPTS="-lm -ldl $LDOPTS" GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" SHARED_LDFLAGS="-shared" SHARED_CFLAGS='' endian="little" thread_support="HAVE_SIGALTSTACK_THREADS" # Include path GCCOPTS="$GCCOPTS -I$PNDSDK/arm-angstrom-linux-gnueabi/usr/include" # Set up compiler gccchoice="4.3.3" prefixtools "$PNDSDK/bin/arm-angstrom-linux-gnueabi-" # Detect SDL GCCOPTS="$GCCOPTS `$PNDSDK/bin/${sdl_config} --cflags`" LDOPTS="$LDOPTS `$PNDSDK/bin/${sdl_config} --libs`" # Compiler options GCCOPTS="$GCCOPTS -O2 -fno-strict-aliasing" GCCOPTS="$GCCOPTS -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp" GCCOPTS="$GCCOPTS -ffast-math -fsingle-precision-constant" } arm1176jzlinuxcc () { GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib//` # Although the ARM1176JZ-S supports unaligned accesses, those seems to disabled # by the kernel. Since GCC emits unaligned accesses by default on ARMv6, we # need to disable that GCCOPTS="$GCCOPTS -mcpu=arm1176jz-s -mno-unaligned-access -mfloat-abi=softfp" GCCOPTIMIZE='' LDOPTS="-lasound -lpthread -lm -ldl -lrt $LDOPTS" GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" # warn about undefined symbols in shared libraries SHARED_LDFLAGS="-shared" SHARED_CFLAGS='' endian="little" app_type="ypr0" # Include path GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -U_FORTIFY_SOURCE -D_REENTRANT" # Set up compiler gccchoice="4.9.4" prefixtools "arm-rockbox-linux-gnueabi-" } ypr0cc () { arm1176jzlinuxcc app_type="ypr0" } sonynwzcc () { arm1176jzlinuxcc app_type="sonynwz" } androidcc () { 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 (r10e to r17) and have the ANDROID_NDK_PATH" echo "environment variable point to the root directory of the Android NDK." exit fi make_toolchain="${ANDROID_NDK_PATH}/build/tools/make-standalone-toolchain.sh" if [ ! -f "$make_toolchain" ]; then echo "ERROR: You need the Android NDK installed (r10e to r17). Please note that" echo "versions newer than r17 are not supported because they do not contain GCC." exit fi # the prebuilt android NDK only supports x86_64 architecture anyway, so we can take shortcuts buildhost=$(uname | tr "[:upper:]" "[:lower:]")-x86_64 GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib// -e s/-Wundef//` LDOPTS="$LDOPTS -ldl -llog" if [ "$modelname" != "ibassodx50" ] && [ "$modelname" != "ibassodx90" ]; then LDOPTS="$LDOPTS -Wl,-soname,librockbox.so -shared" fi SHARED_LDFLAGS="-shared" SHARED_CFLAGS='' GLOBAL_LDOPTS="-Wl,-z,defs -Wl,-z,noexecstack" thread_support="HAVE_SIGALTSTACK_THREADS" ANDROID_ARCH=$2 # for android.make too ANDROID_PLATFORM_VERSION=$1 GCCOPTS="$GCCOPTS $3" gccchoice="4.9" rm -rf "${pwd}/android-toolchain" # old toolchain must be removed before running script # arch dependant stuff case $ANDROID_ARCH in armeabi) endian="little" gcctarget="arm-linux-androideabi-" echo "${make_toolchain} --toolchain=arm-linux-androideabi-${gccchoice} --platform=android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain" ${make_toolchain} --toolchain=arm-linux-androideabi-${gccchoice} --platform=android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain if [ ${?} != 0 ]; then exit fi # Android 4.4 (API 19) doesn't support anything older than armv7. GCCOPTS="$GCCOPTS -fomit-frame-pointer -fuse-ld=bfd" ;; aarch64) endian="little" gcctarget="arm-linux-androideabi-" echo "${make_toolchain} --toolchain=aarch64-linux-android-${gccchoice} --platform=android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain" ${make_toolchain} --toolchain=aarch64-linux-android-${gccchoice} --platform=android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain if [ ${?} != 0 ]; then exit fi GCCOPTS="$GCCOPTS -fomit-frame-pointer -fuse-ld=bfd" # what default cpu arch/tune to use? ;; mips) endian="little" gcctarget="mipsel-linux-android-" echo "${make_toolchain} --toolchain=mipsel-linux-android-${gccchoice} --platform=android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain" ${make_toolchain} --toolchain=mipsel-linux-android-${gccchoice} --platform=android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain if [ ${?} != 0 ]; then exit fi GCCOPTS="$GCCOPTS -march=mips32 -mtune=r4600 -mno-mips16 -mno-long-calls -fomit-frame-pointer -fPIC" ;; x86) endian="little" gcctarget="i686-linux-android-" echo "${make_toolchain} --toolchain=x86-${gccchoice} --platform=android-android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain" ${make_toolchain} --toolchain=x86-${gccchoice} --platform=android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain if [ ${?} != 0 ]; then exit fi GCCOPTS="$GCCOPTS -Wa,--noexecstack -ffunction-sections -fomit-frame-pointer" ;; *) echo "ERROR: androidcc(): Unknown target architecture" exit ;; esac LDOPTS="$LDOPTS -fuse-ld=bfd --sysroot=${pwd}/android-toolchain/sysroot" GCCOPTS="$GCCOPTS --sysroot=${pwd}/android-toolchain/sysroot" echo "Using endian ${endian}" echo "Using gccchoice ${gccchoice}" echo "Using gcctarget ${gcctarget}" PATH=$PATH:${pwd}/android-toolchain/bin prefixtools $gcctarget } androidndkcc() { if ! [ -d "$ANDROID_NDK_PATH" ]; then echo "ERROR: You need the Android NDK installed (r10e or higher) and have the ANDROID_NDK_PATH" echo "environment variable point to the root directory of the Android NDK." exit fi make_toolchain="${ANDROID_NDK_PATH}/build/tools/make-standalone-toolchain.sh" if ! [ -e "${make_toolchain}" ]; then echo "ERROR: ${make_toolchain} could not be found." exit fi # the prebuilt android NDK only supports x86_64 architecture anyway, so we can take shortcuts buildhost=$(uname -s | tr "[:upper:]" "[:lower:]")-x86_64 GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib// -e s/-Wundef//` LDOPTS="$LDOPTS -ldl -llog" SHARED_LDFLAGS="-shared" SHARED_CFLAGS='' GLOBAL_LDOPTS="-Wl,-z,defs -Wl,-z,noexecstack" ANDROID_PLATFORM_VERSION=$1 GCCOPTS="$GCCOPTS $3" # arch dependant stuff case $2 in armeabi) endian="little" gccchoice="4.9" gcctarget="arm-linux-androideabi-" echo "${make_toolchain} --toolchain=arm-linux-androideabi-4.9 --platform=android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain" ${make_toolchain} --toolchain=arm-linux-androideabi-4.9 --platform=android-$ANDROID_PLATFORM_VERSION --install-dir=${pwd}/android-toolchain if [ ${?} != 0 ]; then exit fi GCCOPTS="$GCCOPTS -fomit-frame-pointer" ;; *) echo "ERROR: androidndkcc(): Unknown target architecture" exit ;; esac # -fuse-ld=bfd is needed because toolchain defaults to 'gold' # which often crashes when linking. LDOPTS="$LDOPTS -fuse-ld=bfd --sysroot=${pwd}/android-toolchain/sysroot" GCCOPTS="$GCCOPTS -fuse-ld=bfd --sysroot=${pwd}/android-toolchain/sysroot" echo "Using endian ${endian}" echo "Using gccchoice ${gccchoice}" echo "Using gcctarget ${gcctarget}" PATH=$PATH:${pwd}/android-toolchain/bin prefixtools $gcctarget } mipsellinuxcc () { GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib//` GCCOPTS="$GCCOPTS -march=mips32r2 -mhard-float -mno-mips16 -mno-long-calls -Umips -fPIC" GCCOPTIMIZE='' LDOPTS="-lasound -lpthread -lm -ldl -lrt $LDOPTS" GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" SHARED_LDFLAGS="-shared" SHARED_CFLAGS='-fPIC -fvisibility=hidden' endian="little" thread_support="HAVE_SIGALTSTACK_THREADS" # Include path GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -U_FORTIFY_SOURCE -D_REENTRANT" # Set up compiler gccchoice="4.9.4" prefixtools "mipsel-rockbox-linux-gnu-" } rgnanocc () { if [ -z "$FUNKEY_SDK_PATH" ]; then echo "ERROR: You need the FunKey-SDK installed and have the FUNKEY_SDK_PATH" echo "environment variable point to the root directory of the FunKey-SDK." echo "More info at https://wiki.funkey-project.com/wiki/Setting_up_the_SDK" exit fi $FUNKEY_SDK_PATH/relocate-sdk.sh arch="arm" arch_version="7" arch_profile="classic" CC=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-gcc CPP=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-cpp LD=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-ld AR=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-gcc-ar AS=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-as OC=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-objcopy WINDRES=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-windres DLLTOOL=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-dlltool DLLWRAP=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-dllwrap RANLIB=$FUNKEY_SDK_PATH/bin/arm-funkey-linux-musleabihf-gcc-ranlib GCCOPTS=`echo $CCOPTS | sed -e s/\ -ffreestanding// -e s/\ -nostdlib// -e s/\ -Wundef//` if [ "yes" = "$use_debug" ]; then GCCOPTS=`echo $GCCOPTS | sed -e s/\ -Os/\ -Og/` fi GCCOPTS="$GCCOPTS -fno-builtin -g -Wno-unused-result" GCCOPTS="$GCCOPTS -I$FUNKEY_SDK_PATH/arm-funkey-linux-musleabihf/sysroot/usr/include/SDL" GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -D_REENTRANT -masm-syntax-unified" SHARED_LDFLAGS="-shared" SHARED_CFLAGS="-fPIC -fvisibility=hidden" LDOPTS="-lm -ldl $LDOPTS -L$FUNKEY_SDK_PATH/arm-funkey-linux-musleabihf/sysroot/usr/lib -lSDL -lpthread" GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" thread_support="HAVE_SDL_THREADS" sdl="$FUNKEY_SDK_PATH/arm-funkey-linux-musleabihf/sysroot/usr/bin/sdl-config" rbdir="/FunKey/rockbox" } do_bootloader() { appsdir='$(ROOTDIR)/bootloader' apps="bootloader" flash="" if test -n "$boottool"; then tool="$boottool" fi if test -n "$bootoutput"; then output=$bootoutput fi if test -n "$arm_thumb_boot" && test -z "$ARG_ARM_THUMB"; then ARG_ARM_THUMB=1 fi extradefines="$extradefines -DBOOTLOADER -ffunction-sections -fdata-sections" bootloader="1" if [ -n "${sysfontbl}" ] ; then sysfont=$sysfontbl ; fi } 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, (B)ootloader, (P)rofiling, (V)oice, (U)SB Serial,\n\ (W)in32 crosscompile, Win(6)4 crosscompile, (T)est plugins, (O)mit plugins, \n\ S(m)all C lib, Logf to Ser(i)al port, LTO Build(X), (E)rror on warnings" if [ "$modelname" = "iaudiom5" ]; then printf ", (F)M radio MOD" fi if [ "$modelname" = "iriverh120" ]; then printf ", (R)TC MOD" fi printf ":" 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" ;; [Oo]) echo "Disabling building of plugins" plugins="no" ;; [Cc]) echo "bootchart enabled (logf also enabled)" bootchart="yes" logf="yes" ;; [Ii]) echo "Logf to serial port enabled (logf also enabled)" logf="yes" logf_serial="yes" ;; [Ss]) echo "Simulator build enabled" simulator="yes" ;; [Bb]) echo "Bootloader build selected" do_bootloader ;; [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" ;; [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 ;; [Uu]) echo "USB Serial support enabled" use_usb_serial="#define USB_ENABLE_SERIAL" logf="yes" ;; [Ww]) echo "Enabling Windows cross-compiling (32-bit)" win32crosscompile="yes" win64="" ;; [6]) echo "Enabling Windows cross-compiling (64-bit)" win32crosscompile="yes" win64="yes" ;; [Xx]) echo "LTO build enabled" LTO_ARG="export USE_LTO=y" # GCCOPTS=`echo $GCCOPTS | sed -e s/-funit-at-a-time/-flto/` GCCOPTS="$GCCOPTS -flto" GLOBAL_LDOPTS="-flto $GLOBAL_LDOPTS" ;; [Ee]) echo "Treating all warnings as errors" GCCOPTS="$GCCOPTS -Werror" CCOPTS="$CCOPTS -Werror" ;; "") # 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 if [ -z "$POOL" ] ; then echo " \$POOL is not set, will use /voice-pool by default" fi 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" = "$logf_serial" ]; then use_logf_serial="#define LOGF_SERIAL 1" fi if [ "yes" = "$bootchart" ]; then use_bootchart="#define DO_BOOTCHART 1" fi if [ "yes" = "$simulator" ]; then debug="-DDEBUG" extradefines="$extradefines -DSIMULATOR -DHAVE_TEST_PLUGINS" 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_CHOICE="l" fi if [ -n "`findtool espeak`" ]; then ESPEAK="(e)Speak " ESPEAK_OPTS="" DEFAULT_TTS="espeak" DEFAULT_TTS_OPTS=$ESPEAK_OPTS DEFAULT_CHOICE="e" fi if [ -n "`findtool espeak-ng`" ]; then ESPEAK="(e)Speak-ng " ESPEAK_OPTS="" DEFAULT_TTS="espeak-ng" DEFAULT_TTS_OPTS=$ESPEAK_OPTS DEFAULT_CHOICE="e" fi if [ -n "`findtool festival`" ]; then FESTIVAL="(F)estival " FESTIVAL_OPTS="" DEFAULT_TTS="festival" DEFAULT_TTS_OPTS=$FESTIVAL_OPTS DEFAULT_CHOICE="f" fi if [ -n "`findtool mimic`" ]; then MIMIC="(M)imic " MIMIC_OPTS="" DEFAULT_TTS="mimic" DEFAULT_TTS_OPTS=$MIMIC_OPTS DEFAULT_CHOICE="M" fi if [ -n "`findtool swift`" ]; then SWIFT="S(w)ift " SWIFT_OPTS="" DEFAULT_TTS="swift" DEFAULT_TTS_OPTS=$SWIFT_OPTS 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_CHOICE="S" fi if [ -n "`findtool gtts-cli`" ]; then GTTS="(g)tts " GTTS_OPTS="" DEFAULT_TTS="gtts" DEFAULT_TTS_OPTS=$GTTS_OPTS DEFAULT_CHOICE="g" fi if [ -n "`findtool piper`" ]; then PIPER="(p)iper " PIPER_OPTS="" DEFAULT_TTS="piper" DEFAULT_TTS_OPTS=$PIPER_OPTS DEFAULT_CHOICE="p" fi if [ -n "`findtool rbspeak`" ]; then RBSPEAK="(O)ther " RBSPEAK_OPTS="" DEFAULT_TTS="rbspeak" DEFAULT_TTS_OPTS=$RBSPEAK_OPTS DEFAULT_CHOICE="O" fi if [ "$FESTIVAL" = "$FLITE" ] && [ "$FLITE" = "$ESPEAK" ] && [ "$ESPEAK" = "$SAPI" ] && [ "$SAPI" = "$MIMIC" ] && [ "$MIMIC" = "$SWIFT" ] && [ "$SWIFT" = "$GTTS" ] && [ "$GTTS" = "$PIPER" ] && [ "$PIPER" = "$RBSPEAK" ] ; then echo "You need Festival, eSpeak, Mimic, Flite, piper, gtts, or rbspeak 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}${MIMIC}${SAPI}${SWIFT}${GTTS}${RBSPEAK}${PIPER}(${DEFAULT_CHOICE})?" option=`input` if [ -z "$option" ]; then option=${DEFAULT_CHOICE}; fi advopts="$advopts --tts=$option" fi case "$option" in [Ll]|flite) TTS_ENGINE="flite" TTS_OPTS=$FLITE_OPTS ;; [Ee]|espeak) TTS_ENGINE="espeak" TTS_OPTS=$ESPEAK_OPTS ;; [Ff]|festival) TTS_ENGINE="festival" TTS_OPTS=$FESTIVAL_OPTS ;; [Mm]|mimic) TTS_ENGINE="mimic" TTS_OPTS=$MIMIC_OPTS ;; [Ss]|sapi) TTS_ENGINE="sapi" TTS_OPTS=$SAPI_OPTS ;; [Ww]|swift) TTS_ENGINE="swift" TTS_OPTS=$SWIFT_OPTS ;; [Gg]|gtts) TTS_ENGINE="gtts" TTS_OPTS=$GTTS_OPTS ;; [Pp]|piper) TTS_ENGINE="piper" TTS_OPTS=$PIPER_OPTS ;; [Oo]|rbspeak) TTS_ENGINE="rbspeak" TTS_OPTS=$RBSPEAK_OPTS ;; *) TTS_ENGINE=$DEFAULT_TTS TTS_OPTS=$DEFAULT_TTS_OPTS 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 elif [ "$TTS_ENGINE" = "piper" ]; then if [ -z "$PIPER_MODEL_DIR" ]; then echo "Please set PIPER_MODEL_DIR!"; exit 1 fi models=`(cd $PIPER_MODEL_DIR ; ls -1 *onnx)` for model in $models; do PIPER_MODEL="$model" # Default break; done if [ "$ARG_VOICE" ]; then CHOICE=$ARG_VOICE else i=1 for model in $models; do printf "%3d. %s\n" "$i" "$model" i=`expr $i + 1` done printf "Please select which piper model to use (default is $PIPER_MODEL): " CHOICE=`input` fi i=1 for model in $models; do if [ "$i" = "$CHOICE" -o "$model" = "$CHOICE" ]; then PIPER_MODEL="$model" break; fi i=`expr $i + 1` done TTS_OPTS="$TTS_OPTS --model $PIPER_MODEL_DIR/$PIPER_MODEL" advopts="$advopts --voice=$PIPER_MODEL" echo "Piper model set to $PIPER_MODEL" elif [ "$TTS_ENGINE" = "mimic" ]; then voicelist=`mimic -lv | cut -d':' -f2` for voice in $voicelist; do TTS_MIMIC_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 Mimic voice to use (default is $TTS_MIMIC_VOICE): " CHOICE=`input` fi i=1 for voice in $voicelist; do if [ "$i" = "$CHOICE" -o "$voice" = "$CHOICE" ]; then TTS_MIMIC_VOICE="$voice" break fi i=`expr $i + 1` done advopts="$advopts --voice=$CHOICE" echo "Mimic voice set to $TTS_MIMIC_VOICE" TTS_OPTS="$TTS_OPTS -voice $TTS_MIMIC_VOICE" elif [ "$TTS_ENGINE" = "espeak" ] ; then if [ -n "`findtool espeak-ng`" ] ; then TTS_ENGINE="espeak-ng" fi fi # Read custom tts options from command line if [ "$ARG_TTSOPTS" ]; then TTS_OPTS="$ARG_TTSOPTS" echo "$TTS_ENGINE options set to $TTS_OPTS" fi ENCODER="rbspeexenc" ENC_OPTS="-q 7 -c 10" echo "Using $ENCODER for encoding voice clips" # Read custom encoder options from command line if [ "$ARG_ENCOPTS" ]; then ENC_OPTS="$ARG_ENCOPTS" 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` advopts="$advopts --language=$pick" fi } 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 if test -r "tools/configure"; then # this is a check for a configure script in the tools/ directory, if there # is one, try to figure out if it is this one! if { grep "^# Jukebox" tools/configure >/dev/null 2>&1 ; } then echo "WEEEEEEEEP. Don't run this configure script in the root of the tree." echo "It will only cause you pain and grief. Instead do this:" echo "" 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' toolsdir='$(ROOTDIR)/tools' ################################################################## # Figure out target platform # if [ "$ARG_TARGET" ]; then buildfor=$ARG_TARGET else echo "Enter target platform:" cat </dev/null` # This makes: # 3.3.X => 303 # 3.4.X => 304 # 2.95.3 => 295 # 7.3-win32 => 703 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 if test "$gccnum" -ge "700"; then # gcc 7 spews a bunch of warnings by default GCCOPTS="$GCCOPTS -Wimplicit-fallthrough=0" fi case "$GCCOPTS" in *-mcpu=cortex-m7*) # Cortex-M7 support wasn't added until GCC 5. Since we don't use any # M7-specific features, we can compile as Cortex-M4 when on GCC 4.9. if test "$gccnum" -lt "500"; then GCCOPTS=$(echo "$GCCOPTS" | sed -e "s/-mcpu=cortex-m7/-mcpu=cortex-m4 -mthumb/") fi ;; esac case $prefix in ""|"$CROSS_COMPILE") # simulator ;; *) # 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" makever=`make --version | head -1` echo "Detected make $makever" 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 else CCACHE_ARG="export CCACHE_DISABLE=true" fi # figure out the full path to the various commands if possible HOSTCC=`findtool gcc --lit` HOSTAR=`findtool ar --lit` CC=`findtool ${CC} --lit` CPP=`findtool ${CPP} --lit` LD=`findtool ${LD} --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` # in pure cross-compiler environments without own native compiler this helps: HOSTCC=${HOSTCC:-${CC}} HOSTAR=${HOSTAR:-${AR}} if [ -z "$arch" ]; then cpp_defines=$(echo "" | $CPP $GCCOPTS -dD) if [ -n "$(echo $cpp_defines | grep -w __m68k__)" ]; then arch="m68k" elif [ -n "$(echo $cpp_defines | grep -w __arm__)" ]; then arch="arm" # cpp defines like "#define __ARM_ARCH_4TE__ 1" (where we want to extract the 4) arch_version="$(echo $cpp_defines | tr ' ' '\012' | grep __ARM_ARCH | sed -e 's,.*\([0-9]\).*,\1,' | grep -v __ARM_ARCH | head -1)" arch_profile="$(echo "$cpp_defines" | grep 'define __ARM_ARCH_PROFILE' | sed -e 's,.* \([0-9]\+\)$,\1,')" if test "$gccnum" -ge "800"; then # GCC8+ can natively emit unified asm syntax GCCOPTS="$GCCOPTS -masm-syntax-unified" fi case "$arch_profile" in 77) arch_profile=micro # We have a lot of assembly written for ARM32, which won't # successfully assemble on a Thumb-only core due to missing # IT blocks. The recommended practice for portable assembly # is to add explicit IT blocks nowadays. # # This option instructs the assembler to add IT blocks # automatically as needed, which allows the old assembly to # compile unchanged (although it might be sub-optimal). GCCOPTS="$GCCOPTS -Wa,-mimplicit-it=thumb" # Disable this option -- it only makes sense for cores that # support both ARM and Thumb instruction sets. if [ "$ARG_ARM_THUMB" = "1" ]; then echo "Warning: --thumb option has no effect on ARM M profile cores" ARG_ARM_THUMB=0 fi ;; *) # On classic ARM we expect an empty string, so only warn if it's nonempty if [ -n "$arch_profile" ]; then echo "Warning: Cannot determine target ARM profile, assuming classic" fi arch_profile=classic ;; esac elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then arch="mips" arch_version="$(echo $cpp_defines | tr ' ' '\012' | grep _MIPS_ARCH_MIPS | sed -e 's,.*\([0-9][0-9]\).*,\1,' | grep -v _MIPS_ARCH_MIPS)" elif [ -n "$(echo $cpp_defines | grep -w __i386__)" ]; then arch="x86" elif [ -n "$(echo $cpp_defines | grep -w __x86_64__)" ]; then arch="amd64" else arch="none" echo "Warning: Could not determine target arch" fi if [ "$arch" != "none" ]; then if [ -n "$arch_version" ]; then if [ -n "$arch_profile" ]; then echo "Automatically selected arch: $arch (ver $arch_version, profile $arch_profile)" else echo "Automatically selected arch: $arch (ver $arch_version)" fi else echo "Automatically selected arch: $arch" fi fi; else if [ -n "$arch_version" ]; then echo "Manually selected arch: $arch (ver $arch_version)" else echo "Manually selected arch: $arch" fi fi Darch="#define ARCH arch_$arch" if [ -n "$arch_version" ]; then Darch_version="#define ARCH_VERSION $arch_version" fi if [ -n "$arch_profile" ]; then Darch_profile="#define ARCH_PROFILE $(echo ${arch}_PROFILE_${arch_profile} | tr [a-z] [A-Z])" fi 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 cat > autoconf.h.new < /dev/null 2>&1 ; then mv autoconf.h.new autoconf.h echo "Created autoconf.h" else rm -f autoconf.h.new fi if test -n "$t_cpu"; then TARGET_INC="-I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer/$t_model" if [ "$application" = "yes" ] && [ "$t_manufacturer" = "maemo" ]; then # Maemo needs the SDL port, too TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app" TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl" elif [ "$application" = "yes" ] && [ "$t_manufacturer" = "pandora" ]; then # Pandora needs the SDL port, too TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app" TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl" elif [ "$simulator" = "yes" ]; then # a few more includes for the sim target tree TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl" TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted" elif [ "$t_manufacturer" = "ibasso" ]; then TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/ibasso/tinyalsa/include" fi TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer" test -n "$t_soc" && TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/$t_cpu/$t_soc" TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/$t_cpu" GCCOPTS="$GCCOPTS" fi voicetoolset="rbspeexenc voicefont wavtrim" if test "$apps" = "apps"; then # only when we build "real" apps we build the .lng files buildlangs="langs" fi #### Fix the cmdline ### if [ -n "$ARG_PREFIX" ]; then cmdline="$cmdline --prefix=\$(PREFIX)" fi if [ -n "$ARG_LCDWIDTH" ]; then cmdline="$cmdline --lcdwidth=$ARG_LCDWIDTH --lcdheight=$ARG_LCDHEIGHT " fi # remove parts from the cmdline we're going to set unconditionally cmdline=`echo $cmdline | sed -e s,--target=[a-zA-Z_0-9]\*,,g \ -e s,--ram=[0-9]\*,,g \ -e s,--rbdir=[./a-zA-Z0-9]\*,,g \ -e s,--voice=[-_./a-zA-Z0-9]\*,,g \ -e s,--type=[a-zA-Z0-9]\*,,g` cmdline="$cmdline --target=\$(MODELNAME) --ram=\$(MEMORYSIZE) --rbdir=\$(RBDIR) --type=$btype$advopts" ### end of cmdline cat > Makefile <