-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAVR_GCC_multicross.sh
executable file
·216 lines (174 loc) · 5.83 KB
/
AVR_GCC_multicross.sh
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
#!/bin/bash -ex
# Copyright (c) 2014-2015 Arduino LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# linux - ./build.all.new.bash
# windows - ./build.all.new.bash -h=i686-w64-mingw32"
export BINUTILS_VERSION=2.26.1
export GCC_VERSION=5.4.0
export ISL_VERSION=0.16
export CLOOG_VERSION=0.18.1
export GMP_VERSION=5.1.3
export MPFR_VERSION=3.1.3
export MPC_VERSION=1.0.3
for i in "$@"
do
case $i in
-h=*|--host=*)
export HOST="${i#*=}"
;;
-p=*|--path=*)
export PATH=$PATH:"${i#*=}"
;;
-cc=*)
export CC="${i#*=}"
;;
-cxx=*)
export CXX="${i#*=}"
;;
-cflags=*)
export CFLAGS="${i#*=}"
;;
-cxxflags=*)
export CXXFLAGS="${i#*=}"
;;
-ldflags=*)
export LDFLAGS="${i#*=}"
;;
*)
# unknown option
;;
esac
done
export home=`pwd`
#rm *.tar.*
if [ ! -f binutils-$BINUTILS_VERSION.tar.bz2 ]; then
wget ftp://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.bz2
fi
rm -rf binutils-$BINUTILS_VERSION
tar xf binutils-$BINUTILS_VERSION.tar.bz2
cd binutils-$BINUTILS_VERSION
curl -L https://projects.archlinux.org/svntogit/community.git/plain/trunk/avr-size.patch?h=packages/avr-binutils > 01-avr-size.patch
patch -Np0 < 01-avr-size.patch
sed -i -e "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" libiberty/configure
config_guess=`./config.guess`
if [ "x"$HOST == "x" ]; then
export HOST=${config_guess}
fi
export pkgdir=${home}/pkg-$HOST/
export pkgdir_build=${home}/pkg-${config_guess}/
./configure \
--prefix=$pkgdir \
--with-bugurl=https://github.com/arduino/toolchain-avr/ \
--enable-gold \
--enable-ld=default \
--enable-plugins \
--enable-threads \
--with-pic \
--enable-lto \
--disable-shared \
--disable-werror \
--disable-multilib \
--host=$HOST \
--build=${config_guess} \
--target=avr
make configure-host
make -j8
make install
cd $home
rm -rf gcc-$GCC_VERSION
if [ ! -f gcc-$GCC_VERSION.tar.bz2 ]; then
wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.bz2
fi
if [ ! -f isl-$ISL_VERSION.tar.bz2 ]; then
wget http://isl.gforge.inria.fr/isl-$ISL_VERSION.tar.bz2
fi
if [ ! -f cloog-$CLOOG_VERSION.tar.gz ]; then
wget http://www.bastoul.net/cloog/pages/download/cloog-$CLOOG_VERSION.tar.gz
fi
if [ ! -f gmp-$GMP_VERSION.tar.bz2 ]; then
wget http://mirror.switch.ch/ftp/mirror/gnu/gmp/gmp-$GMP_VERSION.tar.bz2
fi
if [ ! -f mpfr-$MPFR_VERSION.tar.bz2 ]; then
wget http://mirror.switch.ch/ftp/mirror/gnu/mpfr/mpfr-$MPFR_VERSION.tar.bz2
fi
if [ ! -f mpc-$MPC_VERSION.tar.gz ]; then
wget http://www.multiprecision.org/mpc/download/mpc-$MPC_VERSION.tar.gz
fi
tar xf gcc-$GCC_VERSION.tar.bz2
tar xf isl-$ISL_VERSION.tar.bz2
tar xf cloog-$CLOOG_VERSION.tar.gz
tar xf gmp-$GMP_VERSION.tar.bz2
tar xf mpfr-$MPFR_VERSION.tar.bz2
tar xf mpc-$MPC_VERSION.tar.gz
rm -rf gcc-$GCC_VERSION/cloog gcc-$GCC_VERSION/isl gcc-$GCC_VERSION/gmp gcc-$GCC_VERSION/mpfr gcc-$GCC_VERSION/mpc
mv cloog-$CLOOG_VERSION gcc-$GCC_VERSION/cloog
mv isl-$ISL_VERSION gcc-$GCC_VERSION/isl
mv gmp-$GMP_VERSION gcc-$GCC_VERSION/gmp
mv mpfr-$MPFR_VERSION gcc-$GCC_VERSION/mpfr
mv mpc-$MPC_VERSION gcc-$GCC_VERSION/mpc
cd gcc-$GCC_VERSION/
sed -i -e "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
echo $GCC_VERSION > gcc/BASE-VER
export CFLAGS_FOR_TARGET='-O2 -pipe'
export CXXFLAGS_FOR_TARGET='-O2 -pipe'
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgdir_build}/${config_guess}/avr/lib/
export PATH=$PATH:${pkgdir_build}/bin/
cd $home
rm -rf gcc-build
mkdir gcc-build && cd gcc-build
$home/gcc-$GCC_VERSION/configure \
--disable-install-libiberty \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-libunwind-exceptions \
--disable-nls \
--enable-fixed-point \
--enable-long-long \
--disable-werror \
--disable-__cxa_atexit \
--enable-checking=release \
--enable-clocale=gnu \
--enable-cloog-backend=isl \
--enable-gnu-unique-object \
--with-avrlibc=yes \
--with-dwarf2 \
--enable-languages=c,c++ \
--disable-libada \
--disable-doc \
--enable-lto \
--enable-gold \
--disable-plugin \
--prefix=$pkgdir \
--disable-shared \
--with-gnu-ld \
--host=$HOST \
--build=${config_guess} \
--target=avr
#remove __HAVE_MALLOC_H__ if cross compiling for OSX
#http://glaros.dtc.umn.edu/gkhome/node/694
make -j8
make -j1 install-strip
find $pkgdir/lib -type f -name "*.a" -exec ${pkgdir_build}/bin/avr-strip --strip-debug '{}' \;
rm -rf $pkgdir/share/man/man7
rm -rf $pkgdir/share/info
cd $home
rm -rf avr-libc
git clone https://github.com/vancegroup-mirrors/avr-libc.git
cd avr-libc/avr-libc
./bootstrap --prefix=$pkgdir/
CC=${pkgdir_build}/bin/avr-gcc ./configure --prefix=$pkgdir/ --build=`./config.guess` --host=avr
make -j8
make install