-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·305 lines (272 loc) · 7.88 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/bin/sh
# $RIKEN_copyright: 2018 Riken Center for Computational Sceience,
# System Software Devlopment Team. All rights researved$
#
# This file is part of GDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
opt_with_rpm_default="--without-rpm"
opt_with_expat_default="--without-expat"
echo $0 $@ > .build.cmd
self=`basename $0`
rm -f ${build_log}
usage()
{
echo >&2 "Usage: $self [-b|-i] [-j<N>] --prefix=<INSTALL_DIR> --with-pip=<PIP_DIR>"
echo >&2 " [default] : build and install"
echo >&2 " -b : build only, do not install"
echo >&2 " -i : install only, do not build"
echo >&2 " -j<N> : make parallelism"
exit 2
}
prefixdir=
pipdir=
program_prefix=
do_build=true
do_install=true
do_clean=true
with_pip=
do_check=false
packages=
build_parallelism=
while [ x"$1" != x ]; do
arg=$1
case $arg in
-b) do_install=false; do_clean=false;;
-k) do_install=false;;
-i) do_build=false;;
-j*) build_parallelism=`expr "$1" : "-j\([0-9]*\)"`;;
--prefix=*)
installdir=`expr "${arg}" : "--prefix=\(.*\)"`;;
--with-pip=*)
with_pip=$arg
program_prefix=--program-prefix=pip-
;;
--missing) do_check=true;;
--package=*) packages="${packages} `expr "${arg}" : "--package=\(.*\)"`";;
*) usage;;
esac
shift
done
if ! ${do_check}; then
if [ x"${installdir}" == x -o x"${with_pip}" == x ]; then
usage;
fi
pipdir=`expr "${with_pip}" : "--with-pip=\(.*\)"`;
if ! [ -x ${pipdir}/lib/libpip.so ]; then
echo >&2 "$self: ${pipdir} seems not to be PiP directory"
fi
ldlinux=`${pipdir}/lib/libpip.so --ldlinux`
case ${ldlinux} in
/lib/ld-*|/lib64/ld-*|/usr/lib/ld-*|/usr/lib64/ld-*)
echo >&2 -n "$self: Looks like the specified PiP lib (${pipdir}) is not configured ";
echo >&2 "to use the patched PiP-glibc and PiP-gdb cannot work without PiP-glibc";
exit 1;;
*) :;;
esac
else
if [ x"${packages}" != x ]; then
echo >&2 "$self: '--missing' and '--packages' cannot be specified at once"
exit 1
fi
fi
curdir=`dirname $0`
cppflags=
cflags=
build_flags () {
installdir=$1
if [ -d ${installdir}/bin ]; then
export PATH=${installdir}/bin:${PATH}
fi
if [ -d ${installdir}/include ]; then
if [ x"${cppflags}" == x ]; then
cppflags="-I${installdir}/include"
else
cppflags="${cppflags},-I${installdir}/include"
fi
fi
if [ -d ${installdir}/lib ]; then
ccflags="-L${installdir}/lib ${ccflags}"
if [ x"${ldflags}" == x ]; then
ldflags="-rpath=${installdir}/lib"
else
ldflags="${ldflags},-rpath=${installdir}/lib"
fi
fi
}
pkgfail=false;
echo >&2 "$self: Checking required packages ... "
centos_version=`cut -d ' ' -f 4 /etc/redhat-release`;
case $centos_version in
7.*) pkgs_needed="gd-devel libpng-devel zlib-devel libselinux-devel audit-libs-devel libcap-devel nss-devel systemtap-sdt-devel libstdc++-static glibc-static ncurses-devel xz-devel rpm-devel expat-devel python-devel texinfo-tex texlive-ec texlive-cm-super dejagnu perl readline-devel";;
8.*) pkgs_needed="gd-devel libpng-devel zlib-devel libselinux-devel audit-libs-devel libcap-devel nss-devel systemtap-sdt-devel ncurses-devel xz-devel rpm-devel expat-devel python3-debug info texlive perl flex readline-devel";;
esac
if ! sudo true; then
echo >&2 "$self: sudo is diabled and unable to install missed packages"
for pkgn in $pkgs_needed; do
if ! yum list installed $pkgn >/dev/null 2>&1; then
pkgfail=true;
echo >&2 "$self: '$pkgn' package is not installed"
fi
done
else
for pkgn in $pkgs_needed; do
echo >&2 "$self: yum install $pkgn"
if ! sudo yum install -y $pkgn >/dev/null 2>&1; then
pkgfail=true;
echo >&2 "$self: 'yum install $pkgn' failed"
fi
done
fi
echo >&2 -n "Checking texinfo ... "
instdir=/usr
flag_installed=false
for pkg in $packages; do
name=`expr "${pkg}" : "\([^:]*\)"`
if [ $name == "texinfo" ]; then
instdir=`expr "${pkg}" : "[^:]*:\(.*\)"`
flag_installed=true
break;
fi
done
if ! [ -x ${instdir}/bin/makeinfo ]; then
pkgfail=true
if ! $do_check; then
echo >&2 "$self: 'makeinfo' seems not to be installed"
else
echo "texinfo https://ftp.gnu.org/gnu/texinfo/texinfo-6.8.tar.gz"
fi
else
echo >&2 "OK"
if $flag_installed; then
build_flags $instdir
fi
fi
echo >&2 -n "Checking readline ... "
instdir=/usr
flag_installed=false
for pkg in $packages; do
name=`expr "${pkg}" : "\([^:]*\)"`
if [ $name == "readline" ]; then
instdir=`expr "${pkg}" : "[^:]*:\(.*\)"`
flag_installed=true
break;
fi
done
if ! [ -f ${instdir}/include/readline/readline.h ]; then
pkgfail=true
if ! $do_check; then
echo >&2 "$self 'readline' seems not to be installed"
else
echo "readline https://ftp.gnu.org/gnu/readline/readline-8.1.tar.gz"
fi
else
echo >&2 "OK"
if $flag_installed; then
build_flags $instdir
fi
fi
if $do_check; then
exit 0
elif $pkgfail ; then
echo >&2 "$self:WARNING: Some packages are missing and installation might be failed"
else
echo >&2 "$self: All required packages found"
fi
case `uname -m` in
aarch64)
opt_werror=--disable-werror
opt_with_rpm=${opt_with_rpm_default} #--with-rpm=librpm.so.3
opt_inprocess_agent=-disable-inprocess-agent
opt_host_arch=
host=aarch64-redhat-linux-gnu
;;
x86_64)
opt_werror=--enable-werror
opt_with_rpm=${opt_with_rpm_default} #--with-rpm
opt_inprocess_agent=-enable-inprocess-agent
opt_host_arch='-m64 -mtune=generic'
host=x86_64-redhat-linux-gnu
;;
esac
: ${BUILD_PARALLELISM=`getconf _NPROCESSORS_ONLN`}
: ${EXTRA_CONFIGURE_OPTIONS="${opt_werror} ${opt_with_rpm} ${opt_inprocess_agent} --enable-targets=s390-linux-gnu,powerpc-linux-gnu,powerpcle-linux-gnu"}
: ${EXTRA_GCC_OPTIONS="-fstack-protector-strong -grecord-gcc-switches"}
if [ x"${build_parallelism}" != x ]; then
BUILD_PARALLELISM=${build_parallelism}
fi
if [ x"${cppflags}" != x ]; then
cppflags="-Wp,${cppflags}"
fi
if [ x"${ldflags}" != x ]; then
ldflags="-Wl,${ldflags}"
fi
set -x
if $do_build; then
if $do_clean; then
make clean || true
make distclean || true
find . -name config.cache -delete
fi
./configure \
--enable-gdb-build-warnings=,-Wno-unused \
--with-separate-debug-dir=/usr/lib/debug \
--disable-sim \
--disable-rpath \
--with-system-readline \
${opt_with_expat_default} \
--without-libexpat-prefix \
--enable-tui \
--without-python \
--with-lzma \
--without-libunwind \
--enable-64-bit-bfd \
--with-auto-load-dir='$debugdir:$datadir/auto-load' \
--with-auto-load-safe-path='$debugdir:$datadir/auto-load:/usr/bin/mono-gdb.py' \
${EXTRA_CONFIGURE_OPTIONS} \
--prefix=${installdir} ${program_prefix} \
--datarootdir=${installdir}/share.pip-gdb \
${with_pip} \
${host} \
&&
make -j${BUILD_PARALLELISM} \
"CFLAGS=-O2 -g -pipe -Wall \
${cppflags} ${ccflags} ${ldflags} \
-fexceptions \
--param=ssp-buffer-size=4 \
${opt_host_arch} \
${EXTRA_GCC_OPTIONS}" \
"LDFLAGS=-Wl,-z,relro" \
maybe-configure-gdb \
&&
perl -i.relocatable -pe 's/^(D\[".*_RELOCATABLE"\]=" )1(")$/${1}0$2/' \
gdb/config.status \
&&
make -j${BUILD_PARALLELISM} \
"CFLAGS=-O2 -g -pipe -Wall \
${cppflags} ${ccflags} ${ldflags} \
-Wp,-D_FORTIFY_SOURCE=2 \
-fexceptions \
--param=ssp-buffer-size=4 \
${opt_host_arch} \
${EXTRA_GCC_OPTIONS}" \
"LDFLAGS=-Wl,-z,relro"
else
true
fi
if $do_install; then
make install
else
true
fi