[24e7a2]: buildgcc.sh  Maximize  Restore  History

Download this file

164 lines (135 with data), 4.6 kB

  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
#!/bin/bash
CC=gcc-3.4
export CC
DIALOG=`which dialog`
if [ 0$DIALOG = 0 -a 0$1 != 0--defaults ]; then
echo Dialog package not found and --defaults not specified
echo Either install dialog package, or run 'buildgcc --defaults'
fi
# Defaults
GCC_VERSION=4.3.4
GCC_PATCH_FOLDER=gcc-4.x
GMP_VERSION=4.3.1
MPFR_VERSION=2.4.1
TARGET_LOCATION=/opt/mspgcc-gcc-$GCC_VERSION
BINUTILS_VERSION=2.19.1
GNU_MIRROR=ftp.uni-kl.de
BINPACKAGE_NAME=
if [ 0$1 != 0--defaults ]; then
$DIALOG --menu "Select GCC version to build" 12 50 4 1 "gcc-4.3.4" 2 "gcc-4.2.4" 3 "gcc-3.3.6" 4 "gcc-3.2.3" 2>/tmp/dialog.ans
if [ $? == 0 -a -e /tmp/dialog.ans ]; then
if [ `cat /tmp/dialog.ans` = 1 ]; then
GCC_VERSION=4.3.4
GCC_PATCH_FOLDER=gcc-4.x
GMP_VERSION=4.3.1
MPFR_VERSION=2.4.1
fi
if [ `cat /tmp/dialog.ans` = 2 ]; then
GCC_VERSION=4.2.4
GCC_PATCH_FOLDER=gcc-4.x
fi
if [ `cat /tmp/dialog.ans` = 3 ]; then
GCC_VERSION=3.3.6
GCC_PATCH_FOLDER=gcc-3.3
fi
if [ `cat /tmp/dialog.ans` = 4 ]; then
GCC_VERSION=3.2.3
GCC_PATCH_FOLDER=gcc-3.2
fi
rm /tmp/dialog.ans
TARGET_LOCATION=/opt/mspgcc-gcc-$GCC_VERSION
else
echo Build cancelled
exit
fi
fi
WRITE_FAILURE=0
if [ ! -e $TARGET_LOCATION ]; then
mkdir $TARGET_LOCATION 2> /dev/null || WRITE_FAILURE=1
fi
touch $TARGET_LOCATION/test.dat 2>/dev/null || WRITE_FAILURE=1
rm $TARGET_LOCATION/test.dat 2> /dev/null || WRITE_FAILURE=1
if [ $WRITE_FAILURE == 1 ]; then
echo ERROR: Cannot write to $TARGET_LOCATION !
echo Please ensure that the directory exists and is writable by user \"$USER\"
echo
echo The following two commands typically achieve this:
echo " sudo mkdir -p $TARGET_LOCATION"
echo " sudo chown $USER $TARGET_LOCATION"
echo
exit 1
fi
echo ---------------------------------------------------------------
echo Building GCC $GCC_VERSION
echo Target location: $TARGET_LOCATION
echo ---------------------------------------------------------------
export PATH=$TARGET_LOCATION/bin:$PATH
echo "Removing build directory ..."
rm -rf build
mkdir -p build archives
echo "Downloading files ..."
cd archives
test -e gcc-$GCC_VERSION.tar.bz2 || wget -c ftp://$GNU_MIRROR/pub/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.bz2 || exit 3
test -e binutils-$BINUTILS_VERSION.tar.bz2 || wget -c ftp://$GNU_MIRROR/pub/gnu/binutils/binutils-$BINUTILS_VERSION.tar.bz2 || exit 4
if [ x"$GMP_VERSION" != x"" -a ! -e gmp-$GMP_VERSION.tar.bz2 ]; then
wget -c ftp://$GNU_MIRROR/pub/gnu/gmp/gmp-$GMP_VERSION.tar.bz2 || exit 4
fi
if [ x"$MPFR_VERSION" != x"" -a ! -e mpfr-$MPFR_VERSION.tar.bz2 ]; then
wget -c http://www.mpfr.org/mpfr-$MPFR_VERSION/mpfr-$MPFR_VERSION.tar.bz2 || exit 4
fi
cd ..
echo "Starting build ..."
cd build
echo "Unpacking binutils ..."
tar xjf ../archives/binutils-$BINUTILS_VERSION.tar.bz2
cd binutils-$BINUTILS_VERSION
if [ -e ../../binutils-$BINUTILS_VERSION.patch ]
then
patch -p1 < ../../binutils-$BINUTILS_VERSION.patch
fi
./configure --prefix=$TARGET_LOCATION --target=msp430 || exit 5
make || exit 6
make install || exit 7
cd ..
echo "Unpacking GCC ..."
tar xjf ../archives/gcc-$GCC_VERSION.tar.bz2
echo "Building GCC ..."
cd gcc-$GCC_VERSION
# additional patches
for PATCH in ../../patches/gcc-$GCC_VERSION*.patch; do
echo "Applying extra patch $PATCH ..."
patch -p1 < $PATCH
done
if [ x"$GMP_VERSION" != x"" ]; then
tar xjf ../../archives/gmp-$GMP_VERSION.tar.bz2 || exit 1
mv gmp-$GMP_VERSION gmp || exit 1
fi
if [ x"$MPFR_VERSION" != x"" ]; then
tar xjf ../../archives/mpfr-$MPFR_VERSION.tar.bz2 || exit 1
mv mpfr-$MPFR_VERSION mpfr || exit 1
fi
cp -r ../../gcc/$GCC_PATCH_FOLDER/* . || exit 8
cd ..
mkdir buildgcc-$GCC_VERSION
cd buildgcc-$GCC_VERSION
`pwd`/../gcc-$GCC_VERSION/configure --prefix=$TARGET_LOCATION --target=msp430 --enable-languages=c,c++ || exit 9
make || exit 10
make install || exit 11
cd ..
echo "Building msp430-libc..."
cp -r ../msp430-libc buildlibc
cd buildlibc
mkdir -p src/msp1 src/msp2
cd src
PREFIX=$TARGET_LOCATION
export PREFIX
make
make install || exit 13
echo "!<arch>" > 0lib.tmp
cp 0lib.tmp $TARGET_LOCATION/lib/libstdc++.a || exit 1
rm 0lib.tmp
cp $TARGET_LOCATION/msp430/include/sys/inttypes.h $TARGET_LOCATION/msp430/include/inttypes.h || exit 1
echo ---------------------------------------------------------------------------------
echo Build succeeded
echo Do not forget to add $TARGET_LOCATION/bin to your PATH environment variable
echo ---------------------------------------------------------------------------------

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks