CPU definition file
[kugel-rb.git] / tools / configure
blob154166bf6025a7284dbd0339b06f4b8d82da2e0a
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"
31 coldfirecc () {
32 CC=m68k-elf-gcc
33 LD=m68k-elf-ld
34 AR=m68k-elf-ar
35 AS=m68k-elf-as
36 OC=m68k-elf-objcopy
37 GCCOPTS="$CCOPTS -m5200"
40 whichsim () {
42 if [ -z "$simver" ]; then
44 ##################################################################
45 # Figure out win32/x11 GUI
47 echo ""
48 echo "Build (W)in32 or (X)11 GUI version? (X)"
50 option=`input`;
52 case $option in
53 [Ww])
54 simver="win32"
57 simver="x11"
59 esac
60 echo "Selected $simver simulator"
65 simul () {
67 sed > Makefile \
68 -e "s,@ROOTDIR@,${rootdir},g" \
69 -e "s,@ARCHOS@,${archos},g" \
70 -e "s,@DEBUG@,${debug},g" \
71 -e "s,@KEYPAD@,${keypad},g" \
72 -e "s,@PWD@,${pwd},g" \
73 -e "s,@LANGUAGE@,${language},g" \
74 -e "s,@TARGET@,${target},g" \
75 -e "s,@SIMVER@,${simver},g" \
76 <<EOF
77 ## Automaticly generated. http://rockbox.haxx.se
79 export ARCHOS=@ARCHOS@
80 export ROOTDIR=@ROOTDIR@
81 export FIRMDIR=\$(ROOTDIR)/firmware
82 export APPSDIR=\$(ROOTDIR)/apps
83 export TOOLSDIR=\$(ROOTDIR)/tools
84 export DOCSDIR=\$(ROOTDIR)/docs
85 export APPSDIR=@ROOTDIR@/apps
86 export SIMDIR=\$(ROOTDIR)/uisimulator/@SIMVER@
87 export DEBUG=@DEBUG@
88 export KEYPAD=@KEYPAD@
89 export OBJDIR=@PWD@
90 export SIMVER=@SIMVER@
91 export TARGET=@TARGET@
92 export LANGUAGE=@LANGUAGE@
93 export VERSION=\$(shell date +%y%m%d-%H%M)
95 .PHONY:
97 all: sim
99 sim:
100 \$(MAKE) -C \$(SIMDIR)
102 clean:
103 \$(MAKE) -C \$(SIMDIR) clean
104 rm -rf rockbox.zip
106 tags:
107 @rm -f TAGS
108 make -C \$(SIMDIR) tags
110 zip:
111 \$(TOOLSDIR)/buildzip.pl -r "\$(ROOTDIR)" sim\$(TARGET)
113 install:
114 @echo "installing a full setup in your archos dir"
115 @(make zip && cd archos && unzip -oq ../rockbox.zip)
118 echo "Created Makefile"
120 if [ -d "archos" ]; then
121 echo "sub directory archos already present"
122 else
123 mkdir archos
124 echo "created an archos subdirectory for simulating the hard disk"
129 picklang() {
130 # figure out which languages that are around
131 for file in $rootdir/apps/lang/*.lang; do
132 clean=`echo $file | sed -e 's:.*/::g' | cut "-d." -f1`
133 langs="$langs $clean"
134 done
136 num=1
137 for one in $langs; do
138 echo "$num. $one"
139 num=`expr $num + 1`
140 done
142 read pick
143 return $pick;
146 whichlang() {
147 num=1
148 for one in $langs; do
149 if [ "$num" = "$pick" ]; then
150 echo $one
151 return
153 num=`expr $num + 1`
154 done
157 target=$1
158 debug=$2
160 if test "$1" = "--help"; then
161 echo "Rockbox configure script."
162 echo "Invoke this in a directory to generate a Makefile to build Rockbox"
163 echo "Do *NOT* run this within the tools directory!"
164 exit
167 if test -r "configure"; then
168 # this is a check for a configure script in the current directory, it there
169 # is one, try to figure out if it is this one!
171 if { grep "^# Jukebox" configure >/dev/null 2>&1 ; } then
172 echo "WEEEEEEEEP. Don't run this configure script within the tools directory."
173 echo "It will only cause you pain and grief. Instead do this:"
174 echo ""
175 echo " cd .."
176 echo " mkdir build-dir"
177 echo " cd build-dir"
178 echo " ../tools/configure"
179 echo ""
180 echo "Much happiness will arise from this. Enjoy"
181 exit
185 if [ "$target" = "--help" -o \
186 "$target" = "-h" ]; then
187 echo "Just invoke the script and answer the questions."
188 echo "This script will write a Makefile for you"
189 exit
192 # get our current directory
193 pwd=`pwd`;
195 if [ "$target" = "update" ]; then
196 echo "configure update is unfortunately no longer supported"
197 exit
198 else
200 echo "This script will setup your Rockbox build environment."
201 echo "Further docs here: http://rockbox.haxx.se/docs/"
202 echo ""
206 if [ -z "$rootdir" ]; then
207 ##################################################################
208 # Figure out where the source code root is!
211 firmfile="crt0.S" # a file to check for in the firmware root dir
213 for dir in . .. ../.. ../rockbox*; do
214 if [ -f $dir/firmware/$firmfile ]; then
215 rootdir=$dir
216 break
218 done
220 if [ -z "$rootdir" ]; then
221 echo "This script couldn't find your source code root directory. Please enter the"
222 echo "full path to the source code directory here:"
224 firmdir=`input`
227 #####################################################################
228 # Convert the possibly relative directory name to an absolute version
230 now=`pwd`
231 cd $rootdir
232 rootdir=`pwd`
234 echo "Using this source code root directory:"
235 echo $rootdir
236 echo ""
238 # cd back to the build dir
239 cd $now
242 if [ -z "$archos" ]; then
244 ##################################################################
245 # Figure out target platform
248 echo "Enter target platform: (default is Archos Recorder)"
250 echo "1 - Archos Player/Studio"
251 echo "2 - Archos Recorder"
252 echo "3 - Archos FM Recorder"
253 echo "4 - Archos Recorder v2"
254 echo "7 - Archos Ondio SP"
255 echo "8 - Archos Ondio FM"
256 echo "9 - Iriver H100"
258 getit=`input`;
260 case $getit in
263 archos="player"
264 target="-DARCHOS_PLAYER"
265 shcc
266 tool="scramble"
267 output="archos.mod"
268 appextra="player"
269 archosrom=""
270 plugins="yes"
274 archos="fmrecorder"
275 target="-DARCHOS_FMRECORDER"
276 shcc
277 tool="scramble -fm"
278 output="ajbrec.ajz"
279 appextra="recorder"
280 archosrom="$pwd/rombox.ucl"
281 plugins="yes"
285 archos="recorderv2"
286 target="-DARCHOS_RECORDERV2"
287 shcc
288 tool="scramble -v2"
289 output="ajbrec.ajz"
290 appextra="recorder"
291 archosrom="$pwd/rombox.ucl"
292 plugins="yes"
296 archos="ondiosp"
297 target="-DARCHOS_ONDIOSP"
298 shcc
299 tool="scramble -osp"
300 output="ajbrec.ajz"
301 appextra="recorder"
302 archosrom=""
303 plugins=""
307 archos="ondiofm"
308 target="-DARCHOS_ONDIOFM"
309 shcc
310 tool="scramble -ofm"
311 output="ajbrec.ajz"
312 appextra="recorder"
313 archosrom=""
314 plugins=""
318 archos="h100"
319 target="-DIRIVER_H100"
320 memory=32 # always
321 coldfirecc
322 tool="not-written-yet"
323 output="rockbox.iriver"
324 appextra=""
325 archosrom=""
326 plugins="yes"
330 archos="recorder"
331 target="-DARCHOS_RECORDER"
332 shcc
333 tool="scramble"
334 output="ajbrec.ajz"
335 appextra="recorder"
336 archosrom="$pwd/rombox.ucl"
337 plugins="yes"
340 esac
342 echo "Platform set to $archos"
346 if [ -z "$memory" ]; then
347 size="2"
348 if [ -z "$update" ]; then
349 echo "Enter size of your RAM (in MB): (defaults to 2)"
350 size=`input`;
353 case $size in
355 memory="8"
358 memory="2"
361 esac
362 echo "Memory size selected: $memory MB"
365 if [ -z "$debug" ]; then
366 ##################################################################
367 # Figure out debug on/off
369 echo "Build (N)ormal, (D)ebug or (S)imulated version? (N)"
371 option=`input`;
373 case $option in
374 [Ss])
375 debug="1"
376 simulator="yes"
377 echo "Simulator build selected"
378 whichsim
380 [Dd])
381 debug="1"
382 echo "Debug build selected"
383 GCCOPTS="$GCCOPTS -g -DDEBUG"
386 debug=""
387 echo "Normal build selected"
388 GCCOPTS="$GCCOPTS -fomit-frame-pointer -fschedule-insns"
391 esac
395 if [ -z "$language" ]; then
397 echo "Select a number for the language to use (default is english)"
399 picklang
400 language=`whichlang`
402 if [ -z "$language" ]; then
403 # pick a default
404 language="english"
406 echo "Language set to $language"
409 if [ "yes" = "$simulator" ]; then
410 # we have already dealt with the simulator Makefile separately
411 simul
412 exit
415 sed > Makefile \
416 -e "s,@ROOTDIR@,${rootdir},g" \
417 -e "s,@DEBUG@,${debug},g" \
418 -e "s,@MEMORY@,${memory},g" \
419 -e "s,@TARGET@,${target},g" \
420 -e "s,@ARCHOS@,${archos},g" \
421 -e "s,@LANGUAGE@,${language},g" \
422 -e "s,@PWD@,${pwd},g" \
423 -e "s,@CC@,${CC},g" \
424 -e "s,@LD@,${LD},g" \
425 -e "s,@AR@,${AR},g" \
426 -e "s,@AS@,${AS},g" \
427 -e "s,@OC@,${OC},g" \
428 -e "s,@TOOL@,${tool},g" \
429 -e "s,@OUTPUT@,${output},g" \
430 -e "s,@APPEXTRA@,${appextra},g" \
431 -e "s,@ARCHOSROM@,${archosrom},g" \
432 -e "s,@PLUGINS@,${plugins},g" \
433 -e "s,@GCCOPTS@,${GCCOPTS},g" \
434 <<EOF
435 ## Automaticly generated. http://rockbox.haxx.se
437 export ROOTDIR=@ROOTDIR@
438 export FIRMDIR=\$(ROOTDIR)/firmware
439 export APPSDIR=\$(ROOTDIR)/apps
440 export TOOLSDIR=\$(ROOTDIR)/tools
441 export DOCSDIR=\$(ROOTDIR)/docs
442 export DEBUG=@DEBUG@
443 export ARCHOS=@ARCHOS@
444 export ARCHOSROM=@ARCHOSROM@
445 export TARGET=@TARGET@
446 export OBJDIR=@PWD@
447 export LANGUAGE=@LANGUAGE@
448 export MEMORYSIZE=@MEMORY@
449 export VERSION=\$(shell date +%y%m%d-%H%M)
450 export MKFIRMWARE=\$(TOOLSDIR)/@TOOL@
451 export BINARY=@OUTPUT@
452 export APPEXTRA=@APPEXTRA@
453 export ENABLEDPLUGINS=@PLUGINS@
454 export CC=@CC@
455 export LD=@LD@
456 export AR=@AR@
457 export AS=@AS@
458 export OC=@OC@
459 export GCCOPTS=@GCCOPTS@
461 .PHONY: all clean tags zip
463 all:
464 @\$(MAKE) -C \$(FIRMDIR)
465 @\$(MAKE) -C \$(APPSDIR)
467 clean:
468 @\$(MAKE) -C \$(FIRMDIR) clean
469 @\$(MAKE) -C \$(APPSDIR) clean
470 @rm -f rockbox.zip TAGS
472 tags:
473 @rm -f TAGS
474 \$(MAKE) -C \$(FIRMDIR) tags
475 \$(MAKE) -C \$(APPSDIR) tags
476 \$(MAKE) -C \$(APPSDIR)/plugins tags
477 \$(MAKE) -C \$(APPSDIR)/plugins/lib tags
479 zip:
480 \$(TOOLSDIR)/buildzip.pl -r "\$(ROOTDIR)" \$(TARGET)
483 echo "Created Makefile"