This repository has been archived by the owner on Feb 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·68 lines (57 loc) · 2.13 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
#!/bin/bash
# build.sh
# Reference: http://inaz2.hatenablog.com/entry/2015/12/01/204201
set -e
PREFIX=/usr/local
PARALLEL_MAKE=-j8
CONFIGURATION_OPTIONS="--disable-multilib --disable-nls"
build() {
local TARGET="$1"
local LINUX_ARCH="$2"
# Step 1. Binutils
mkdir -p build-binutils-$TARGET
cd build-binutils-$TARGET
../$BINUTILS_VERSION/configure --prefix=$PREFIX --target=$TARGET $CONFIGURATION_OPTIONS
make $PARALLEL_MAKE
make install
cd ..
# Step 2. Linux Kernel Headers
cd $LINUX_KERNEL_VERSION
make ARCH=$LINUX_ARCH INSTALL_HDR_PATH=$PREFIX/$TARGET headers_install
cd ..
# Step 3. C/C++ Compilers
mkdir -p build-gcc-$TARGET
cd build-gcc-$TARGET
../$GCC_VERSION/configure --prefix=$PREFIX --target=$TARGET --enable-languages=c,c++ $CONFIGURATION_OPTIONS \
-disable-decimal-float --disable-threads --disable-libmudflap --disable-libssp --disable-libgomp
make $PARALLEL_MAKE gcc_cv_libc_provides_ssp=yes all-gcc
make install-gcc
cd ..
# Step 4. Standard C Library Headers and Startup Files
mkdir -p build-glibc-$TARGET
cd build-glibc-$TARGET
../$GLIBC_VERSION/configure --prefix=$PREFIX/$TARGET --build=$MACHTYPE --host=$TARGET --target=$TARGET --with-headers=$PREFIX/$TARGET/include $CONFIGURATION_OPTIONS libc_cv_forced_unwind=yes
make install-bootstrap-headers=yes install-headers
make $PARALLEL_MAKE csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $PREFIX/$TARGET/lib
$TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $PREFIX/$TARGET/lib/libc.so
touch $PREFIX/$TARGET/include/gnu/stubs.h
cd ..
# Step 5. Compiler Support Library
cd build-gcc-$TARGET
make $PARALLEL_MAKE all-target-libgcc
make install-target-libgcc
cd ..
# Step 6. Standard C Library & the rest of Glibc
cd build-glibc-$TARGET
make $PARALLEL_MAKE
make install
cd ..
# Step 7. Standard C++ Library & the rest of GCC
cd build-gcc-$TARGET
make $PARALLEL_MAKE all
make install
cd ..
rm -rf build-binutils-$TARGET build-gcc-$TARGET build-glibc-$TARGET
}
build $1 $2