-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathct_ngInstall.sh
More file actions
executable file
·179 lines (167 loc) · 4.76 KB
/
Copy pathct_ngInstall.sh
File metadata and controls
executable file
·179 lines (167 loc) · 4.76 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
179
#########################################################################
# File Name: go.sh
# Author: Hello
# mail: Hello@163.com
# Created Time: 2019年10月28日 星期一 22时26分28秒
#########################################################################
#!/bin/bash
IF_LOG_ALL=y
DIR_ROOT=/home/lvbing/tool
BRANCH=1.22
# if v1.22 modify ./crosstool-ng/kconfig/zconf.hash.c +167
SAMPLES=arm-unknown-linux-gnueabi
TARGET_VENDOR=none
NAME_TOOL_TARGET=test
NAME_TOOL_ALIAS=lv
# Os options
IF_KERNEL_linux=y
IF_LINUX_CUSTOM=y
DIR_LINUX_CUSTOM=/home/lvbing/tool/linux-stable
#SAMPLES=arm-unknown-eabi
# -------------------------------------------------
# crosstool 编译依赖:
# gperf 是完美哈希函数生成器;
# bison,flex 是用来生成语法和词法分析器;
# texinfo,man 类似,用来读取帮助文档
# automake 是帮助生成Makefile的工具;
# libtool 帮助在编译过程中处理库的依赖关系,自动搜索路径;
# gawk linux下用于文本处理和模式匹配的工具.
# sudo apt-get install gperf flex bison texinfo gawk libtool automake libncurses5-dev g++ help2man
install_package(){
sudo apt-get install help2man
}
# -------------------------------------------------
# download : crosstool-ng
# https://github.com/crosstool-ng/crosstool-ng.git
download_ct_ng(){
cd $DIR_ROOT
if [ -d crosstool-ng ] ;then
read -n 2 -p "You had src. So now checkout to $BRANCH ? [y/n] >> " rep
echo
if [ $rep == 'y' ] ;then
cd $DIR_PROJECT
git checkout -b crosstool.local.$BRANCH remotes/origin/$BRANCH
else
exit
fi
else
git clone https://github.com/crosstool-ng/crosstool-ng.git
fi
}
# -------------------------------------------------
compile_install(){
if [ -d $DIR_PREFIX ] ;then
rm -rf $DIR_PREFIX
else
mkdir -p $DIR_PREFIX
fi
cd $DIR_PROJECT
# run the bootstrap script before running configure:
./bootstrap
# config crosstool
./configure --prefix=$DIR_PREFIX
# compile
make
# install crosstool
make install
# please export enverment
echo "you must do next before use ct-ng:"
echo "export PATH=\$PATH:$DIR_PREFIX/bin"
}
# -------------------------------------------------
DIR_LINUX_CUSTOM=/home/lvbing/tool/linux-stable
menuconfig_ct_ng(){
cd $DIR_PROJECT
read -n 2 -p "if read config base '$SAMPLES', and cover current? [y/n] >> " rep
echo
if [ $rep == 'y' ] ;then
cp $DIR_PROJECT/samples/$SAMPLES/crosstool.config $DIR_PROJECT/.config
echo CT_TARGET=\"$NAME_TOOL_TARGET\" >> $DIR_PROJECT/.config
echo CT_TARGET_ALIAS=\"$NAME_TOOL_ALIAS\" >> $DIR_PROJECT/.config
echo CT_PREFIX_DIR=\"$DIR_TOOL_PREFIX\" >> $DIR_PROJECT/.config
echo CT_TARGET_VENDOR=\"$TARGET_VENDOR\" >> $DIR_PROJECT/.config
echo CT_LOCAL_TARBALLS_DIR=\"$DIR_TARBALLS\" >> $DIR_PROJECT/.config
if [ ! -n "$IF_LOG_ALL" ]; then
echo CT_LOG_ALL=$IF_LOG_ALL >> $DIR_PROJECT/.config
fi
# os set
#echo CT_KERNEL_linux=$IF_KERNEL_linux >> $DIR_PROJECT/.config
#echo CT_KERNEL_LINUX_CUSTOM=$IF_LINUX_CUSTOM >> $DIR_PROJECT/.config
#echo CT_KERNEL_LINUX_CUSTOM_LOCATION=\"$DIR_LINUX_CUSTOM\" >> $DIR_PROJECT/.config
echo -----------------------------------------
cat $DIR_PROJECT/.config
echo -----------------------------------------
fi
read -n 2 -p "if menuconfig ? [y/n] >> " rep
echo
if [ $rep == 'y' ] ;then
./ct-ng menuconfig
fi
}
# -------------------------------------------------
build_ct_ng(){
cd $DIR_ROOT
if [ -d $DIR_TOOL_PREFIX ] ;then
rm -rf $DIR_TOOL_PREFIX
fi
mkdir -p $DIR_TOOL_PREFIX
if [ ! -d $DIR_TARBALLS ] ;then
mkdir -p $DIR_TARBALLS
fi
cd $DIR_PROJECT
./ct-ng build
}
# -------------------------------------------------
if [ ! -n "$DIR_ROOT" ] ;then
DIR_ROOT=$(pwd)
fi
cd $DIR_ROOT
if [ -d crosstool-ng ] ;then
echo
else
read -n 2 -p "Not find src. So now download ct-ng? [y/n] >> " rep
echo
if [ $rep == 'y' ] ;then
download_ct_ng
else
exit
fi
fi
DIR_PREFIX=$DIR_ROOT/ct_prefix
DIR_PROJECT=$DIR_ROOT/crosstool-ng
DIR_TARBALLS=$DIR_ROOT/tarballs
DIR_TOOL_PREFIX=$DIR_ROOT/tool_prefix
echo ------------------------------------------------
echo "project dir= $DIR_PROJECT"
echo "prefix dir= $DIR_PREFIX"
echo "samples = $SAMPLES"
echo "branch = $BRANCH"
echo ------------------------------------------------
echo 1, install Depend on the package of ct-ng.
echo 2, download ct-ng and change the branches.
echo 3, compile and install ct-ng.
echo 4, ct-ng menuconfig, config gcc tool.
echo 5, ct-ng build, creat gcc tool.
echo ------------------------------------------------
echo -n "Enter you cmd:"
read cmd
case $cmd in
1) echo “you select [$cmd]”
install_package
;;
2) echo “you select [$cmd]”
download_ct_ng
;;
3) echo “you select [$cmd]”
compile_install
;;
4) echo “you select [$cmd]”
menuconfig_ct_ng
;;
5) echo “you select [$cmd]”
build_ct_ng
;;
*) echo “you select error!”
exit
;;
esac