Project

General

Profile

gnu-arm-build.2.sh

blombo, 09/07/2011 11:32 AM

 
1
#!/bin/sh
2

    
3
ROOT=`pwd`
4
SRCDIR=$ROOT/src
5
BUILDDIR=$ROOT/build
6
PREFIX=$ROOT/install
7

    
8
GCC_SRC=gcc-4.5.2.tar.bz2
9
GCC_VERSION=4.5.2
10
GCC_DIR=gcc-$GCC_VERSION
11

    
12
BINUTILS_SRC=binutils-2.21.1a.tar.bz2
13
BINUTILS_VERSION=2.21.1
14
BINUTILS_DIR=binutils-$BINUTILS_VERSION
15

    
16
NEWLIB_SRC=newlib-1.19.0.tar.gz
17
NEWLIB_VERSION=1.19.0
18
NEWLIB_DIR=newlib-$NEWLIB_VERSION
19

    
20
#INSIGHT_SRC=insight-6.8-1.tar.bz2
21
#INSIGHT_VERSION=6.8-1
22
#INSIGHT_DIR=insight-$INSIGHT_VERSION
23

    
24
echo "I will build an arm-elf cross-compiler:
25

    
26
  Prefix: $PREFIX
27
  Sources: $SRCDIR
28
  Build files: $BUILDDIR
29

    
30
Press ^C now if you do NOT want to do this."
31
read IGNORE
32

    
33
#
34
# Helper functions.
35
#
36
unpack_source()
37
{
38
(
39
    cd $SRCDIR
40
    ARCHIVE_SUFFIX=${1##*.}
41
    if [ "$ARCHIVE_SUFFIX" = "gz" ]; then
42
      tar zxvf $1
43
    elif [ "$ARCHIVE_SUFFIX" = "bz2" ]; then
44
      tar jxvf $1
45
    else
46
      echo "Unknown archive format for $1"
47
      exit 1
48
    fi
49
)
50
}
51

    
52
# Create all the directories we need.
53
#mkdir -p $SRCDIR $BUILDDIR $PREFIX
54

    
55
(
56
cd $SRCDIR
57

    
58
# Unpack the sources.
59
unpack_source $(basename $GCC_SRC)
60
unpack_source $(basename $BINUTILS_SRC)
61
unpack_source $(basename $NEWLIB_SRC)
62
#unpack_source $(basename $INSIGHT_SRC)
63
)
64

    
65
# Set the PATH to include the binaries we're going to build.
66
OLD_PATH=$PATH
67
export PATH=$PREFIX/bin:$PATH
68

    
69
#
70
# Stage 1: Build binutils
71
#
72
(
73
(
74
# autoconf check.
75
cd $SRCDIR/$BINUTILS_DIR
76

    
77
) || exit 1
78

    
79
# Now, build it.
80
mkdir -p $BUILDDIR/$BINUTILS_DIR
81
cd $BUILDDIR/$BINUTILS_DIR
82

    
83
$SRCDIR/$BINUTILS_DIR/configure --target=arm-elf --prefix=$PREFIX \
84
    --enable-interwork --enable-threads=posix --enable-multilib --with-float=soft --disable-werror \
85
    && make all install
86

    
87
) || exit 1
88

    
89
#
90
# Stage 2: Patch the GCC multilib rules, then build the gcc compiler only
91
#
92
(
93
MULTILIB_CONFIG=$SRCDIR/$GCC_DIR/gcc/config/arm/t-arm-elf
94

    
95
echo "
96

    
97
MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
98
MULTILIB_DIRNAMES += normal interwork
99

    
100
" >> $MULTILIB_CONFIG
101

    
102
mkdir -p $BUILDDIR/$GCC_DIR
103
cd $BUILDDIR/$GCC_DIR
104

    
105
$SRCDIR/$GCC_DIR/configure --target=arm-elf --prefix=$PREFIX \
106
    --enable-interwork --enable-multilib --with-float=soft --disable-werror \
107
    --enable-languages="c,c++" --with-newlib \
108
    --with-headers=$SRCDIR/$NEWLIB_DIR/newlib/libc/include \
109
    --with-system-zlib --disable-shared \
110
    && make all-gcc install-gcc
111

    
112
) || exit 1
113

    
114
#
115
# Stage 3: Build and install newlib
116
#
117
(
118
(
119
# Same issue, we have to patch to support makeinfo >= 4.11.
120
cd $SRCDIR/$NEWLIB_DIR
121

    
122
) || exit 1
123

    
124
# And now we can build it.
125
mkdir -p $BUILDDIR/$NEWLIB_DIR
126
cd $BUILDDIR/$NEWLIB_DIR
127

    
128
$SRCDIR/$NEWLIB_DIR/configure --target=arm-elf --prefix=$PREFIX \
129
    --enable-interwork --enable-multilib --with-float=soft --disable-werror \
130
    && make all install
131

    
132
) || exit 1
133

    
134
#
135
# Stage 4: Build and install the rest of GCC.
136
#
137
(
138
cd $BUILDDIR/$GCC_DIR
139

    
140
make all install
141

    
142
) || exit 1
143

    
144
#
145
# Stage 5: Build and install INSIGHT.
146
#
147
# edit: we currently don't need that for OsmocomBB
148

    
149
#(
150
# Now, build it.
151
#mkdir -p $BUILDDIR/$INSIGHT_DIR
152

    
153
#cd $BUILDDIR/$INSIGHT_DIR
154

    
155
#$SRCDIR/$INSIGHT_DIR/configure --target=arm-elf --prefix=$PREFIX \
156
#    --enable-interwork --enable-multilib --with-float=soft --disable-werror \
157
#    && make all install
158

    
159
#) || exit 1
160

    
161

    
162
export PATH=$OLD_PATH
163

    
164
echo "
165
Build complete! Add $PREFIX/bin to your PATH to make arm-elf-gcc and friends
166
accessible directly.
167
"
Add picture from clipboard (Maximum size: 48.8 MB)