diff options
Diffstat (limited to 'tools/rockboxdev.sh')
-rwxr-xr-x | tools/rockboxdev.sh | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/tools/rockboxdev.sh b/tools/rockboxdev.sh new file mode 100755 index 0000000000..302bb57672 --- /dev/null +++ b/tools/rockboxdev.sh | |||
@@ -0,0 +1,137 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # this is where this script will store downloaded files and check for already | ||
4 | # downloaded files | ||
5 | dlwhere="$HOME/tmp" | ||
6 | |||
7 | # will append the target string to the prefix dir mentioned here | ||
8 | # Note that the user running this script must be able to do make install in | ||
9 | # this given prefix directory. Also make sure that this given root dir | ||
10 | # exists. | ||
11 | prefix="/usr/local" | ||
12 | |||
13 | # The binutils version to use | ||
14 | binutils="2.16.1" | ||
15 | |||
16 | ############################################################################## | ||
17 | |||
18 | findtool(){ | ||
19 | file="$1" | ||
20 | |||
21 | IFS=":" | ||
22 | for path in $PATH | ||
23 | do | ||
24 | # echo "checks for $file in $path" >&2 | ||
25 | if test -f "$path/$file"; then | ||
26 | echo "$path/$file" | ||
27 | return | ||
28 | fi | ||
29 | done | ||
30 | } | ||
31 | |||
32 | input() { | ||
33 | read response | ||
34 | echo $response | ||
35 | } | ||
36 | |||
37 | #$1 file | ||
38 | #$2 URL"root | ||
39 | getfile() { | ||
40 | tool=`findtool curl` | ||
41 | if test -z "$tool"; then | ||
42 | tool=`findtool wget` | ||
43 | if test -n "$tool"; then | ||
44 | # wget download | ||
45 | echo "download $2/$1 using wget" | ||
46 | $tool -O $dlwhere/$1 $2/$1 | ||
47 | fi | ||
48 | else | ||
49 | # curl download | ||
50 | echo "download $2/$1 using curl" | ||
51 | $tool -Lo $dlwhere/$1 $2/$1 | ||
52 | fi | ||
53 | if test -z "$tool"; then | ||
54 | echo "couldn't find downloader tool to use!" | ||
55 | exit | ||
56 | fi | ||
57 | |||
58 | |||
59 | } | ||
60 | |||
61 | echo "Pick target arch:" | ||
62 | echo "s. sh" | ||
63 | echo "m. m68k" | ||
64 | echo "a. arm" | ||
65 | |||
66 | arch=`input` | ||
67 | |||
68 | case $arch in | ||
69 | [Ss]) | ||
70 | target="sh-elf" | ||
71 | gccver="4.0.3" | ||
72 | ;; | ||
73 | [Mm]) | ||
74 | target="m68k-elf" | ||
75 | gccver="3.4.6" | ||
76 | ;; | ||
77 | [Aa]) | ||
78 | target="arm-elf" | ||
79 | gccver="4.0.3" | ||
80 | ;; | ||
81 | *) | ||
82 | echo "unsupported" | ||
83 | exit | ||
84 | ;; | ||
85 | esac | ||
86 | |||
87 | if test -d build-rbdev; then | ||
88 | echo "you have a build-rbdev dir already, please remove and rerun" | ||
89 | exit | ||
90 | fi | ||
91 | |||
92 | bindir="$prefix/$target/bin" | ||
93 | echo "Summary:" | ||
94 | echo "Target: $target" | ||
95 | echo "gcc $gccver" | ||
96 | echo "binutils $binutils" | ||
97 | echo "install in $prefix/$target" | ||
98 | echo "" | ||
99 | echo "Set your PATH to point to $bindir" | ||
100 | |||
101 | |||
102 | if test -f "$dlwhere/binutils-$binutils.tar.bz2"; then | ||
103 | echo "binutils $binutils already downloaded" | ||
104 | else | ||
105 | getfile binutils-$binutils.tar.bz2 ftp://ftp.gnu.org/pub/gnu/binutils | ||
106 | fi | ||
107 | |||
108 | if test -f "$dlwhere/gcc-$gccver.tar.bz2"; then | ||
109 | echo "gcc $gccver already downloaded" | ||
110 | else | ||
111 | getfile gcc-$gccver.tar.bz2 ftp://ftp.gnu.org/pub/gnu/gcc/gcc-$gccver | ||
112 | fi | ||
113 | |||
114 | |||
115 | mkdir build-rbdev | ||
116 | cd build-rbdev | ||
117 | echo "extracting binutils" | ||
118 | tar xjf $dlwhere/binutils-$binutils.tar.bz2 | ||
119 | echo "extracting gcc" | ||
120 | tar xf $dlwhere/gcc-$gccver.tar.bz2 | ||
121 | |||
122 | mkdir build-binu | ||
123 | cd build-binu | ||
124 | ../binutils-$binutils/configure --target=$target --prefix=$prefix/$target | ||
125 | make | ||
126 | make install | ||
127 | PATH="${PATH}:$bindir" | ||
128 | SHELL=/bin/sh # seems to be needed by the gcc build in some cases | ||
129 | |||
130 | cd ../ | ||
131 | mkdir build-gcc | ||
132 | cd build-gcc | ||
133 | ../gcc-$gccver/configure --target=$target --prefix=$prefix/$target --enable-languages=c | ||
134 | make | ||
135 | make install | ||
136 | |||
137 | echo "done" | ||