summaryrefslogtreecommitdiff
path: root/tools/configure
blob: 7e7dbcb57040ed20cac4e354b249479a03533f5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
#!/bin/sh
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
# $Id$
#


#
# Begin Function Definitions
#
input() {
    read response
    echo $response
}

whichsim () {

if [ -z "$simver" ]; then

  ##################################################################
  # Figure out win32/x11 GUI
  #
  echo ""
  echo "Build (W)in32 or  (X)11 GUI version? (X)"

  option=`input`;

  case $option in
   [Ww])
     simver="win32"
     ;;
   *)
     simver="x11"
     ;;
   esac
fi
}


simul () {

 ##################################################################
 # Figure out where the firmware code is!
 #

 # a file to check for in the uisimulator root dir
 simfile="$simver/lcd-$simver.c" 

 for dir in uisimulator . .. ../uisimulator ../../uisimulator; do
   if [ -f "$dir/$simfile" ]; then
     simdir="$dir/$simver"
     break
   fi
 done

 if [ -z "$simdir" ]; then
   echo "This script couldn't find your uisimulator/$simver directory. Please enter the"
   echo "full path to your uisimulator/$simver directory here:"

   simdir=`input`
 fi

sed > Makefile \
 -e "s,@SIMDIR@,${simdir},g" \
 -e "s,@TARGET@,${target},g" \
 -e "s,@ARCHOS@,${archos},g" \
 -e "s,@DEBUG@,${debug},g" \
 -e "s,@DISPLAY@,${display},g" \
 -e "s,@KEYPAD@,${keypad},g" \
 -e "s,@PWD@,${pwd},g" \
 -e "s,@LANGUAGE@,${language},g" \
 -e "s,@SIMVER@,${simver},g" \
 -e "s,@EXTRA_DEFINES@,${extra_defines},g" \
<<EOF 
## Automaticly generated. http://rockbox.haxx.se

ARCHOS=@ARCHOS@
SIMDIR=@SIMDIR@
DEBUG=@DEBUG@
TARGET=@TARGET@
DISPLAY=@DISPLAY@
KEYPAD=@KEYPAD@
THISDIR="@PWD@"
SIMVER=@SIMVER@
LANGUAGE=@LANGUAGE@
VERSION=\$(shell date +%y%m%d-%H%M)
EXTRA_DEFINES=@EXTRA_DEFINES@

.PHONY: 

all: sim

sim:
	\$(MAKE) -C \$(SIMDIR) DISPLAY=\$(DISPLAY) KEYPAD=\$(KEYPAD) OBJDIR=\$(THISDIR) VERSION=\$(VERSION) LANGUAGE=\$(LANGUAGE) EXTRA_DEFINES="\$(EXTRA_DEFINES)"

clean:
	\$(MAKE) -C \$(SIMDIR) DISPLAY=\$(DISPLAY) KEYPAD=\$(KEYPAD) OBJDIR=\$(THISDIR) clean

tags:
	@rm -f TAGS
	make -C \$(SIMDIR) DISPLAY=\$(DISPLAY) KEYPAD=\$(KEYPAD) OBJDIR=\$(THISDIR) tags

EOF

  echo "Created Makefile"

  if [ -d "archos" ]; then
    echo "sub directory archos already present"
  else
    mkdir archos
    echo "created an archos subdirectory for simulating the hard disk"
  fi

}

picklang() {
    # figure out which languages that are around
    for file in $appsdir/lang/*.lang; do
        clean=`echo $file | sed -e 's:.*/::g' | cut "-d." -f1`
        langs="$langs $clean"
    done

    num=1
    for one in $langs; do
        echo "$num. $one"
        num=`expr $num + 1`
    done

    read pick
    return $pick;
}

whichlang() {
    num=1
    for one in $langs; do
        if [ "$num" = "$pick" ]; then
            echo $one
            return
        fi
        num=`expr $num + 1`
    done
}


#
# Beging Build Script
#

target=$1
debug=$2

