-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall3CrossToolchain.sh
More file actions
178 lines (159 loc) · 4.55 KB
/
Install3CrossToolchain.sh
File metadata and controls
178 lines (159 loc) · 4.55 KB
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
#! /bin/zsh
source Utils.sh
source UtilInstallPackages.sh
# =====================================||===================================== #
# #
# Functions #
# #
# ===============ft_linux==============||==============©Othello=============== #
Install5CrossToolchain()
{
InstallBinutils_CT1;
InstallGCC_CT1;
InstallLinuxAPI_CT;
InstallGlibc_CT;
if SanityCheckGlibc; then
InstallLibstdCPP_CT;
fi
}
ValidateCrossToolchain()
{
# Binutils
if command -v $LFS_TGT-as &> /dev/null && command -v $LFS_TGT-ld &> /dev/null; then
printf "%-11s ${C_GREEN}OK${C_RESET}\n" "Binutils:"
else
printf "%-11s ${C_RED}KO${C_RESET}\n" "Binutils:"
fi
# GCC
if command -v $LFS_TGT-gcc &> /dev/null; then
printf "%-11s ${C_GREEN}OK${C_RESET}\n" "GCC:"
else
printf "%-11s ${C_RED}KO${C_RESET}\n" "GCC:"
fi
# LinuxAPI
TempStatus=true;
local INCLUDE_DIR="$LFS/usr/include";
if [ ! -d "$INCLUDE_DIR" ]; then
TempStatus=false;
fi
declare -A HeaderDirectoryList;
HeaderDirectoryList[asm]=65;
HeaderDirectoryList[asm-generic]=37;
HeaderDirectoryList[drm]=28;
HeaderDirectoryList[linux]=781;
HeaderDirectoryList[misc]=7;
HeaderDirectoryList[mtd]=5;
HeaderDirectoryList[rdma]=29;
HeaderDirectoryList[regulator]=1;
HeaderDirectoryList[scsi]=10;
HeaderDirectoryList[sound]=23;
HeaderDirectoryList[video]=3;
HeaderDirectoryList[xen]=4;
for DIRECTORY in ${(k)HeaderDirectoryList}; do
if [ ! -d "$INCLUDE_DIR/$DIRECTORY" ]; then
MSG="${C_RED}Error${C_RESET}(${C_ORANGE}Linux API Header${C_RESET}): Missing directory ${C_ORANGE}$INCLUDE_DIR/$DIRECTORY${C_RESET}"
TempStatus=false;
elif [ ${HeaderDirectoryList[$DIRECTORY]} -gt $(find $INCLUDE_DIR/$DIRECTORY -type f -name '*.h' | wc -l) ]; then
MSG="${C_RED}Error${C_RESET}(${C_ORANGE}Linux API Header${C_RESET}): Missing headers in directory ${C_ORANGE}$INCLUDE_DIR/$DIRECTORY${C_RESET}"
TempStatus=false;
fi
done
if [ "${TempStatus}" = "true" ]; then
printf "%-11s ${C_GREEN}OK${C_RESET}\n" "Linux API:";
else
printf "%-11s ${C_RED}KO${C_RESET}\n" "Linux API:";
fi
# Glibc
echo 'int main(){}' | $LFS_TGT-gcc -xc - -o gcctest.out
if [ -f "gcctest.out" ]; then
readelf -l gcctest.out | grep ld-linux 1> /dev/null
if [ $? -eq 0 ]; then
printf "%-11s ${C_GREEN}OK${C_RESET}\n" "Glibc:"
else
printf "%-11s ${C_RED}KO${C_RESET}\n" "Glibc:"
fi
rm gcctest.out
else
printf "%-11s ${C_RED}KO${C_RESET}\n" "Glibc:"
fi
# LibstdC++
if command -v $LFS_TGT-g++ &> /dev/null; then
printf "%-11s ${C_GREEN}OK${C_RESET}\n" "LibstdC++:"
else
printf "%-11s ${C_RED}KO${C_RESET}\n" "LibstdC++:"
fi
printf '%*s\n' "$Width" '' | tr ' ' '-';
}
Install6CrossTemporaryTools()
{
InstallM4_TT;
InstallNcurses_TT;
InstallBash_TT;
InstallCoreutils_TT;
InstallDiffutils_TT;
InstallFile_TT;
InstallFindutils_TT;
InstallGawk_TT;
InstallGrep_TT;
InstallGzip_TT;
InstallMake_TT;
InstallPatch_TT;
InstallSed_TT;
InstallTar_TT;
InstallXz_TT;
InstallBinutils_TT2;
InstallGCC_TT2;
}
ValidateTemporaryTools()
{
printf "WIP\n";
printf '%*s\n' "$Width" '' | tr ' ' '-';
}
# =====================================||===================================== #
# #
# Execution #
# #
# ===============ft_linux==============||==============©Othello=============== #
if [ $# -gt 0 ]; then
case "$1" in
RunAll) Install5CrossToolchain;
Install6CrossTemporaryTools;;
# PrepareChrootForTemporaryTools;;
*) echo "Bad flag: '$1'";;
esac
exit;
fi
while true; do
Width=$(tput cols);
clear;
printf '%*s\n' "$Width" '' | tr ' ' '-';
echo "${C_ORANGE}${C_BOLD}5. Compiling a Cross-Toolchain${C_RESET}";
echo "Option:\t${-}";
printf '%*s\n' "$Width" '' | tr ' ' '-';
echo "0)\t Compile Cross-Toolchain and Temporary Tools";
echo "5)\t Compile Cross-Toolchain packages";
echo "6)\t Cross-Compile Temporary Tool packages";
# echo "7)\t Prepare Chroot";
printf '%*s\n' "$Width" '' | tr ' ' '-';
echo "c)\t Display Cross Toolchain";
echo "t)\t Display Temporary Tools";
echo "r)\t Remove Directories";
echo "q)\t Return to main menu";
printf '%*s\n' "$Width" '' | tr ' ' '-';
$LocalCommand;
unset LocalCommand;
echo -n "Input> ";
GetKeyPress;
case $input in
0) Install5CrossToolchain;
Install6CrossTemporaryTools;
PrepareChrootForTemporaryTools;;
5) Install5CrossToolchain;;
6) Install6CrossTemporaryTools;;
# 7) PrepareChrootForTemporaryTools;;
c) local LocalCommand="ValidateCrossToolchain";;
t) local LocalCommand="ValidateTemporaryTools";;
r) RemovePackageDirectories;;
q) exit;;
esac
done