Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: tools/trusted_cross_toolchains/mips_tc_build.sh

Issue 11036032: [MIPS] Script to build a trusted mipsel-linux-gnu cross toolchain from source. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2 #
3 # Copyright 2012 The Native Client Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can
5 # be found in the LICENSE file.
6
7 # This script is intended to build a mipsel-linux-gnu cross compilation
8 # toolchain that runs on x86 linux and generates code for a little-endian,
9 # hard-float, mips32 target.
10 #
11 # It expects the host machine to have relatively recent versions of GMP (4.2.0
12 # or later), MPFR (2.4.2), and MPC (0.8.1) in order to build the GCC.
13 #
14 # Common way to get those is:
15 # sudo apt-get install libmpfr-dev libmpc-dev libgmp3-dev
16 set -eu
Mark Seaborn 2012/10/04 15:10:46 Nit: add an empty line before this to separate it
17
18 arch="mips32"
19
20 top_dir=`pwd`
21 bld_dir="$top_dir/obj"
Mark Seaborn 2012/10/04 15:10:46 Can you make these less cryptic, please? i.e. "bu
22 tar_dir="$top_dir/tars"
23 src_dir="$top_dir/src"
24 ins_nam="mips-toolchain"
25 ins_dir="$top_dir/$ins_nam"
26 sys_dir="$ins_dir/sysroot"
27
28 export PATH=$ins_dir/bin:/usr/sbin:/usr/bin:/sbin:/bin
Mark Seaborn 2012/10/04 15:10:46 Please do export PATH=$ins_dir/bin:$PATH so that t
29
30 echo -n "cleaning up"
31 rm -rf $bld_dir
32 echo -n "."
33 rm -rf $sys_dir
34 echo -n "."
35 rm -rf $ins_dir
36 echo -n "."
37 rm -rf $src_dir
38 echo "done"
39
40 # get the code
41 echo "downloading the sources"
42
43 mkdir -p $tar_dir
44 cd $tar_dir
45
46
47
48 if [ ! -f 'binutils-2.22.tar.bz2' ]; then
49 wget http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2
Mark Seaborn 2012/10/04 15:10:46 Can you write wget http://ftp.gnu.org/gnu/binuti
50 fi
51 checksum=`sha1sum binutils-2.22.tar.bz2 | cut -d ' ' -f 1`
52 if [ "$checksum" != "65b304a0b9a53a686ce50a01173d1f40f8efe404" ]; then
53 echo "binutils-2.22.tar.bz2 sha1sum failed, file deleted"
Mark Seaborn 2012/10/04 15:10:46 Please indent blocks by 2 spaces
54 rm -f binutils-2.22.tar.bz2
55 exit
Mark Seaborn 2012/10/04 15:10:46 This should be "exit 1" since this is an error
56 fi
57
58
59
60 if [ ! -f 'gcc-4.6.3.tar.bz2' ]; then
Mark Seaborn 2012/10/04 15:10:46 There's a lot of duplication here. Can you factor
61 wget http://ftp.gnu.org/gnu/gcc/gcc-4.6.3/gcc-4.6.3.tar.bz2
62 fi
63 checksum=`sha1sum gcc-4.6.3.tar.bz2 | cut -d ' ' -f 1`
64 if [ "$checksum" != "ce317ca5c8185b58bc9300182b534608c578637f" ]; then
65 echo "gcc-4.6.3.tar.bz2 sha1sum failed, file deleted"
66 rm -f gcc-4.6.3.tar.bz2
67 exit
68 fi
69
70
71
72 if [ ! -f 'linux-2.6.38.4.tar.gz' ]; then
73 wget http://www.linux-mips.org/pub/linux/mips/kernel/v2.6/linux-2.6.38.4.tar.g z
74 fi
75 checksum=`sha1sum linux-2.6.38.4.tar.gz | cut -d ' ' -f 1`
76 if [ "$checksum" != "377fa5cf5f1d0c396759b1c4d147330e7e5b6d7f" ]; then
77 echo "linux-2.6.38.4.tar.gz sha1sum failed, file deleted"
78 rm -f linux-2.6.38.4.tar.gz
79 exit
80 fi
81
82
83
84 if [ ! -f 'gdb-7.5.tar.gz' ]; then
85 wget http://ftp.gnu.org/gnu/gdb/gdb-7.5.tar.gz
86 fi
87 checksum=`sha1sum gdb-7.5.tar.gz | cut -d ' ' -f 1`
88 if [ "$checksum" != "57b58bc5b959e420d9aeb4cfeaa3b2fd7c685a10" ]; then
89 echo "gdb-7.5.tar.gz sha1sum failed, file deleted"
90 rm -f gdb-7.5.tar.gz
91 exit
92 fi
93
94 svn export -r 20996 svn://svn.eglibc.org/branches/eglibc-2_14 eglibc-2_14
95
96
97
98 cd $top_dir
99
100 #untar all
Mark Seaborn 2012/10/04 15:10:46 Please put a space after '#' in comments. And cap
101 echo -n "unpacking the sources"
102 mkdir -p $src_dir
103 cd $src_dir
104 tar xjf $tar_dir/binutils-2.22.tar.bz2
105 echo -n "."
106 tar xjf $tar_dir/gcc-4.6.3.tar.bz2
107 echo -n "."
108 tar xzf $tar_dir/linux-2.6.38.4.tar.gz linux-2.6.38.4
109 echo -n "."
110 tar xzf $tar_dir/gdb-7.5.tar.gz
111 echo -n "."
112 #tar xzf $tar_dir/eglibc-2_14.tar.gz
Mark Seaborn 2012/10/04 15:10:46 Please remove this commented-out line
113 mv $tar_dir/eglibc-2_14 .
114 echo "done"
115 cd $top_dir
116
117 #prepare the code
118 cd $src_dir/eglibc-2_14/libc/ && ln -s ../ports ports && cd -
Mark Seaborn 2012/10/04 15:10:46 Can you replace "&&" with a newline, please? Same
119
120 cd $src_dir/binutils-2.22/gas/config && OLD_TEXT="as_warn_where (fragp->fr_file, fragp->fr_line, msg);" && NEW_TEXT="as_warn_where (fragp->fr_file, fragp->fr_li ne, \"%s\", msg);" && FILE_NAME="$PWD/tc-mips.c" && sed -i "s/$OLD_TEXT/$NEW_TEX T/g" "$FILE_NAME" && cd -
121
122
123 #build the toolchain
124 echo "building the toolchain"
125 mkdir -p $bld_dir/binutils/
126 cd $bld_dir/binutils/
127 $src_dir/binutils-2.22/configure --prefix=$ins_dir --target=mipsel-linux-gnu --w ith-sysroot=$sys_dir
128 make --jobs=3 all-binutils all-gas all-ld || exit 1
Mark Seaborn 2012/10/04 15:10:46 "|| exit 1" isn't necessary since you have "set -e
129 make --jobs=3 install-binutils install-gas install-ld || exit 1
130 mkdir -p $bld_dir/gcc/initial
Mark Seaborn 2012/10/04 15:10:46 For readability, can you separate the build of eac
131 cd $bld_dir/gcc/initial
132 $src_dir/gcc-4.6.3/configure --prefix=$ins_dir --disable-libssp --disable-libgom p --disable-libmudflap --disable-fixed-point --disable-decimal-float --with-m ips-plt --with-endian=little --with-arch=$arch --target=mipsel-linux-gnu --enabl e-languages=c --with-newlib --without-headers --disable-shared --disable-threads --disable-libquadmath --disable-libatomic
133 make --jobs=3 all || exit 1
134 make --jobs=3 install || exit 1
135 cd $src_dir/linux-2.6.38.4
136 make headers_install ARCH=mips INSTALL_HDR_PATH=$sys_dir/usr || exit 1
137 export BUILD_CC=gcc
138 export AR=mipsel-linux-gnu-ar
139 export RANLIB=mipsel-linux-gnu-ranlib
140 export CC=mipsel-linux-gnu-gcc
141 export CXX=mipsel-linux-gnu-g++
142 mkdir -p $bld_dir/eglibc/initial
143 cd $bld_dir/eglibc/initial
144 $src_dir/eglibc-2_14/libc/configure --prefix=/usr --with-headers=$sys_dir/usr/in clude --build=i686-pc-linux-gnu --host=mipsel-linux-gnu --disable-profile --with out-gd --without-cvs --enable-add-ons
145 make --jobs=3 install-headers install_root=$sys_dir install-bootstrap-headers=ye s || exit 1
146 mkdir -p $sys_dir/usr/lib
147 make csu/subdir_lib && cp csu/crt1.o csu/crti.o csu/crtn.o $sys_dir/usr/lib || exit 1
148 mipsel-linux-gnu-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $sys_dir/ usr/lib/libc.so
149 unset BUILD_CC AR RANLIB CC CXX
150 mkdir -p $bld_dir/gcc/intermediate
151 cd $bld_dir/gcc/intermediate
152 $src_dir/gcc-4.6.3/configure --prefix=$ins_dir --disable-libssp --disable-libgom p --disable-libmudflap --disable-fixed-point --disable-decimal-float --with-m ips-plt --with-endian=little --with-arch=$arch --target=mipsel-linux-gnu --enabl e-languages=c --with-sysroot=$sys_dir --disable-libquadmath --disable-libatomic
153 make --jobs=3 all || exit 1
154 make --jobs=3 install || exit 1
155 export BUILD_CC=gcc
156 export AR=mipsel-linux-gnu-ar
157 export RANLIB=mipsel-linux-gnu-ranlib
158 export CC=mipsel-linux-gnu-gcc
159 export CXX=mipsel-linux-gnu-g++
160 mkdir -p $bld_dir/eglibc/final
161 cd $bld_dir/eglibc/final
162 $src_dir/eglibc-2_14/libc/configure --prefix=/usr --with-headers=$sys_dir/usr/in clude --build=i686-pc-linux-gnu --host=mipsel-linux-gnu --disable-profile --with out-gd --without-cvs --enable-add-ons
163 make --jobs=3 all || exit 1
164 make --jobs=3 install install_root=$sys_dir || exit 1
165 unset BUILD_CC AR RANLIB CC CXX
166 mkdir -p $bld_dir/gcc/final
167 cd $bld_dir/gcc/final
168 $src_dir/gcc-4.6.3/configure --prefix=$ins_dir --disable-libssp --disable-libgom p --disable-libmudflap --disable-fixed-point --disable-decimal-float --with-m ips-plt --with-endian=little --with-arch=$arch --target=mipsel-linux-gnu --enabl e-languages=c,c++ --with-sysroot=$sys_dir --enable-__cxa_atexit
169 make --jobs=3 all || exit 1
170 make --jobs=3 install || exit 1
171 mkdir -p $bld_dir/gdb/
172 cd $bld_dir/gdb/
173 $src_dir/gdb-7.5/configure --prefix=$ins_dir --target=mipsel-linux-gnu
174 make --jobs=3 all-gdb
175 make --jobs=3 install-gdb
176 echo "done"
177
178 #Make toolchain tarball
179 echo -n "packing the toolchain..."
180 cd $top_dir
181 tar czf mips-toolchain.tar.gz $ins_nam
182
183 echo "done"
184 echo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698