if test "$1" = "--help"; then
  echo "Rockbox configure script."
  echo "Invoke this in a directory to generate a Makefile to build Rockbox"
  echo "Do *NOT* run this within the tools directory!"
  exit
fi

if test -r "configure"; then
 # this is a check for a configure script in the current directory, it there
 # is one, try to figure out if it is this one!

 if { grep "^#   Jukebox" configure >/dev/null 2>&1 ; } then
   echo "WEEEEEEEEP. Don't run this configure script within the tools directory."
   echo "It will only cause you pain and grief. Instead do this:"
   echo ""
   echo " cd .."
   echo " mkdir build-dir"
   echo " cd build-dir"
   echo " ../tools/configure"
   echo ""
   echo "Much happiness will arise from this. Enjoy"
   exit
 fi
fi

if [ "$target" = "--help" -o \
     "$target" = "-h" ]; then
  echo "Just invoke the script and answer the questions."
  echo "This script will write a Makefile for you"
  exit
fi

# get our current directory
pwd=`pwd`;

if [ "$target" = "update" ]; then
  target=""
  if [ -f Makefile ]; then
    if { grep "^## Auto" Makefile >/dev/null 2>&1 ; } then
      echo "Existing generated Makefile found. Getting defaults from it."
      archos=`grep "^ARCHOS=" Makefile | cut -d= -f2-`
      target=`grep "^TARGET=" Makefile | cut -d= -f2-`
      debug=`grep "^DEBUG=" Makefile | cut -d= -f2-`
      language=`grep "^LANGUAGE=" Makefile | cut -d= -f2-`
      extra_defines=`grep "^EXTRA_DEFINES=" Makefile | cut -d= -f2-`

      if [ "$debug" = "SIMULATOR=1" ]; then
        simulator="yes"
        display=`grep "^DISPLAY=" Makefile | cut -d= -f2-`
        keypad=`grep "^KEYPAD=" Makefile | cut -d= -f2-`
        simver=`grep "^SIMVER=" Makefile | cut -d= -f2-`
      fi
    fi
  fi
else

echo "Setup your Rockbox build environment."
echo "http://rockbox.haxx.se/"
echo ""

fi

if [ -z "$archos" ]; then

##################################################################
# Figure out target platform
#

  echo "Enter target platform: (defaults to Recorder)"

  echo "1 - Archos Player/Studio"
  echo "2 - Archos Recorder"
  echo "3 - Archos FM Recorder"

  getit=`input`;

  case $getit in

   1)
    archos="player"
    target="-DARCHOS_PLAYER"
    display="-DHAVE_LCD_CHARCELLS"
    keypad="-DHAVE_PLAYER_KEYPAD"
    ;;

   3)
    archos="fmrecorder"
    target="-DARCHOS_FMRECORDER"
    display="-DHAVE_LCD_BITMAP"
    keypad="-DHAVE_RECORDER_KEYPAD"
    ;;

   *)
    archos="recorder"
    target="-DARCHOS_RECORDER"
    display="-DHAVE_LCD_BITMAP"
    keypad="-DHAVE_RECORDER_KEYPAD"
    ;;

  esac
fi

if [ -z "$extra_defines" ]; then
    if [  "player" != "$archos" ] ; then
        disable_demos="-DDISABLE_NOTHING"
        disable_games=""

        echo "Do you want to use Demos? (Y)"
        getit=`input`;
        if [ "n" = "$getit" -o "N" = "$getit" ] ; then
            disable_demos="-DDISABLE_DEMOS"
        fi
 
        echo "Do you want to play Games? (Y)"
        getit=`input`;
        if [ "n" = "$getit" -o "N" = "$getit" ] ; then
            disable_games=" -DDISABLE_GAMES"
        fi

        extra_defines="$disable_demos$disable_games"
    fi
fi


