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"
175 echo "Where do you want the firmware to be flashed?"
176 echo "WARNING: Do not answer this question lightly,"
177 echo "unless you don't plan to flash your gmini."
178 echo "In this case, reply '0x10000' (no quotes) and "
179 echo "re-configure when you know better."
182 if [ "0$loadaddress" = "0" ]; then
184 loadaddress
="0x10000";
186 echo "You selected $loadaddress"
194 ##################################################################
195 # Prompt for specific developer options
198 echo "Enter your developer options (press enter when done)"
199 echo "(D)EBUG, (L)ogf, (S)imulator"
202 while [ $cont = "1" ]; do
210 GCCOPTS
="$GCCOPTS -g -DDEBUG"
214 echo "logf() support enabled"
215 use_logf
="#define ROCKBOX_HAS_LOGF 1"
218 echo "Simulator build enabled"
228 if [ "yes" = "$simulator" ]; then
230 extradefines
="-DSIMULATOR"
237 if [ -z "$simver" ]; then
239 ##################################################################
240 # Figure out win32/x11 GUI
243 echo "Build (W)in32 or (X)11 GUI version? (X)"
255 # make sure the code knows this is for win32
256 extradefines
="$extradefines -DWIN32"
262 echo "Selected $simver simulator"
267 # figure out which languages that are around
268 for file in $rootdir/apps
/lang
/*.lang
; do
269 clean
=`echo $file | sed -e 's:.*/::g' | cut "-d." -f1`
270 langs
="$langs $clean"
274 for one
in $langs; do
285 for one
in $langs; do
286 if [ "$num" = "$pick" ]; then
294 if test "$1" = "--help"; then
295 echo "Rockbox configure script."
296 echo "Invoke this in a directory to generate a Makefile to build Rockbox"
297 echo "Do *NOT* run this within the tools directory!"
299 echo "Usage: configure [--ccache]"
303 if test "$1" = "--ccache"; then
304 echo "Enable ccache for building"
308 if test -r "configure"; then
309 # this is a check for a configure script in the current directory, it there
310 # is one, try to figure out if it is this one!
312 if { grep "^# Jukebox" configure
>/dev
/null
2>&1 ; } then
313 echo "WEEEEEEEEP. Don't run this configure script within the tools directory."
314 echo "It will only cause you pain and grief. Instead do this:"
317 echo " mkdir build-dir"
319 echo " ../tools/configure"
321 echo "Much happiness will arise from this. Enjoy"
326 if [ "$target" = "--help" -o \
327 "$target" = "-h" ]; then
328 echo "Just invoke the script and answer the questions."
329 echo "This script will write a Makefile for you"
333 # get our current directory
336 if [ "$target" = "update" ]; then
337 echo "configure update is unfortunately no longer supported"
341 echo "This script will setup your Rockbox build environment."
342 echo "Further docs here: http://www.rockbox.org/"
347 if [ -z "$rootdir" ]; then
348 ##################################################################
349 # Figure out where the source code root is!
352 firmfile
="crt0.S" # a file to check for in the firmware root dir
354 for dir
in . .. ..
/.. ..
/rockbox
*; do
355 if [ -f $dir/firmware
/$firmfile ]; then
361 if [ -z "$rootdir" ]; then
362 echo "This script couldn't find your source code root directory. Please enter the"
363 echo "full path to the source code directory here:"
368 #####################################################################
369 # Convert the possibly relative directory name to an absolute version
375 echo "Using this source code root directory:"
379 # cd back to the build dir
384 appsdir
='\$(ROOTDIR)/apps'
386 ##################################################################
387 # Figure out target platform
390 echo "Enter target platform:"
392 echo "1 - Archos Player/Studio"
393 echo "2 - Archos Recorder"
394 echo "3 - Archos FM Recorder"
395 echo "4 - Archos Recorder v2"
396 echo "5 - Archos Gmini 120"
397 echo "6 - Archos Gmini SP"
398 echo "7 - Archos Ondio SP"
399 echo "8 - Archos Ondio FM"
400 echo "9 - iriver H120/H140"
401 echo "10 - iriver H320/H340"
402 echo "11 - iriver iHP-100/iHP-110/iHP-115"
403 echo "12 - iAudio X5"
411 target
="-DARCHOS_PLAYER"
413 tool
="$rootdir/tools/scramble"
416 archosrom
="$pwd/rombox.ucl"
417 flash
="$pwd/rockbox.ucl"
424 target
="-DARCHOS_RECORDER"
426 tool
="$rootdir/tools/scramble"
429 archosrom
="$pwd/rombox.ucl"
430 flash
="$pwd/rockbox.ucl"
437 target
="-DARCHOS_FMRECORDER"
439 tool
="$rootdir/tools/scramble -fm"
443 flash
="$pwd/rockbox.ucl"
450 target
="-DARCHOS_RECORDERV2"
452 tool
="$rootdir/tools/scramble -v2"
455 archosrom
="$pwd/rombox.ucl"
456 flash
="$pwd/rockbox.ucl"
463 target
="-DARCHOS_GMINI120"
464 memory
=16 # fixed size (16 is a guess, remove comment when checked)
466 tool
="cp" # might work for now!
467 output
="rockbox.gmini"
471 plugins
="" # disabled for now, enable later on
477 target
="-DARCHOS_GMINISP"
478 memory
=16 # fixed size (16 is a guess, remove comment when checked)
480 tool
="cp" # might work for now!
481 output
="rockbox.gmini"
485 plugins
="" # disabled for now, enable later on
491 target
="-DARCHOS_ONDIOSP"
493 tool
="$rootdir/tools/scramble -osp"
496 archosrom
="$pwd/rombox.ucl"
497 flash
="$pwd/rockbox.ucl"
504 target
="-DARCHOS_ONDIOFM"
506 tool
="$rootdir/tools/scramble -ofm"
509 archosrom
="$pwd/rombox.ucl"
510 flash
="$pwd/rockbox.ucl"
517 target
="-DIRIVER_H120"
520 tool
="$rootdir/tools/scramble -add=h120"
521 output
="rockbox.iriver"
526 codecs
="libmad liba52 libFLAC libTremor libwavpack dumb libmusepack"
531 target
="-DIRIVER_H300"
534 tool
="$rootdir/tools/scramble -add=h300"
535 output
="rockbox.iriver"
540 codecs
="libmad liba52 libFLAC libTremor libwavpack dumb libmusepack"
545 target
="-DIRIVER_H100"
548 tool
="$rootdir/tools/scramble -add=h100"
549 output
="rockbox.iriver"
554 codecs
="libmad liba52 libFLAC libTremor libwavpack dumb libmusepack"
562 tool
="$rootdir/tools/scramble -add=x5" # wrong, must be fixed
563 output
="rockbox.iaudio"
568 codecs
="libmad liba52 libFLAC libTremor libwavpack dumb libmusepack"
572 echo "Please select an actual target platform!"
578 echo "Platform set to $archos"
581 ############################################################################
582 # Amount of memory, for those that can differ.
585 if [ -z "$memory" ]; then
587 if [ -z "$update" ]; then
588 echo "Enter size of your RAM (in MB): (defaults to 2)"
601 echo "Memory size selected: $memory MB"
604 ##################################################################
605 # Figure out build "type"
608 echo "Build (N)ormal, (D)evel, (S)imulator, (B)ootloader? (N)"
616 extradefines
="-DBOOTLOADER" # for target makefile symbol EXTRA_DEFINES
617 appsdir
='\$(ROOTDIR)/bootloader'
621 extradefines
="-DBOOTLOADER -ffunction-sections -fdata-sections"
622 appsdir
='\$(ROOTDIR)/flash/bootbox'
627 echo "Bootloader build selected"
632 extradefines
="-DSIMULATOR"
633 echo "Simulator build selected"
637 echo "Devel build selected"
642 echo "Normal build selected"
643 GCCOPTS
="$GCCOPTS $GCCOPTIMIZE"
651 ############################################################################
654 echo "Select a number for the language to use (default is english)"
659 if [ -z "$language" ]; then
663 echo "Language set to $language"
667 if [ "yes" = "$simulator" ]; then
668 # setup compiler and things for simulator
671 if [ -d "archos" ]; then
672 echo "sub directory archos already present"
675 echo "created an archos subdirectory for simulating the hard disk"
679 # Now, figure out version number of the (gcc) compiler we are about to use
680 gccver
=`$CC -dumpversion`;
682 if [ -z "$gccver" ]; then
683 echo "WARNING: The compiler you must use ($CC) is not in your path!"
684 echo "WARNING: this may cause your build to fail since we cannot do the"
685 echo "WARNING: checks we want now."
688 # gccver should now be "3.3.5", "3.4.3", "2.95.3-6" and similar, but don't
691 num1
=`echo $gccver | cut -d . -f1`
692 num2
=`echo $gccver | cut -d . -f2`
693 gccnum
=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
700 echo "Using $CC $gccver ($gccnum)"
702 if test "$gccnum" -ge "400"; then
703 # gcc 4.0 is just *so* much pickier on arguments that differ in signedness
704 # so we ignore that warnings for now
706 GCCOPTS
="$GCCOPTS -Wno-pointer-sign"
711 if test "X$ccache" = "Xyes"; then
715 if test "X$endian" = "Xbig"; then
716 defendian
="ROCKBOX_BIG_ENDIAN"
718 defendian
="ROCKBOX_LITTLE_ENDIAN"
722 -e "s,@ENDIAN@,${defendian},g" \
723 -e "s,^#undef ROCKBOX_HAS_LOGF,$use_logf,g" \
724 -e "s,@SIMSOUND@,$use_simsound,g" \
726 /* This header was made by configure */
727 #ifndef __BUILD_AUTOCONF_H
728 #define __BUILD_AUTOCONF_H
730 /* Define endianess for the target or simulator platform */
733 /* Define this if you build rockbox to support the logf logging and display */
734 #undef ROCKBOX_HAS_LOGF
736 /* Define this if you have the linux/soundcard.h header and thus can compile
737 the sound-playing code in the X11 sim */
740 #endif /* __BUILD_AUTOCONF_H */
743 if test "$simulator" = "yes"; then
744 # verify that we have a sed version we can use!
745 lines
=`echo "moo" | sed -e '/moo/cline1\nline2\nline3' | wc -l`
746 if test "$lines" -eq "1"; then
747 echo "You have a broken sed version. You must upgrade to be able to "
748 echo "generate a fine Makefile. See details at:"
749 echo "http://www.rockbox.org/twiki/bin/view/Main/BrokenSed"
752 version
=`sed --version | head -n 1`
753 echo "$version is a fine sed"
756 # add simul make stuff on the #SIMUL# line
757 simmagic
='/#SIMUL#/c\ @$(MAKE) -C $(SIMDIR) OBJDIR=$(BUILDDIR)/sim\n @$(MAKE) -C $(ROOTDIR)/uisimulator/common OBJDIR=$(BUILDDIR)/comsim'
759 # delete the line that matches
760 simmagic
='/#SIMUL#/D'
764 -e "s,@ROOTDIR@,${rootdir},g" \
765 -e "s,@DEBUG@,${debug},g" \
766 -e "s,@MEMORY@,${memory},g" \
767 -e "s,@TARGET@,${target},g" \
768 -e "s,@ARCHOS@,${archos},g" \
769 -e "s,@LANGUAGE@,${language},g" \
770 -e "s,@PWD@,${pwd},g" \
771 -e "s,@CC@,${CC},g" \
772 -e "s,@LD@,${LD},g" \
773 -e "s,@AR@,${AR},g" \
774 -e "s,@AS@,${AS},g" \
775 -e "s,@OC@,${OC},g" \
776 -e "s,@WINDRES@,${WINDRES},g" \
777 -e "s,@DLLTOOL@,${DLLTOOL},g" \
778 -e "s,@DLLWRAP@,${DLLWRAP},g" \
779 -e "s,@RANLIB@,${RANLIB},g" \
780 -e "s,@TOOL@,${tool},g" \
781 -e "s,@OUTPUT@,${output},g" \
782 -e "s,@APPEXTRA@,${appextra},g" \
783 -e "s,@ARCHOSROM@,${archosrom},g" \
784 -e "s,@FLASHFILE@,${flash},g" \
785 -e "s,@PLUGINS@,${plugins},g" \
786 -e "s,@CODECS@,${codecs},g" \
787 -e "s,@GCCOPTS@,${GCCOPTS},g" \
788 -e "s,@LDOPTS@,${LDOPTS},g" \
789 -e "s,@LOADADDRESS@,${loadaddress},g" \
790 -e "s,@EXTRADEF@,${extradefines},g" \
791 -e "s,@APPSDIR@,${appsdir},g" \
792 -e "s,@APPS@,${apps},g" \
793 -e "s,@SIMVER@,${simver},g" \
794 -e "s,@GCCVER@,${gccver},g" \
795 -e "s,@GCCNUM@,${gccnum},g" \
796 -e "s,@UNAME@,${uname},g" \
797 -e "s,@ENDIAN@,${defendian},g" \
800 ## Automaticly generated. http://www.rockbox.org/
802 export ROOTDIR=@ROOTDIR@
803 export FIRMDIR=\$(ROOTDIR)/firmware
804 export APPSDIR=@APPSDIR@
805 export TOOLSDIR=\$(ROOTDIR)/tools
806 export DOCSDIR=\$(ROOTDIR)/docs
808 export ARCHOS=@ARCHOS@
809 export ARCHOSROM=@ARCHOSROM@
810 export FLASHFILE=@FLASHFILE@
811 export TARGET=@TARGET@
813 export BUILDDIR=@PWD@
814 export LANGUAGE=@LANGUAGE@
815 export MEMORYSIZE=@MEMORY@
816 export VERSION=\$(shell date +%y%m%d-%H%M)
817 export MKFIRMWARE=@TOOL@
818 export BINARY=@OUTPUT@
819 export APPEXTRA=@APPEXTRA@
820 export ENABLEDPLUGINS=@PLUGINS@
821 export SOFTWARECODECS=@CODECS@
822 export EXTRA_DEFINES=@EXTRADEF@
828 export WINDRES=@WINDRES@
829 export DLLTOOL=@DLLTOOL@
830 export DLLWRAP=@DLLWRAP@
831 export RANLIB=@RANLIB@
832 export GCCOPTS=@GCCOPTS@
833 export LOADADDRESS=@LOADADDRESS@
834 export SIMVER=@SIMVER@
835 export SIMDIR=\$(ROOTDIR)/uisimulator/\$(SIMVER)
836 export LDOPTS=@LDOPTS@
837 export GCCVER=@GCCVER@
838 export GCCNUM=@GCCNUM@
841 # Do not print "Entering directory ..."
842 MAKEFLAGS += --no-print-directory
844 .PHONY: all clean tags zip
848 @\$(MAKE) -C \$(FIRMDIR) OBJDIR=\$(BUILDDIR)/firmware
849 @\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@
852 @\$(MAKE) -C \$(FIRMDIR) clean OBJDIR=\$(BUILDDIR)/firmware
853 @\$(MAKE) -C \$(APPSDIR) clean OBJDIR=\$(BUILDDIR)/@APPS@
854 @rm -rf rockbox.zip TAGS @APPS@ firmware comsim sim lang.h
858 \$(MAKE) -C \$(FIRMDIR) tags
859 \$(MAKE) -C \$(APPSDIR) tags
860 \$(MAKE) -C \$(APPSDIR)/plugins tags
861 \$(MAKE) -C \$(APPSDIR)/plugins/lib tags
864 \$(TOOLSDIR)/buildzip.pl -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY)
867 if [ "yes" = "$simulator" ]; then
869 cat >> Makefile
<<EOF
872 @echo "installing a full setup in your archos dir"
873 @(make zip && cd archos && unzip -oq ../rockbox.zip)
878 echo "Created Makefile"