This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.sh
executable file
·170 lines (129 loc) · 3.35 KB
/
build.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
#!/bin/sh
ROOT=`pwd`
SRCDIR=$ROOT/src
BUILDDIR=$ROOT/build
PREFIX=$ROOT/install
GCC_SRC=gcc-4.5.2.tar.bz2
GCC_VERSION=4.5.2
GCC_DIR=gcc-$GCC_VERSION
BINUTILS_SRC=binutils-2.21.1a.tar.bz2
BINUTILS_VERSION=2.21.1
BINUTILS_DIR=binutils-$BINUTILS_VERSION
NEWLIB_SRC=newlib-1.19.0.tar.gz
NEWLIB_VERSION=1.19.0
NEWLIB_DIR=newlib-$NEWLIB_VERSION
#INSIGHT_SRC=insight-6.8-1.tar.bz2
#INSIGHT_VERSION=6.8-1
#INSIGHT_DIR=insight-$INSIGHT_VERSION
echo "I will build an arm-elf cross-compiler:
Prefix: $PREFIX
Sources: $SRCDIR
Build files: $BUILDDIR
Press ^C now if you do NOT want to do this."
read IGNORE
#
# Helper functions.
#
unpack_source()
{
(
cd $SRCDIR
ARCHIVE_SUFFIX=${1##*.}
if [ "$ARCHIVE_SUFFIX" = "gz" ]; then
tar zxvf $1
elif [ "$ARCHIVE_SUFFIX" = "bz2" ]; then
tar jxvf $1
else
echo "Unknown archive format for $1"
exit 1
fi
)
}
# Create all the directories we need.
#mkdir -p $SRCDIR $BUILDDIR $PREFIX
(
cd $SRCDIR
# Unpack the sources.
unpack_source $(basename $GCC_SRC)
unpack_source $(basename $BINUTILS_SRC)
unpack_source $(basename $NEWLIB_SRC)
#unpack_source $(basename $INSIGHT_SRC)
# Patch for texinfo5. Adapted from Marcello Pogliani
patch -p1 < ../gcc-texinfo5.patch
patch -p1 < ../fix-gcc5-build.patch
)
# Set the PATH to include the binaries we're going to build.
OLD_PATH=$PATH
export PATH=$PREFIX/bin:$PATH
#
# Stage 1: Build binutils
#
(
(
# autoconf check.
cd $SRCDIR/$BINUTILS_DIR
) || exit 1
# Now, build it.
mkdir -p $BUILDDIR/$BINUTILS_DIR
cd $BUILDDIR/$BINUTILS_DIR
$SRCDIR/$BINUTILS_DIR/configure --target=arm-elf --prefix=$PREFIX \
--enable-interwork --enable-threads=posix --enable-multilib --with-float=soft --disable-werror \
&& make all install
) || exit 1
#
# Stage 2: Patch the GCC multilib rules, then build the gcc compiler only
#
(
MULTILIB_CONFIG=$SRCDIR/$GCC_DIR/gcc/config/arm/t-arm-elf
echo "
MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
MULTILIB_DIRNAMES += normal interwork
" >> $MULTILIB_CONFIG
mkdir -p $BUILDDIR/$GCC_DIR
cd $BUILDDIR/$GCC_DIR
$SRCDIR/$GCC_DIR/configure --target=arm-elf --prefix=$PREFIX \
--enable-interwork --enable-multilib --with-float=soft --disable-werror \
--enable-languages="c,c++" --with-newlib \
--with-headers=$SRCDIR/$NEWLIB_DIR/newlib/libc/include \
--with-system-zlib --disable-shared \
&& make all-gcc install-gcc
) || exit 1
#
# Stage 3: Build and install newlib
#
(
(
# Same issue, we have to patch to support makeinfo >= 4.11.
cd $SRCDIR/$NEWLIB_DIR
) || exit 1
# And now we can build it.
mkdir -p $BUILDDIR/$NEWLIB_DIR
cd $BUILDDIR/$NEWLIB_DIR
$SRCDIR/$NEWLIB_DIR/configure --target=arm-elf --prefix=$PREFIX \
--enable-interwork --enable-multilib --with-float=soft --disable-werror \
&& make all install
) || exit 1
#
# Stage 4: Build and install the rest of GCC.
#
(
cd $BUILDDIR/$GCC_DIR
make all install
) || exit 1
#
# Stage 5: Build and install INSIGHT.
#
# edit: we currently don't need that for OsmocomBB
#(
# Now, build it.
#mkdir -p $BUILDDIR/$INSIGHT_DIR
#cd $BUILDDIR/$INSIGHT_DIR
#$SRCDIR/$INSIGHT_DIR/configure --target=arm-elf --prefix=$PREFIX \
# --enable-interwork --enable-multilib --with-float=soft --disable-werror \
# && make all install
#) || exit 1
export PATH=$OLD_PATH
echo "
Build complete! Add $PREFIX/bin to your PATH to make arm-elf-gcc and friends
accessible directly.
"