tool we use on the web site to produce an image of a font
[kugel-rb.git] / tools / configure
blob4e6a6d369102eb69c617cbc3aacf6b4d5088fe36
1 #!/bin/sh
2 # __________ __ ___.
3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 # \/ \/ \/ \/ \/
8 # $Id$
13 # Begin Function Definitions
15 input() {
16 read response
17 echo $response
20 whichsim () {
22 if [ -z "$simver" ]; then
24 ##################################################################
25 # Figure out win32/x11 GUI
27 echo ""
28 echo "Build (W)in32 or (X)11 GUI version? (X)"
30 option=`input`;
32 case $option in
33 [Ww])
34 simver="win32"
37 simver="x11"
39 esac
40 echo "Selected $simver simulator"
45 simul () {
47 ##################################################################
48 # Figure out where the firmware code is!
51 # a file to check for in the uisimulator root dir
52 simfile="$simver/lcd-$simver.c"
54 for dir in uisimulator . .. ../uisimulator ../../uisimulator; do
55 if [ -f "$dir/$simfile" ]; then
56 simdir="$dir/$simver"
57 break
59 done
61 if [ -z "$simdir" ]; then
62 echo "This script couldn't find your uisimulator/$simver directory. Please enter the"
63 echo "full path to your uisimulator/$simver directory here:"
65 simdir=`input`
68 sed > Makefile \
69 -e "s,@SIMDIR@,${simdir},g" \
70 -e "s,@TOOLSDIR@,${toolsdir},g" \
71 -e "s,@TARGET@,${target},g" \
72 -e "s,@ARCHOS@,${archos},g" \
73 -e "s,@DEBUG@,${debug},g" \
74 -e "s,@DISPLAY@,${display},g" \
75 -e "s,@KEYPAD@,${keypad},g" \
76 -e "s,@PWD@,${pwd},g" \
77 -e "s,@LANGUAGE@,${language},g" \
78 -e "s,@SIMVER@,${simver},g" \
79 <<EOF
80 ## Automaticly generated. http://rockbox.haxx.se
82 ARCHOS=@ARCHOS@
83 SIMDIR=@SIMDIR@
84 TOOLSDIR=@TOOLSDIR@
85 DEBUG=@DEBUG@
86 TARGET=@TARGET@
87 DISPLAY=@DISPLAY@
88 KEYPAD=@KEYPAD@
89 THISDIR="@PWD@"
90 SIMVER=@SIMVER@
91 LANGUAGE=@LANGUAGE@
92 VERSION=\$(shell date +%y%m%d-%H%M)
94 .PHONY:
96 all: sim
98 sim:
99 \$(MAKE) -C \$(SIMDIR) DISPLAY=\$(DISPLAY) KEYPAD=\$(KEYPAD) OBJDIR=\$(THISDIR) VERSION=\$(VERSION) LANGUAGE=\$(LANGUAGE)
101 clean:
102 \$(MAKE) -C \$(SIMDIR) DISPLAY=\$(DISPLAY) KEYPAD=\$(KEYPAD) OBJDIR=\$(THISDIR) clean
104 tags:
105 @rm -f TAGS
106 make -C \$(SIMDIR) DISPLAY=\$(DISPLAY) KEYPAD=\$(KEYPAD) OBJDIR=\$(THISDIR) tags
110 echo "Created Makefile"
112 if [ -d "archos" ]; then
113 echo "sub directory archos already present"
114 else
115 mkdir archos
116 echo "created an archos subdirectory for simulating the hard disk"
121 picklang() {
122 # figure out which languages that are around
123 for file in $appsdir/lang/*.lang; do
124 clean=`echo $file | sed -e 's:.*/::g' | cut "-d." -f1`
125 langs="$langs $clean"
126 done
128 num=1
129 for one in $langs; do
130 echo "$num. $one"
131 num=`expr $num + 1`
132 done
134 read pick
135 return $pick;
138 whichlang() {
139 num=1
140 for one in $langs; do
141 if [ "$num" = "$pick" ]; then
142 echo $one
143 return
145 num=`expr $num + 1`
146 done
151 # Beging Build Script
154 target=$1
155 debug=$2
157 if test "$1" = "--help"; then
158 echo "Rockbox configure script."
159 echo "Invoke this in a directory to generate a Makefile to build Rockbox"
160 echo "Do *NOT* run this within the tools directory!"
161 exit
164 if test -r "configure"; then
165 # this is a check for a configure script in the current directory, it there
166 # is one, try to figure out if it is this one!
168 if { grep "^# Jukebox" configure >/dev/null 2>&1 ; } then
169 echo "WEEEEEEEEP. Don't run this configure script within the tools directory."
170 echo "It will only cause you pain and grief. Instead do this:"
171 echo ""
172 echo " cd .."
173 echo " mkdir build-dir"
174 echo " cd build-dir"
175 echo " ../tools/configure"
176 echo ""
177 echo "Much happiness will arise from this. Enjoy"
178 exit
182 if [ "$target" = "--help" -o \
183 "$target" = "-h" ]; then
184 echo "Just invoke the script and answer the questions."
185 echo "This script will write a Makefile for you"
186 exit
189 # get our current directory
190 pwd=`pwd`;
192 if [ "$target" = "update" ]; then
193 update="1"
194 target=""
195 if [ -f Makefile ]; then
196 if { grep "^## Auto" Makefile >/dev/null 2>&1 ; } then
197 echo "Existing generated Makefile found. Getting defaults from it."
198 archos=`grep "^ARCHOS=" Makefile | cut -d= -f2-`
199 target=`grep "^TARGET=" Makefile | cut -d= -f2-`
200 debug=`grep "^DEBUG=" Makefile | cut -d= -f2-`
201 language=`grep "^LANGUAGE=" Makefile | cut -d= -f2-`
202 memory=`grep "^MEMORYSIZE=" Makefile | cut -d= -f2-`
204 if [ "$debug" = "SIMULATOR=1" ]; then
205 simulator="yes"
206 display=`grep "^DISPLAY=" Makefile | cut -d= -f2-`
207 keypad=`grep "^KEYPAD=" Makefile | cut -d= -f2-`
208 simver=`grep "^SIMVER=" Makefile | cut -d= -f2-`
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 "$archos" ]; then
222 ##################################################################
223 # Figure out target platform
226 echo "Enter target platform: (default is Archos Recorder)"
228 echo "1 - Archos Player/Studio"
229 echo "2 - Archos Recorder"
230 echo "3 - Archos FM Recorder"
231 echo "4 - Archos Recorder v2"
232 echo "5 - Neo mStation"
233 echo "6 - Neo 35"
235 getit=`input`;
237 case $getit in
240 archos="player"
241 target="-DARCHOS_PLAYER"
242 display="-DHAVE_LCD_CHARCELLS"
243 keypad="-DHAVE_PLAYER_KEYPAD"
247 archos="fmrecorder"
248 target="-DARCHOS_FMRECORDER"
249 display="-DHAVE_LCD_BITMAP"
250 keypad="-DHAVE_RECORDER_KEYPAD"
254 archos="recorderv2"
255 target="-DARCHOS_RECORDERV2"
256 display="-DHAVE_LCD_BITMAP"
257 keypad="-DHAVE_RECORDER_KEYPAD"
261 archos="neomstation"
262 target="-DNEO_MSTATION"
263 display="-DHAVE_NEOLCD_CHARCELLS"
264 keypad="-DHAVE_NEO_KEYPAD"
268 archos="neo35"
269 target="-DNEO_35"
270 display="-DHAVE_NEOLCD_CHARCELLS"
271 keypad="-DHAVE_NEO_KEYPAD"
275 archos="recorder"
276 target="-DARCHOS_RECORDER"
277 display="-DHAVE_LCD_BITMAP"
278 keypad="-DHAVE_RECORDER_KEYPAD"
281 esac
283 echo "Platform set to $archos"
287 if [ -z "$memory" ]; then
288 size="2"
289 if [ -z "$update" ]; then
290 echo "Enter size of your RAM (in MB): (defaults to 2)"
291 size=`input`;
294 case $size in
296 memory="8"
299 memory="2"
302 esac
303 echo "Memory size selected: $memory MB"
306 if [ -z "$debug" ]; then
307 ##################################################################
308 # Figure out debug on/off
310 echo "Build (N)ormal, (D)ebug or (S)imulated version? (N)"
312 option=`input`;
314 case $option in
315 [Ss])
316 debug="SIMULATOR=1"
317 simulator="yes"
318 echo "Simulator build selected"
319 whichsim
321 [Dd])
322 debug="DEBUG=1"
323 echo "Debug build selected"
326 debug="NODEBUG=1"
327 echo "Normal build selected"
330 esac
333 ##################################################################
334 # Figure out where the firmware code is!
337 firmfile="crt0.S" # a file to check for in the firmware root dir
339 for dir in firmware . .. ../firmware ../../firmware; do
340 if [ -f $dir/$firmfile ]; then
341 firmdir=$dir
342 break
344 done
346 if [ -z "$firmdir" ]; then
347 echo "This script couldn't find your firmware directory. Please enter the"
348 echo "full path to the firmware directory here:"
350 firmdir=`input`
353 ##################################################################
354 # Figure out where the apps code is!
357 appsfile="credits.c" # a file to check for in the apps root dir
359 for dir in apps . .. ../apps ../../apps $firmdir/apps $firmdir/../apps; do
360 if [ -f $dir/$appsfile ]; then
361 appsdir=$dir
362 break
364 done
366 if [ -z "$appsdir" ]; then
367 echo "This script couldn't find your apps directory. Please enter the"
368 echo "full path to the apps directory here:"
370 appsdir=`input`
373 ##################################################################
374 # Figure out where the tools directory is!
377 toolsfile="descramble.c" # a file to check for in the tools root dir
379 for dir in tools . .. ../tools ../../tools $firmdir/tools $firmdir/../tools; do
380 if [ -f $dir/$toolsfile ]; then
381 toolsdir="$dir"
382 break
384 done
386 if [ -z "$toolsdir" ]; then
387 # no file found, check if (some of) the necessary tools are in the PATH
388 # already
390 toolsexe="scramble"
392 for dir in `echo $PATH | tr ':' ' '`; do
393 if [ -x "$dir/$toolsexe" ]; then
394 echo "found $toolsexe in $dir"
395 toolsdir="$dir"
396 break
398 done
402 if [ -z "$toolsdir" ]; then
403 echo "This script couldn't find your tools directory. Please enter the"
404 echo "full path to the tools directory here:"
406 toolsdir=`input`
409 if [ -z "$language" ]; then
411 echo "Select a number for the language to use (default is english)"
413 picklang
414 language=`whichlang`
416 if [ -z "$language" ]; then
417 # pick a default
418 language="english"
420 echo "Language set to $language"
423 if [ "yes" = "$simulator" ]; then
424 # we have already dealt with the simulator Makefile separately
425 simul
426 exit
429 sed > Makefile \
430 -e "s,@FIRMDIR@,${firmdir},g" \
431 -e "s,@APPSDIR@,${appsdir},g" \
432 -e "s,@TOOLSDIR@,${toolsdir},g" \
433 -e "s,@DEBUG@,${debug},g" \
434 -e "s,@MEMORY@,${memory},g" \
435 -e "s,@TARGET@,${target},g" \
436 -e "s,@ARCHOS@,${archos},g" \
437 -e "s,@LANGUAGE@,${language},g" \
438 -e "s,@PWD@,${pwd},g" \
439 <<EOF
440 ## Automaticly generated. http://rockbox.haxx.se
442 FIRMDIR=@FIRMDIR@
443 APPSDIR=@APPSDIR@
444 TOOLSDIR=@TOOLSDIR@
445 DEBUG=@DEBUG@
446 ARCHOS=@ARCHOS@
447 TARGET=@TARGET@
448 THISDIR="@PWD@"
449 LANGUAGE=@LANGUAGE@
450 MEMORYSIZE=@MEMORY@
451 VERSION=\$(shell date +%y%m%d-%H%M)
453 .PHONY: firmware apps
455 all: firmware apps
457 firmware:
458 \$(MAKE) -C \$(FIRMDIR) TARGET=\$(TARGET) \$(DEBUG) OBJDIR=\$(THISDIR) MEM=\$(MEMORYSIZE) TOOLSDIR=\$(TOOLSDIR)
460 apps:
461 \$(MAKE) -C \$(APPSDIR) TARGET=\$(TARGET) \$(DEBUG) OBJDIR=\$(THISDIR) VERSION=\$(VERSION) LANGUAGE=\$(LANGUAGE) MEM=\$(MEMORYSIZE) TOOLSDIR=\$(TOOLSDIR)
463 clean-firmware:
464 \$(MAKE) -C \$(FIRMDIR) TARGET=\$(TARGET) OBJDIR=\$(THISDIR) clean
466 clean-apps:
467 \$(MAKE) -C \$(APPSDIR) TARGET=\$(TARGET) OBJDIR=\$(THISDIR) clean
469 clean:
470 \$(MAKE) clean-firmware clean-apps
472 tags-firmware:
473 \$(MAKE) -C \$(FIRMDIR) TARGET=\$(TARGET) OBJDIR=\$(THISDIR) tags
475 tags-apps:
476 \$(MAKE) -C \$(APPSDIR) TARGET=\$(TARGET) OBJDIR=\$(THISDIR) tags
478 tags:
479 @rm -f TAGS
480 \$(MAKE) tags-firmware tags-apps
483 echo "Created Makefile"