-
Notifications
You must be signed in to change notification settings - Fork 18
/
0-Preparation
138 lines (123 loc) · 4.19 KB
/
0-Preparation
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
# # Prequisites # #
# Required for host:
# o cmake
# o ninja/samurai
# o python3 (linked as 'python' if python2 not installed)
# o wget/curl (to download sources)
# Required Base Development tools (may refer to LFS)
# o bash 3.2 (/bin/sh should be a symbolic or hard link to bash)
# o binutils 2.25
# o bison 2.7 (/usr/bin/yacc should be a link to bison or small script that executes bison)
# o bzip2 1.0.4
# o coreutils 6.9
# o diffutils 2.8.1
# o findutils 4.2.31
# o gawk 4.0.1 (/usr/bin/awk should be a link to gawk)
# o GCC 6.2 *including the C++ compiler, g++
# o Glibc 2.11 / Musl Libc 1.20
# o Grep 2.5.1a
# o gzip 1.3.12
# o linux kernel 3.2 (not sure if it matters, as most distros are running 4.x/5.x kernels
# o m4 1.4.10
# o make 4.0
# o patch 2.5.4
# o Python 3.4
# o sed 4.1.5
# o tar 1.22
# o texinfo 4.7
# o xz 5.0.0
# * (if hostdistro is MLFS/LFS, then all development packages are installed)
# Create a directory to hold sources and stage area, as root:
mkdir -pv /mnt/cmlfs
export CMLFS=/mnt/cmlfs
# Create directories to build clang with GCC libraries (cgnutools)
# and the final toolchain without GCC libraries. As root, Link them
# to host's root directory:
mkdir -v $CMLFS/cgnutools
mkdir -v $CMLFS/llvmtools
ln -sv $CMLFS/cgnutools /
ln -sv $CMLFS/llvmtools /
# As root, create directories to hold patches, files, packages,
# and build area:
mkdir -pv $CMLFS/sources/{patches,files,pkgs}
# Download sources. Provided list can be used with wget:
#wget --input-file=sources.list --continue --directory-prefix=$CMLFS/sources/pkgs
# or use the download_sources.sh script if you have only cURL ;^]
./download_sources.sh sources.list sources.md5
# Create user and group:
# As root, change ownership to allow installation of tools
groupadd cmlfs
useradd -s /bin/bash -g cmlfs -m -k /dev/null cmlfs
passwd cmlfs
chown -v cmlfs $CMLFS/cgnutools
chown -v cmlfs $CMLFS/llvmtools
chown -vR cmlfs $CMLFS/sources
chmod -v a+wt $CMLFS/sources
# Now run as cmlfs user. All toolchain software should be built
# as this user, unless specified.
su - cmlfs
# Set up the environment.
cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\n\$ ' /bin/bash
EOF
cat > ~/.bashrc << "EOF"
set +h
umask 022
CMLFS=/mnt/cmlfs
LC_ALL=POSIX
PATH=/cgnutools/bin:/llvmtools/bin:/bin:/usr/bin
export CMLFS LC_ALL PATH
EOF
# Load the stored environment
source ~/.bash_profile
# CFLAGS and CXXFLAGS must not be set during the building of cross-tools.
unset CFLAGS
unset CXXFLAGS
cat >> ~/.bashrc << EOF
unset CFLAGS
unset CXXFLAGS
EOF
# Set the tuples
case $(uname -m) in
x86_64) export CMLFS_TARGET="x86_64-cmlfs-linux-musl"
export TARGET_TUPLE="x86_64-pc-linux-musl"
export CMLFS_ARCH="x86"
export CMLFS_CPU="x86-64"
export MCA="x86_64"
;;
i686) export CMLFS_TARGET="i686-cmlfs-linux-musl"
export TARGET_TUPLE="i686-pc-linux-musl"
export CMLFS_ARCH="x86"
export CMLFS_CPU="i686"
export MCA="i386"
;;
aarch64 ) export CMLFS_TARGET="aarch64-cmlfs-linux-musl"
export TARGET_TUPLE="aarch64-pc-linux-musl"
export CMLFS_ARCH="arm64"
export CMLFS_CPU="armv8-a"
export MCA="aarch64"
;;
arm7*) export CMLFS_TARGET="armv7l-cmlfs-linux-musleabihf"
export TARGET_TUPLE="armv7l-pc-linux-musleabihf"
export CMLFS_ARCH="arm"
export CMLFS_CPU="armv7-a"
export MCA="arm"
;;
arm6*) export CMLFS_TARGET="armv6l-cmlfs-linux-musleabihf"
export TARGET_TUPLE="armv6l-pc-linux-musleabihf"
export CMLFS_ARCH="arm"
export CMLFS_CPU="armv6zk"
export MCA="arm"
;;
esac
export CMLFS_HOST="$(echo $MACHTYPE | \
sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
cat >> ~/.bashrc << EOF
export CMLFS_HOST="${CMLFS_HOST}" \
CMLFS_TARGET="${CMLFS_TARGET}" \
CMLFS_ARCH="${CMLFS_ARCH}" \
CMLFS_CPU="${CMLFS_CPU}" \
TARGET_TUPLE="${TARGET_TUPLE}"
MCA="${MCA}"
EOF
source ~/.bashrc