forked from landley/aboriginal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
native-compiler.sh
executable file
·74 lines (55 loc) · 1.9 KB
/
native-compiler.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
#!/bin/bash
# Build a compiler for a given target, using one or more existing simple
# cross compilers.
# This can be used to build a native compiler for an aribitrary target, or to
# build a more portable and capable cross compiler for an arbitrary host.
# The new compiler is built --with-shared, with thread support, has uClibc++
# installed, and is linked against musl (see BUILD_STATIC in config).
source sources/include.sh && load_target "$1" || exit 1
check_for_base_arch || exit 0
check_prerequisite "${CC_PREFIX}cc"
[ -z "$HOST_ARCH" ] && HOST_ARCH="$ARCH" && STAGE_DIR="$STAGE_DIR/usr" ||
check_prerequisite "${HOST_ARCH}-cc"
mkdir -p "$STAGE_DIR/bin" || dienow
# Build C Library
if [ ! -z "$KARCH" ]
then
build_section linux-headers
if [ -z "$UCLIBC_CONFIG" ] || [ ! -z "$MUSL" ]
then
build_section musl
else
build_section uClibc
fi
fi
# Build binutils, gcc, and ccwrap
build_section binutils
[ ! -z "$ELF2FLT" ] && build_section elf2flt
build_section gcc
build_section ccwrap
# Tell future packages to link against the libraries in the new compiler,
# rather than the ones in the simple compiler.
export "$(echo $ARCH | sed 's/-/_/g')"_CCWRAP_TOPDIR="$STAGE_DIR"
if [ ! -z "$KARCH" ]
then
# Add C++ standard library
[ -z "$NO_CPLUSPLUS" ] && build_section uClibc++
# For a native compiler, build make, bash, and distcc. (Yes, this is an old
# version of Bash. It's intentional.)
if [ -z "$TOOLCHAIN_PREFIX" ]
then
build_section make
build_section bash
build_section distcc
cp "$SOURCES/toys/hdainit.sh" "$STAGE_DIR/../init" &&
mv "$STAGE_DIR"/{man,share/man} || dienow
fi
fi
# Delete some unneeded files and strip everything else
rm -rf "$STAGE_DIR"/{info,libexec/gcc/*/*/install-tools} || dienow
if [ -z "$SKIP_STRIP" ]
then
"${ARCH}-strip" --strip-unneeded "$STAGE_DIR"/lib/*.so
"${ARCH}-strip" "$STAGE_DIR"/{bin/*,sbin/*}
fi
create_stage_tarball