Skip to content

Commit e7942d2

Browse files
committed
build: added libexpat build support
This allows commands such as "info os files" previously we had expat support on x86_64 only.
1 parent f7e97ca commit e7942d2

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
path = src/submodule_packages/binutils-gdb
77
url = [email protected]:guyush1/binutils-gdb.git
88
branch = gdb-static
9+
[submodule "src/submodule_packages/libexpat"]
10+
path = src/submodule_packages/libexpat
11+
url = [email protected]:guyush1/libexpat.git

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RUN apt update && apt install -y \
1919
gcc-powerpc-linux-gnu \
2020
git \
2121
libncurses-dev \
22+
libtool \
2223
m4 \
2324
make \
2425
patch \

src/compilation/build.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ function set_ncurses_link_variables() {
6868
export LDFLAGS="-L$ncursesw_build_dir/lib $LDFLAGS"
6969
}
7070

71+
function set_libexpat_link_variables() {
72+
# Set up libexpat library link variables
73+
#
74+
# Parameters:
75+
# $1: libexpat build dir
76+
local libexpat_build_dir="$1"
77+
78+
# Allow tui mode by adding our custom built static libexpat library to the linker search path.
79+
export LDFLAGS="-L$libexpat_build_dir/lib/.libs $LDFLAGS"
80+
}
81+
7182
function build_iconv() {
7283
# Build libiconv.
7384
#
@@ -214,6 +225,56 @@ function build_ncurses() {
214225
popd > /dev/null
215226
}
216227

228+
function build_libexpat() {
229+
# Build libexpat.
230+
#
231+
# Parameters:
232+
# $1: libexpat package directory
233+
# $2: target architecture
234+
#
235+
# Echoes:
236+
# The libexpat build directory
237+
#
238+
# Returns:
239+
# 0: success
240+
# 1: failure
241+
local libexpat_dir="$1"
242+
local target_arch="$2"
243+
local libexpat_build_dir="$(realpath "$libexpat_dir/build-$target_arch")"
244+
245+
echo "$libexpat_build_dir"
246+
mkdir -p "$libexpat_build_dir"
247+
248+
if [[ -f "$libexpat_build_dir/lib/.libs/libexpat.a" ]]; then
249+
>&2 echo "Skipping build: libexpat already built for $target_arch"
250+
return 0
251+
fi
252+
253+
pushd "$libexpat_build_dir" > /dev/null
254+
255+
>&2 fancy_title "Building libexpat for $target_arch"
256+
257+
# Generate configure if it doesnt exist.
258+
if [[ ! -f "$libexpat_build_dir/../expat/configure" ]]; then
259+
../expat/buildconf.sh ../expat/
260+
fi
261+
262+
../expat/configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
263+
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
264+
if [[ $? -ne 0 ]]; then
265+
return 1
266+
fi
267+
268+
make -j$(nproc) 1>&2
269+
if [[ $? -ne 0 ]]; then
270+
return 1
271+
fi
272+
273+
>&2 fancy_title "Finished building libexpat for $target_arch"
274+
275+
popd > /dev/null
276+
}
277+
217278
function build_python() {
218279
# Build python.
219280
#
@@ -373,6 +434,7 @@ function build_gdb() {
373434

374435
../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \
375436
--enable-tui "$python_flag" \
437+
--with-expat --with-libexpat-type="static" \
376438
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
377439
"--with-gmp=$libgmp_prefix" \
378440
"--with-mpfr=$libmpfr_prefix" \
@@ -517,6 +579,9 @@ function build_gdb_with_dependencies() {
517579
fi
518580
set_ncurses_link_variables "$ncursesw_build_dir"
519581

582+
libexpat_build_dir="$(build_libexpat "$packages_dir/libexpat" "$target_arch")"
583+
set_libexpat_link_variables "$libexpat_build_dir"
584+
520585
if [[ "$with_python" == "yes" ]]; then
521586
build_python "$packages_dir/cpython-static" "$target_arch"
522587
if [[ $? -ne 0 ]]; then

src/submodule_packages/libexpat

Submodule libexpat added at 2691aff

0 commit comments

Comments
 (0)