Added ID3 searching
[kugel-rb.git] / tools / configure
blob1c58a39e4af1d399a37044a8cea62a49a955d083
1 #!/bin/sh
2 # __________ __ ___.
3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 # \/ \/ \/ \/ \/
8 # $Id$
11 # global CC options for all platforms
12 CCOPTS="-W -Wall -O -nostdlib -ffreestanding -Wstrict-prototypes"
15 # Begin Function Definitions
17 input() {
18 read response
19 echo $response
22 shcc () {
23 CC=sh-elf-gcc
24 LD=sh-elf-ld
25 AR=sh-elf-ar
26 AS=sh-elf-as
27 OC=sh-elf-objcopy
28 GCCOPTS="$CCOPTS -m1"
29 GCCOPTIMIZE="-fomit-frame-pointer -fschedule-insns"
32 calmrisccc () {
33 CC=calmrisc16-unknown-elf-gcc
34 LD=calmrisc16-unknown-elf-ld
35 AR=calmrisc16-unknown-elf-ar
36 AS=calmrisc16-unknown-elf-as
37 OC=calmrisc16-unknown-elf-objcopy
38 GCCOPTS="$CCOPTS"
39 GCCOPTIMIZE="-fomit-frame-pointer"
42 coldfirecc () {
43 CC=m68k-elf-gcc
44 LD=m68k-elf-ld
45 AR=m68k-elf-ar
46 AS=m68k-elf-as
47 OC=m68k-elf-objcopy
48 GCCOPTS="$CCOPTS -g -m5200 -Wa\,-m5249"
49 GCCOPTIMIZE="-fomit-frame-pointer"
52 whichsim () {
54 if [ -z "$simver" ]; then
56 ##################################################################
57 # Figure out win32/x11 GUI
59 echo ""
60 echo "Build (W)in32 or (X)11 GUI version? (X)"
62 option=`input`;
64 case $option in
65 [Ww])
66 simver="win32"
69 simver="x11"
71 esac
72 echo "Selected $simver simulator"
77 simul () {
79 sed > Makefile \
80 -e "s,@ROOTDIR@,${rootdir},g" \
81 -e "s,@ARCHOS@,${archos},g" \
82 -e "s,@DEBUG@,${debug},g" \
83 -e "s,@KEYPAD@,${keypad},g" \
84 -e "s,@PWD@,${pwd},g" \
85 -e "s,@LANGUAGE@,${language},g" \
86 -e "s,@TARGET@,${target},g" \
87 -e "s,@PLUGINS@,${plugins},g" \
88 -e "s,@SIMVER@,${simver},g" \
89 <<EOF
90 ## Automaticly generated. http://rockbox.haxx.se
92 export ARCHOS=@ARCHOS@
93 export ROOTDIR=@ROOTDIR@
94 export FIRMDIR=\$(ROOTDIR)/firmware
95 export APPSDIR=\$(ROOTDIR)/apps
96 export TOOLSDIR=\$(ROOTDIR)/tools
97 export DOCSDIR=\$(ROOTDIR)/docs
98 export APPSDIR=@ROOTDIR@/apps
99 export SIMDIR=\$(ROOTDIR)/uisimulator/@SIMVER@
100 export DEBUG=@DEBUG@
101 export KEYPAD=@KEYPAD@
102 export OBJDIR=@PWD@
103 export SIMVER=@SIMVER@
104 export TARGET=@TARGET@
105 export LANGUAGE=@LANGUAGE@
106 export VERSION=\$(shell date +%y%m%d-%H%M)
107 export ENABLEDPLUGINS=@PLUGINS@
109 .PHONY:
111 all: sim
113 sim:
114 \$(MAKE) -C \$(SIMDIR)
116 clean:
117 \$(MAKE) -C \$(SIMDIR) clean
118 rm -rf rockbox.zip
120 tags:
121 @rm -f TAGS
122 make -C \$(SIMDIR) tags
124 zip:
125 \$(TOOLSDIR)/buildzip.pl -r "\$(ROOTDIR)" sim\$(TARGET)
127 install:
128 @echo "installing a full setup in your archos dir"
129 @(make zip && cd archos && unzip -oq ../rockbox.zip)
132 echo "Created Makefile"
134 if [ -d "archos" ]; then
135 echo "sub directory archos already present"
136 else
137 mkdir archos
138 echo "created an archos subdirectory for simulating the hard disk"
143 picklang() {
144 # figure out which languages that are around
145 for file in $rootdir/apps/lang/*.lang; do
146 clean=`echo $file | sed -e 's:.*/::g' | cut "-d." -f1`
147 langs="$langs $clean"
148 done
150 num=1
151 for one in $langs; do
152 echo "$num. $one"
153 num=`expr $num + 1`
154 done
156 read pick
157 return $pick;
160 whichlang() {
161 num=1
162 for one in $langs; do
163 if [ "$num" = "$pick" ]; then
164 echo $one
165 return
167 num=`expr $num + 1`
168 done
171 target=$1
172 debug=$2
174 if test "$1" = "--help"; then
175 echo "Rockbox configure script."
176 echo "Invoke this in a directory to generate a Makefile to build Rockbox"
177 echo "Do *NOT* run this within the tools directory!"
178 exit
181 if test -r "configure"; then
182 # this is a check for a configure script in the current directory, it there
183 # is one, try to figure out if it is this one!
185 if { grep "^# Jukebox" configure >/dev/null 2>&1 ; } then
186 echo "WEEEEEEEEP. Don't run this configure script within the tools directory."
187 echo "It will only cause you pain and grief. Instead do this:"
188 echo ""
189 echo " cd .."
190 echo " mkdir build-dir"
191 echo " cd build-dir"
192 echo " ../tools/configure"
193 echo ""
194 echo "Much happiness will arise from this. Enjoy"
195 exit
199 if [ "$target" = "--help" -o \
200 "$target" = "-h" ]; then
201 echo "Just invoke the script and answer the questions."
202 echo "This script will write a Makefile for you"
203 exit
206 # get our current directory
207 pwd=`pwd`;
209 if [ "$target" = "update" ]; then
210 echo "configure update is unfortunately no longer supported"
211 exit
212 else
214 echo "This script will setup your Rockbox build environment."
215 echo "Further docs here: http://rockbox.haxx.se/docs/"
216 echo ""
220 if [ -z "$rootdir" ]; then
221 ##################################################################
222 # Figure out where the source code root is!
225 firmfile="crt0.S" # a file to check for in the firmware root dir
227 for dir in . .. ../.. ../rockbox*; do
228 if [ -f $dir/firmware/$firmfile ]; then
229 rootdir=$dir
230 break
232 done
234 if [ -z "$rootdir" ]; then
235 echo "This script couldn't find your source code root directory. Please enter the"
236 echo "full path to the source code directory here:"
238 firmdir=`input`
241 #####################################################################
242 # Convert the possibly relative directory name to an absolute version
244 now=`pwd`
245 cd $rootdir
246 rootdir=`pwd`
248 echo "Using this source code root directory:"
249 echo $rootdir
250 echo ""
252 # cd back to the build dir
253 cd $now
256 if [ -z "$archos" ]; then
258 ##################################################################
259 # Figure out target platform
262 echo "Enter target platform: (default is Archos Recorder)"
264 echo "1 - Archos Player/Studio"
265 echo "2 - Archos Recorder"
266 echo "3 - Archos FM Recorder"
267 echo "4 - Archos Recorder v2"
268 echo "5 - Archos Gmini 120"
269 echo "7 - Archos Ondio SP"
270 echo "8 - Archos Ondio FM"
271 echo "9 - Iriver H100"
273 getit=`input`;
275 case $getit in
278 archos="player"
279 target="-DARCHOS_PLAYER"
280 shcc
281 tool="$rootdir/tools/scramble"
282 output="archos.mod"
283 appextra="player"
284 archosrom="$pwd/rombox.ucl"
285 flash="$pwd/rockbox.ucl"
286 plugins="yes"
290 archos="fmrecorder"
291 target="-DARCHOS_FMRECORDER"
292 shcc
293 tool="$rootdir/tools/scramble -fm"
294 output="ajbrec.ajz"
295 appextra="recorder"
296 archosrom=""
297 flash="$pwd/rockbox.ucl"
298 plugins="yes"
302 archos="recorderv2"
303 target="-DARCHOS_RECORDERV2"
304 shcc
305 tool="$rootdir/tools/scramble -v2"
306 output="ajbrec.ajz"
307 appextra="recorder"
308 archosrom="$pwd/rombox.ucl"
309 flash="$pwd/rockbox.ucl"
310 plugins="yes"
314 archos="gmini120"
315 target="-DARCHOS_GMINI120"
316 memory=16 # fixed size (16 is a guess, remove comment when checked)
317 calmrisccc
318 tool="$rootdir/tools/scramble" # not correct but...
319 output="rockboxgmini"
320 appextra="recorder"
321 archosrom=""
322 flash=""
323 plugins="" # disabled for now, enable later on
327 archos="ondiosp"
328 target="-DARCHOS_ONDIOSP"
329 shcc
330 tool="$rootdir/tools/scramble -osp"
331 output="ajbrec.ajz"
332 appextra="recorder"
333 archosrom="$pwd/rombox.ucl"
334 flash="$pwd/rockbox.ucl"
335 plugins="yes"
339 archos="ondiofm"
340 target="-DARCHOS_ONDIOFM"
341 shcc
342 tool="$rootdir/tools/scramble -ofm"
343 output="ajbrec.ajz"
344 appextra="recorder"
345 archosrom="$pwd/rombox.ucl"
346 flash="$pwd/rockbox.ucl"
347 plugins="yes"
351 archos="h100"
352 target="-DIRIVER_H100"
353 memory=32 # always
354 coldfirecc
355 tool="$rootdir/tools/scramble -iriver"
356 output="rockbox.iriver"
357 appextra="recorder"
358 archosrom=""
359 flash=""
360 plugins=""
364 archos="recorder"
365 target="-DARCHOS_RECORDER"
366 shcc
367 tool="$rootdir/tools/scramble"
368 output="ajbrec.ajz"
369 appextra="recorder"
370 archosrom="$pwd/rombox.ucl"
371 flash="$pwd/rockbox.ucl"
372 plugins="yes"
375 esac
377 echo "Platform set to $archos"
381 if [ -z "$memory" ]; then
382 size="2"
383 if [ -z "$update" ]; then
384 echo "Enter size of your RAM (in MB): (defaults to 2)"
385 size=`input`;
388 case $size in
390 memory="8"
393 memory="2"
396 esac
397 echo "Memory size selected: $memory MB"
400 if [ -z "$debug" ]; then
401 ##################################################################
402 # Figure out debug on/off
404 echo "Build (N)ormal, (D)ebug or (S)imulated version? (N)"
406 option=`input`;
408 case $option in
409 [Ss])
410 debug="1"
411 simulator="yes"
412 echo "Simulator build selected"
413 whichsim
415 [Dd])
416 debug="1"
417 echo "Debug build selected"
418 GCCOPTS="$GCCOPTS -g -DDEBUG"
421 debug=""
422 echo "Normal build selected"
423 GCCOPTS="$GCCOPTS $GCCOPTIMIZE"
426 esac
430 if [ -z "$language" ]; then
432 echo "Select a number for the language to use (default is english)"
434 picklang
435 language=`whichlang`
437 if [ -z "$language" ]; then
438 # pick a default
439 language="english"
441 echo "Language set to $language"
444 if [ "yes" = "$simulator" ]; then
445 # we have already dealt with the simulator Makefile separately
446 simul
447 exit
450 sed > Makefile \
451 -e "s,@ROOTDIR@,${rootdir},g" \
452 -e "s,@DEBUG@,${debug},g" \
453 -e "s,@MEMORY@,${memory},g" \
454 -e "s,@TARGET@,${target},g" \
455 -e "s,@ARCHOS@,${archos},g" \
456 -e "s,@LANGUAGE@,${language},g" \
457 -e "s,@PWD@,${pwd},g" \
458 -e "s,@CC@,${CC},g" \
459 -e "s,@LD@,${LD},g" \
460 -e "s,@AR@,${AR},g" \
461 -e "s,@AS@,${AS},g" \
462 -e "s,@OC@,${OC},g" \
463 -e "s,@TOOL@,${tool},g" \
464 -e "s,@OUTPUT@,${output},g" \
465 -e "s,@APPEXTRA@,${appextra},g" \
466 -e "s,@ARCHOSROM@,${archosrom},g" \
467 -e "s,@FLASHFILE@,${flash},g" \
468 -e "s,@PLUGINS@,${plugins},g" \
469 -e "s,@GCCOPTS@,${GCCOPTS},g" \
470 <<EOF
471 ## Automaticly generated. http://rockbox.haxx.se
473 export ROOTDIR=@ROOTDIR@
474 export FIRMDIR=\$(ROOTDIR)/firmware
475 export APPSDIR=\$(ROOTDIR)/apps
476 export TOOLSDIR=\$(ROOTDIR)/tools
477 export DOCSDIR=\$(ROOTDIR)/docs
478 export DEBUG=@DEBUG@
479 export ARCHOS=@ARCHOS@
480 export ARCHOSROM=@ARCHOSROM@
481 export FLASHFILE=@FLASHFILE@
482 export TARGET=@TARGET@
483 export OBJDIR=@PWD@
484 export LANGUAGE=@LANGUAGE@
485 export MEMORYSIZE=@MEMORY@
486 export VERSION=\$(shell date +%y%m%d-%H%M)
487 export MKFIRMWARE=@TOOL@
488 export BINARY=@OUTPUT@
489 export APPEXTRA=@APPEXTRA@
490 export ENABLEDPLUGINS=@PLUGINS@
491 export CC=@CC@
492 export LD=@LD@
493 export AR=@AR@
494 export AS=@AS@
495 export OC=@OC@
496 export GCCOPTS=@GCCOPTS@
498 .PHONY: all clean tags zip
500 all:
501 @\$(MAKE) -C \$(FIRMDIR)
502 @\$(MAKE) -C \$(APPSDIR)
504 clean:
505 @\$(MAKE) -C \$(FIRMDIR) clean
506 @\$(MAKE) -C \$(APPSDIR) clean
507 @rm -f rockbox.zip TAGS
509 tags:
510 @rm -f TAGS
511 \$(MAKE) -C \$(FIRMDIR) tags
512 \$(MAKE) -C \$(APPSDIR) tags
513 \$(MAKE) -C \$(APPSDIR)/plugins tags
514 \$(MAKE) -C \$(APPSDIR)/plugins/lib tags
516 zip:
517 \$(TOOLSDIR)/buildzip.pl -r "\$(ROOTDIR)" \$(TARGET)
520 echo "Created Makefile"