3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
11 # global CC options for all platforms
12 CCOPTS
="-W -Wall -O -nostdlib -ffreestanding -Wstrict-prototypes"
14 use_logf
="#undef ROCKBOX_HAS_LOGF"
15 use_simsound
="#undef ROCKBOX_HAS_SIMSOUND"
17 scriptver
=`echo '$Revision$' | sed -e 's:\\$::g' -e 's/Revision: //'`
20 # Begin Function Definitions
30 WINDRES
=${prefix}windres
31 DLLTOOL
=${prefix}dlltool
32 DLLWRAP
=${prefix}dllwrap
33 RANLIB
=${prefix}ranlib
41 # naive approach to selecting a mingw cross-compiler on linux/*nix
42 echo "Enabling win32 crosscompiling"
44 prefixtools i586-mingw32msvc-
46 LDOPTS
="-lgdi32 -luser32 -mwindows"
47 # add cross-compiler option(s)
48 GCCOPTS
="$GCCOPTS -mno-cygwin"
50 output
="rockboxui.exe" # use this as output binary name
52 endian
="little" # windows is little endian
56 if test -n "$codecs"; then
57 if test -f "/usr/include/sys/soundcard.h"; then
58 # We have a header file so we can build the sound code
59 use_simsound
="#define ROCKBOX_HAS_SIMSOUND 1"
60 echo "Enabled PCM sound playback in simulator"
61 fi # header file present
68 # default tool setup for native building
71 GCCOPTS
='-W -Wall -g -fno-builtin'
73 output
="rockboxui" # use this as default output binary name
77 echo "Cygwin host detected"
79 if [ "$simver" = "win32" ]; then
81 GCCOPTS
="$GCCOPTS -mno-cygwin -DNOCYGWIN"
82 LDOPTS
="-lgdi32 -luser32 -mno-cygwin"
86 LDOPTS
='-L/usr/X11R6/lib -lSM -lICE -lXt -lX11 -lXmu -lSM -lICE -lX11 -lpthread'
89 output
="rockboxui.exe" # use this as output binary name
93 echo "Linux host detected"
95 LDOPTS
='-L/usr/X11R6/lib -lX11 -lm -lXt -lXmu -lnsl -ldl -lpthread'
96 if [ "$simver" = "win32" ]; then
97 crosswincc
# setup cross-compiler
100 fi # not a cross-compiler
104 echo "FreeBSD host detected"
105 LDOPTS
='-L/usr/X11R6/lib -lX11 -lm -lXt -lXmu -dl -lpthread'
106 if [ "$simver" = "win32" ]; then
107 crosswincc
# setup cross-compiler
112 echo "Unsupported system: $uname, fix configure and retry"
118 if test "X$crosscompile" != "Xyes"; then
120 cat >/tmp
/conftest-
$id.c
<<EOF
122 int main(int argc, char **argv)
125 char *varp = (char *)&var;
133 $CC -o /tmp
/conftest-
$id /tmp
/conftest-
$id.c
2>/dev
/null
135 if test `/tmp/conftest-$id 2>/dev/null` -gt "1"; then
142 echo "Simulator environment deemed $endian endian"
144 # use wildcard here to make it work even if it was named *.exe like
146 rm -f /tmp
/conftest-
$id*
152 GCCOPTS
="$CCOPTS -m1"
153 GCCOPTIMIZE
="-fomit-frame-pointer -fschedule-insns"
158 prefixtools calmrisc16-unknown-elf-
159 GCCOPTS
="-Wl\,--no-check-sections $CCOPTS"
160 GCCOPTIMIZE
="-fomit-frame-pointer"
165 prefixtools m68k-elf-
166 GCCOPTS
="$CCOPTS -g -m5200 -Wa\,-m5249 -malign-int -mstrict-align"
167 GCCOPTIMIZE
="-fomit-frame-pointer"
173 GCCOPTS
="$CCOPTS -mcpu=arm7tdmi"
174 GCCOPTIMIZE
="-fomit-frame-pointer"
182 echo "Where do you want the firmware to be flashed?"
183 echo "WARNING: Do not answer this question lightly,"
184 echo "unless you don't plan to flash your gmini."
185 echo "In this case, reply '0x10000' (no quotes) and "
186 echo "re-configure when you know better."
189 if [ "0$loadaddress" = "0" ]; then
191 loadaddress
="0x10000";
193 echo "You selected $loadaddress"
201 ##################################################################
202 # Prompt for specific developer options
205 echo "Enter your developer options (press enter when done)"
206 echo "(D)EBUG, (L)ogf, (S)imulator"
209 while [ $cont = "1" ]; do
217 GCCOPTS
="$GCCOPTS -g -DDEBUG"
221 echo "logf() support enabled"
222 use_logf
="#define ROCKBOX_HAS_LOGF 1"
225 echo "Simulator build enabled"
235 if [ "yes" = "$simulator" ]; then
237 extradefines
="-DSIMULATOR"
244 if [ -z "$simver" ]; then
246 ##################################################################
247 # Figure out win32/x11 GUI
250 echo "Build (W)in32 or (X)11 GUI version? (X)"
262 # make sure the code knows this is for win32
263 extradefines
="$extradefines -DWIN32"
269 echo "Selected $simver simulator"
274 # figure out which languages that are around
275 for file in $rootdir/apps
/lang
/*.lang
; do
276 clean
=`echo $file | sed -e 's:.*/::g' | cut "-d." -f1`
277 langs
="$langs $clean"
281 for one
in $langs; do
292 for one
in $langs; do
293 if [ "$num" = "$pick" ]; then
301 if test "$1" = "--help"; then
302 echo "Rockbox configure script."
303 echo "Invoke this in a directory to generate a Makefile to build Rockbox"
304 echo "Do *NOT* run this within the tools directory!"
306 echo "Usage: configure [--ccache]"
310 if test "$1" = "--ccache"; then
311 echo "Enable ccache for building"
315 if test -r "configure"; then
316 # this is a check for a configure script in the current directory, it there
317 # is one, try to figure out if it is this one!
319 if { grep "^# Jukebox" configure
>/dev
/null
2>&1 ; } then
320 echo "WEEEEEEEEP. Don't run this configure script within the tools directory."
321 echo "It will only cause you pain and grief. Instead do this:"
324 echo " mkdir build-dir"
326 echo " ../tools/configure"
328 echo "Much happiness will arise from this. Enjoy"
333 if [ "$target" = "--help" -o \
334 "$target" = "-h" ]; then
335 echo "Just invoke the script and answer the questions."
336 echo "This script will write a Makefile for you"
340 # get our current directory
343 if [ "$target" = "update" ]; then
344 echo "configure update is unfortunately no longer supported"
348 echo "This script will setup your Rockbox build environment."
349 echo "Further docs here: http://www.rockbox.org/"
354 if [ -z "$rootdir" ]; then
355 ##################################################################
356 # Figure out where the source code root is!
359 firmfile
="crt0.S" # a file to check for in the firmware root dir
361 for dir
in . .. ..
/.. ..
/rockbox
*; do
362 if [ -f $dir/firmware
/$firmfile ]; then
368 if [ -z "$rootdir" ]; then
369 echo "This script couldn't find your source code root directory. Please enter the"
370 echo "full path to the source code directory here:"
375 #####################################################################
376 # Convert the possibly relative directory name to an absolute version
382 echo "Using this source code root directory:"
386 # cd back to the build dir
391 appsdir
='\$(ROOTDIR)/apps'
393 ##################################################################
394 # Figure out target platform
397 echo "Enter target platform:"
399 echo "1 - Archos Player/Studio"
400 echo "2 - Archos Recorder"
401 echo "3 - Archos FM Recorder"
402 echo "4 - Archos Recorder v2"
403 echo "5 - Archos Gmini 120"
404 echo "6 - Archos Gmini SP"
405 echo "7 - Archos Ondio SP"
406 echo "8 - Archos Ondio FM"
407 echo "9 - iriver H120/H140"
408 echo "10 - iriver H320/H340"
409 echo "11 - iriver iHP-100/iHP-110/iHP-115"
410 echo "12 - iAudio X5"
411 echo "13 - iPod Color/Photo"
412 echo "14 - iPod Nano"
420 target
="-DARCHOS_PLAYER"
422 tool
="$rootdir/tools/scramble"
424 appextra
="player:gui"
425 archosrom
="$pwd/rombox.ucl"
426 flash
="$pwd/rockbox.ucl"
433 target
="-DARCHOS_RECORDER"
435 tool
="$rootdir/tools/scramble"
437 appextra
="recorder:gui"
438 archosrom
="$pwd/rombox.ucl"
439 flash
="$pwd/rockbox.ucl"
446 target
="-DARCHOS_FMRECORDER"
448 tool
="$rootdir/tools/scramble -fm"
450 appextra
="recorder:gui"
451 archosrom
="$pwd/rombox.ucl"
452 flash
="$pwd/rockbox.ucl"
459 target
="-DARCHOS_RECORDERV2"
461 tool
="$rootdir/tools/scramble -v2"
463 appextra
="recorder:gui"
464 archosrom
="$pwd/rombox.ucl"
465 flash
="$pwd/rockbox.ucl"
472 target
="-DARCHOS_GMINI120"
473 memory
=16 # fixed size (16 is a guess, remove comment when checked)
475 tool
="cp" # might work for now!
476 output
="rockbox.gmini"
477 appextra
="recorder:gui"
480 plugins
="" # disabled for now, enable later on
486 target
="-DARCHOS_GMINISP"
487 memory
=16 # fixed size (16 is a guess, remove comment when checked)
489 tool
="cp" # might work for now!
490 output
="rockbox.gmini"
491 appextra
="recorder:gui"
494 plugins
="" # disabled for now, enable later on
500 target
="-DARCHOS_ONDIOSP"
502 tool
="$rootdir/tools/scramble -osp"
504 appextra
="recorder:gui"
505 archosrom
="$pwd/rombox.ucl"
506 flash
="$pwd/rockbox.ucl"
513 target
="-DARCHOS_ONDIOFM"
515 tool
="$rootdir/tools/scramble -ofm"
517 appextra
="recorder:gui"
518 archosrom
="$pwd/rombox.ucl"
519 flash
="$pwd/rockbox.ucl"
526 target
="-DIRIVER_H120"
529 tool
="$rootdir/tools/scramble -add=h120"
530 output
="rockbox.iriver"
531 appextra
="recorder:gui"
535 codecs
="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a"
540 target
="-DIRIVER_H300"
543 tool
="$rootdir/tools/scramble -add=h300"
544 output
="rockbox.iriver"
545 appextra
="recorder:gui"
549 codecs
="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a"
554 target
="-DIRIVER_H100"
557 tool
="$rootdir/tools/scramble -add=h100"
558 output
="rockbox.iriver"
559 appextra
="recorder:gui"
563 codecs
="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a"
571 tool
="$rootdir/tools/scramble -add=x5" # wrong, must be fixed
572 output
="rockbox.iaudio"
573 appextra
="recorder:gui"
577 codecs
="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a"
582 target
="-DIPOD_COLOR"
585 tool
="$rootdir/tools/scramble -add=ipco"
586 output
="rockbox.ipod"
587 appextra
="recorder:gui"
591 codecs
="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a"
599 tool
="$rootdir/tools/scramble -add=nano"
600 output
="rockbox.ipod"
601 appextra
="recorder:gui"
605 codecs
="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a"
609 echo "Please select an actual target platform!"
615 echo "Platform set to $archos"
618 ############################################################################
619 # Amount of memory, for those that can differ.
622 if [ -z "$memory" ]; then
624 if [ -z "$update" ]; then
625 echo "Enter size of your RAM (in MB): (defaults to 2)"
638 echo "Memory size selected: $memory MB"
641 ##################################################################
642 # Figure out build "type"
645 echo "Build (N)ormal, (D)evel, (S)imulator, (B)ootloader? (N)"
652 h100|h120|ipodcolor|ipodnano
)
653 extradefines
="-DBOOTLOADER" # for target makefile symbol EXTRA_DEFINES
654 appsdir
='\$(ROOTDIR)/bootloader'
658 extradefines
="-DBOOTLOADER -ffunction-sections -fdata-sections"
659 appsdir
='\$(ROOTDIR)/flash/bootbox'
664 echo "Bootloader build selected"
669 extradefines
="-DSIMULATOR"
670 echo "Simulator build selected"
674 echo "Devel build selected"
679 echo "Normal build selected"
680 GCCOPTS
="$GCCOPTS $GCCOPTIMIZE"
688 ############################################################################
691 echo "Select a number for the language to use (default is english)"
696 if [ -z "$language" ]; then
700 echo "Language set to $language"
704 if [ "yes" = "$simulator" ]; then
705 # setup compiler and things for simulator
708 if [ -d "archos" ]; then
709 echo "sub directory archos already present"
712 echo "created an archos subdirectory for simulating the hard disk"
716 # Now, figure out version number of the (gcc) compiler we are about to use
717 gccver
=`$CC -dumpversion`;
719 if [ -z "$gccver" ]; then
720 echo "WARNING: The compiler you must use ($CC) is not in your path!"
721 echo "WARNING: this may cause your build to fail since we cannot do the"
722 echo "WARNING: checks we want now."
725 # gccver should now be "3.3.5", "3.4.3", "2.95.3-6" and similar, but don't
728 num1
=`echo $gccver | cut -d . -f1`
729 num2
=`echo $gccver | cut -d . -f2`
730 gccnum
=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
737 echo "Using $CC $gccver ($gccnum)"
739 if test "$gccnum" -ge "400"; then
740 # gcc 4.0 is just *so* much pickier on arguments that differ in signedness
741 # so we ignore that warnings for now
743 GCCOPTS
="$GCCOPTS -Wno-pointer-sign"
748 if test "X$ccache" = "Xyes"; then
752 if test "X$endian" = "Xbig"; then
753 defendian
="ROCKBOX_BIG_ENDIAN"
755 defendian
="ROCKBOX_LITTLE_ENDIAN"
759 -e "s,@ENDIAN@,${defendian},g" \
760 -e "s,^#undef ROCKBOX_HAS_LOGF,$use_logf,g" \
761 -e "s,@SIMSOUND@,$use_simsound,g" \
763 /* This header was made by configure */
764 #ifndef __BUILD_AUTOCONF_H
765 #define __BUILD_AUTOCONF_H
767 /* Define endianess for the target or simulator platform */
770 /* Define this if you build rockbox to support the logf logging and display */
771 #undef ROCKBOX_HAS_LOGF
773 /* Define this if you have the linux/soundcard.h header and thus can compile
774 the sound-playing code in the X11 sim */
777 #endif /* __BUILD_AUTOCONF_H */
780 if test "$simulator" = "yes"; then
781 # verify that we have a sed version we can use!
782 lines
=`echo "moo" | sed -e '/moo/cline1\nline2\nline3' | wc -l`
783 if test "$lines" -eq "1"; then
784 echo "You have a broken sed version. You must upgrade to be able to "
785 echo "generate a fine Makefile. See details at:"
786 echo "http://www.rockbox.org/twiki/bin/view/Main/BrokenSed"
789 version
=`sed --version | head -n 1`
790 echo "$version is a fine sed"
793 # add simul make stuff on the #SIMUL# line
794 simmagic
='/#SIMUL#/c\ @$(MAKE) -C $(SIMDIR) OBJDIR=$(BUILDDIR)/sim\n @$(MAKE) -C $(ROOTDIR)/uisimulator/common OBJDIR=$(BUILDDIR)/comsim'
796 # delete the line that matches
797 simmagic
='/#SIMUL#/D'
801 -e "s,@ROOTDIR@,${rootdir},g" \
802 -e "s,@DEBUG@,${debug},g" \
803 -e "s,@MEMORY@,${memory},g" \
804 -e "s,@TARGET@,${target},g" \
805 -e "s,@ARCHOS@,${archos},g" \
806 -e "s,@LANGUAGE@,${language},g" \
807 -e "s,@PWD@,${pwd},g" \
808 -e "s,@CC@,${CC},g" \
809 -e "s,@LD@,${LD},g" \
810 -e "s,@AR@,${AR},g" \
811 -e "s,@AS@,${AS},g" \
812 -e "s,@OC@,${OC},g" \
813 -e "s,@WINDRES@,${WINDRES},g" \
814 -e "s,@DLLTOOL@,${DLLTOOL},g" \
815 -e "s,@DLLWRAP@,${DLLWRAP},g" \
816 -e "s,@RANLIB@,${RANLIB},g" \
817 -e "s,@TOOL@,${tool},g" \
818 -e "s,@OUTPUT@,${output},g" \
819 -e "s,@APPEXTRA@,${appextra},g" \
820 -e "s,@ARCHOSROM@,${archosrom},g" \
821 -e "s,@FLASHFILE@,${flash},g" \
822 -e "s,@PLUGINS@,${plugins},g" \
823 -e "s,@CODECS@,${codecs},g" \
824 -e "s,@GCCOPTS@,${GCCOPTS},g" \
825 -e "s,@LDOPTS@,${LDOPTS},g" \
826 -e "s,@LOADADDRESS@,${loadaddress},g" \
827 -e "s,@EXTRADEF@,${extradefines},g" \
828 -e "s,@APPSDIR@,${appsdir},g" \
829 -e "s,@APPS@,${apps},g" \
830 -e "s,@SIMVER@,${simver},g" \
831 -e "s,@GCCVER@,${gccver},g" \
832 -e "s,@GCCNUM@,${gccnum},g" \
833 -e "s,@UNAME@,${uname},g" \
834 -e "s,@ENDIAN@,${defendian},g" \
837 ## Automaticly generated. http://www.rockbox.org/
839 export ROOTDIR=@ROOTDIR@
840 export FIRMDIR=\$(ROOTDIR)/firmware
841 export APPSDIR=@APPSDIR@
842 export TOOLSDIR=\$(ROOTDIR)/tools
843 export DOCSDIR=\$(ROOTDIR)/docs
845 export ARCHOS=@ARCHOS@
846 export ARCHOSROM=@ARCHOSROM@
847 export FLASHFILE=@FLASHFILE@
848 export TARGET=@TARGET@
850 export BUILDDIR=@PWD@
851 export LANGUAGE=@LANGUAGE@
852 export MEMORYSIZE=@MEMORY@
853 export VERSION=\$(shell date +%y%m%d-%H%M)
854 export BUILDDATE=\$(shell date +'-DYEAR=%Y -DMONTH=%m -DDAY=%d')
855 export MKFIRMWARE=@TOOL@
856 export BINARY=@OUTPUT@
857 export APPEXTRA=@APPEXTRA@
858 export ENABLEDPLUGINS=@PLUGINS@
859 export SOFTWARECODECS=@CODECS@
860 export EXTRA_DEFINES=@EXTRADEF@
866 export WINDRES=@WINDRES@
867 export DLLTOOL=@DLLTOOL@
868 export DLLWRAP=@DLLWRAP@
869 export RANLIB=@RANLIB@
870 export GCCOPTS=@GCCOPTS@
871 export LOADADDRESS=@LOADADDRESS@
872 export SIMVER=@SIMVER@
873 export SIMDIR=\$(ROOTDIR)/uisimulator/\$(SIMVER)
874 export LDOPTS=@LDOPTS@
875 export GCCVER=@GCCVER@
876 export GCCNUM=@GCCNUM@
879 # Do not print "Entering directory ..."
880 MAKEFLAGS += --no-print-directory
882 .PHONY: all clean tags zip
886 @\$(MAKE) -C \$(FIRMDIR) OBJDIR=\$(BUILDDIR)/firmware
887 @\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@
890 @\$(MAKE) -C \$(FIRMDIR) clean OBJDIR=\$(BUILDDIR)/firmware
891 @\$(MAKE) -C \$(APPSDIR) clean OBJDIR=\$(BUILDDIR)/@APPS@
892 @rm -rf rockbox.zip TAGS @APPS@ firmware comsim sim lang.h
896 \$(MAKE) -C \$(FIRMDIR) tags
897 \$(MAKE) -C \$(APPSDIR) tags
898 \$(MAKE) -C \$(APPSDIR)/plugins tags
899 \$(MAKE) -C \$(APPSDIR)/plugins/lib tags
902 \$(TOOLSDIR)/buildzip.pl -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY)
905 if [ "yes" = "$simulator" ]; then
907 cat >> Makefile
<<EOF
910 @echo "installing a full setup in your archos dir"
911 @(make zip && cd archos && unzip -oq ../rockbox.zip)
916 echo "Created Makefile"