if [ -z "$debug" ]; then
  ##################################################################
  # Figure out debug on/off
  #
  echo ""
  echo "Build (N)ormal, (D)ebug or (S)imulated version? (N)"

  option=`input`;

  case $option in
    [Ss])
      debug="SIMULATOR=1"
      simulator="yes"
      whichsim
      ;;
    [Dd])
      debug="DEBUG=1"
      ;;
    *)
      debug="NODEBUG=1"
      ;;

  esac
fi

##################################################################
# Figure out where the firmware code is!
#

firmfile="crt0.S" # a file to check for in the firmware root dir

for dir in firmware . .. ../firmware ../../firmware; do
  if [ -f $dir/$firmfile ]; then
    firmdir=$dir
    break
  fi
done

if [ -z "$firmdir" ]; then
  echo "This script couldn't find your firmware directory. Please enter the"
  echo "full path to the firmware directory here:"

  firmdir=`input`
fi

##################################################################
# Figure out where the apps code is!
#

appsfile="credits.c" # a file to check for in the apps root dir

for dir in apps . .. ../apps ../../apps $firmdir/apps $firmdir/../apps; do
    if [ -f $dir/$appsfile ]; then
        appsdir=$dir
        break
    fi
done

if [ -z "$appsdir" ]; then
    echo "This script couldn't find your apps directory. Please enter the"
    echo "full path to the apps directory here:"

    appsdir=`input`
fi

if [ -z "$language" ]; then

    echo "Select a number for the language to use (default is english)"

    picklang
    language=`whichlang`

    if [ -z "$language" ]; then
        # pick a default
        language="english"
    fi
fi

if [ "yes" = "$simulator" ]; then
    # we have already dealt with the simulator Makefile separately
    simul
    exit
fi

sed > Makefile \
 -e "s,@FIRMDIR@,${firmdir},g" \
 -e "s,@APPSDIR@,${appsdir},g" \
 -e "s,@DEBUG@,${debug},g" \
 -e "s,@TARGET@,${target},g" \
 -e "s,@ARCHOS@,${archos},g" \
 -e "s,@LANGUAGE@,${language},g" \
 -e "s,@EXTRA_DEFINES@,${extra_defines},g" \
 -e "s,@PWD@,${pwd},g" \
<<EOF 
## Automaticly generated. http://rockbox.haxx.se

FIRMDIR=@FIRMDIR@
APPSDIR=@APPSDIR@
DEBUG=@DEBUG@
ARCHOS=@ARCHOS@
TARGET=@TARGET@
THISDIR="@PWD@"
LANGUAGE=@LANGUAGE@
VERSION=\$(shell date +%y%m%d-%H%M)

EXTRA_DEFINES=@EXTRA_DEFINES@
.PHONY: firmware apps

all: firmware apps

firmware:
	\$(MAKE) -C \$(FIRMDIR) TARGET=\$(TARGET) \$(DEBUG) OBJDIR=\$(THISDIR) EXTRA_DEFINES="\$(EXTRA_DEFINES)"

apps:
	\$(MAKE) -C \$(APPSDIR) TARGET=\$(TARGET) \$(DEBUG) OBJDIR=\$(THISDIR) VERSION=\$(VERSION) LANGUAGE=\$(LANGUAGE) EXTRA_DEFINES="\$(EXTRA_DEFINES)"

clean-firmware:
	\$(MAKE) -C \$(FIRMDIR) TARGET=\$(TARGET) OBJDIR=\$(THISDIR) clean

clean-apps:
	\$(MAKE) -C \$(APPSDIR) TARGET=\$(TARGET) OBJDIR=\$(THISDIR) clean

clean:
	\$(MAKE) clean-firmware clean-apps

tags-firmware:
	\$(MAKE) -C \$(FIRMDIR) TARGET=\$(TARGET) OBJDIR=\$(THISDIR) tags

tags-apps:
	\$(MAKE) -C \$(APPSDIR) TARGET=\$(TARGET) OBJDIR=\$(THISDIR) tags

tags:
	@rm -f TAGS
	\$(MAKE) tags-firmware tags-apps
EOF

echo "Created Makefile"