This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.2nd.sh
executable file
·200 lines (174 loc) · 4.82 KB
/
build.2nd.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
# build tmp system
cd $BUILDTMP
# install kernel headers
tar xvf $SRCROOT/$KERNEL_TAR
cd $KERNEL_SRC
make mrproper
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* $CROSS/include
cd ..
rm -rf $KERNEL_SRC
# install glibc
tar xvf $SRCROOT/$GLIBC_TAR
cd $GLIBC_SRC
mkdir -v build
cd build
../configure \
--prefix=$CROSS \
--host=$LFS_TGT \
--build=$(../scripts/config.guess) \
--disable-profile \
--enable-kernel=4.13 \
--with-headers=$CROSS/include \
libc_cv_forced_unwind=yes \
libc_cv_c_cleanup=yes
$MAKE $MFLAGS
$MAKE $MFLAGS install
echo 'int main(){}' > dummy.c
$LFS_TGT-gcc dummy.c
readelf -l a.out | grep "$CROSS"
ldd a.out
file a.out
rm -v dummy.c a.out
cd ../../
rm -rf $GLIBC_SRC
# build Libstdc++
cd $BUILDTMP
tar xvf $SRCROOT/$GCC_TAR
cd $GCC_SRC
case "$UNAMEM" in
i386|i486|i586|i686|amd64|x86_64)
tar -xf $SRCROOT/$MPFR_TAR
mv -v $MPFR_SRC mpfr
tar -xf $SRCROOT/$GMP_TAR
mv -v $GMP_SRC gmp
tar -xf $SRCROOT/$MPC_TAR
mv -v $MPC_SRC mpc
;;
armv7l|armhf|armv8l|aarch64)
./contrib/download_prerequisites
;;
esac
for file in \
$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h -o -name aarch64-linux.h -o -name linux-eabi.h)
do
cp -uv $file{,.orig}
sed -e "s@/lib\(64\)\?\(32\)\?/ld@$CROSS&@g" \
-e "s@/usr@$CROSS@g" $file.orig > $file
echo "
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 \"$CROSS/lib/\"
#define STANDARD_STARTFILE_PREFIX_2 \"\"" >> $file
touch $file.orig
done
case $(uname -m) in
x86_64)
sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64
;;
aarch64)
sed -e '/mabi.lp64=/s/lib64/lib/' \
-i.orig gcc/config/aarch64/t-aarch64-linux
;;
esac
mkdir -v build
cd build
../libstdc++-v3/configure \
--host=$LFS_TGT \
--prefix=$CROSS \
--disable-multilib \
--disable-nls \
--disable-libstdcxx-threads \
--disable-libstdcxx-pch \
--with-gxx-include-dir=$CROSS/$LFS_TGT/include/c++/7.3.0
$MAKE $MFLAGS
$MAKE $MFLAGS install
cd ../../
rm -rf $GCC_SRC
# build binutils-2
cd $BUILDTMP
tar xvf $SRCROOT/$BINUTILS_TAR
cd $BINUTILS_SRC
mkdir -v build
cd build
CC=$LFS_TGT-gcc \
AR=$LFS_TGT-ar \
RANLIB=$LFS_TGT-ranlib \
../configure --prefix=$CROSS \
--with-sysroot \
--with-lib-path=$CROSS/lib \
--disable-nls \
--disable-werror
$MAKE $MFLAGS
$MAKE $MFLAGS install
make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new $CROSS/bin
cd ../../
rm -rf $BINUTILS_SRC
# build gcc-2
cd $BUILDTMP
tar xvf $SRCROOT/$GCC_TAR
cd $GCC_SRC
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h
case "$UNAMEM" in
i386|i486|i586|i686|amd64|x86_64)
tar -xf $SRCROOT/$MPFR_TAR
mv -v $MPFR_SRC mpfr
tar -xf $SRCROOT/$GMP_TAR
mv -v $GMP_SRC gmp
tar -xf $SRCROOT/$MPC_TAR
mv -v $MPC_SRC mpc
;;
armv7l|armhf|armv8l|aarch64)
./contrib/download_prerequisites
;;
esac
for file in \
$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h -o -name aarch64-linux.h -o -name linux-eabi.h)
do
cp -uv $file{,.orig}
sed -e "s@/lib\(64\)\?\(32\)\?/ld@$CROSS&@g" \
-e "s@/usr@$CROSS@g" $file.orig > $file
echo "
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 \"$CROSS/lib/\"
#define STANDARD_STARTFILE_PREFIX_2 \"\"" >> $file
touch $file.orig
done
case $(uname -m) in
x86_64|aarch64)
sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64
;;
esac
mkdir -v build
cd build
CC=$LFS_TGT-gcc \
CXX=$LFS_TGT-g++ \
AR=$LFS_TGT-ar \
RANLIB=$LFS_TGT-ranlib \
../configure \
--prefix=$CROSS \
--with-local-prefix=$CROSS \
--with-native-system-header-dir=$CROSS/include \
--disable-multilib \
--disable-libgomp \
--disable-bootstrap \
--disable-libstdcxx-pch \
--enable-languages=c,c++ $GFLAGS
$MAKE $MFLAGS
$MAKE $MFLAGS install
ln -sv gcc $CROSS/bin/cc
ls gcc -al|grep gcc
echo 'int main(){}' > dummy.c
cc dummy.c
readelf -l a.out | grep "$CROSS"
ldd a.out
file a.out
rm -v dummy.c a.out
cd ../../
rm -rf $GCC_SRC