build: added libexpat build support

This allows commands such as "info os files"
previously we had expat support on x86_64 only.
This commit is contained in:
Guy Shimko 2025-01-09 18:01:42 +02:00
parent 9e7d1ed118
commit d978ca9aaf
4 changed files with 71 additions and 6 deletions

3
.gitmodules vendored
View File

@ -9,3 +9,6 @@
[submodule "src/submodule_packages/pygments"] [submodule "src/submodule_packages/pygments"]
path = src/submodule_packages/pygments path = src/submodule_packages/pygments
url = git@github.com:pygments/pygments.git url = git@github.com:pygments/pygments.git
[submodule "src/submodule_packages/libexpat"]
path = src/submodule_packages/libexpat
url = git@github.com:guyush1/libexpat.git

View File

@ -19,6 +19,7 @@ RUN apt update && apt install -y \
gcc-powerpc-linux-gnu \ gcc-powerpc-linux-gnu \
git \ git \
libncurses-dev \ libncurses-dev \
libtool \
m4 \ m4 \
make \ make \
patch \ patch \

View File

@ -57,15 +57,18 @@ function set_compliation_variables() {
export LDFLAGS="-s" export LDFLAGS="-s"
} }
function set_ncurses_link_variables() { function set_up_lib_search_paths() {
# Set up ncurses library link variables # Set up library-related linker search paths.
# #
# Parameters: # Parameters:
# $1: ncursesw build dir # $1: ncursesw build dir
# $2: libexpat build dir
local ncursesw_build_dir="$1" local ncursesw_build_dir="$1"
local libexpat_build_dir="$2"
# Allow tui mode by adding our custom built static ncursesw library to the linker search path. # I) Allow tui mode by adding our custom built static ncursesw library to the linker search path.
export LDFLAGS="-L$ncursesw_build_dir/lib $LDFLAGS" # II) Allow parsing xml files by adding libexpat library to the linker search path.
export LDFLAGS="-L$ncursesw_build_dir/lib -L$libexpat_build_dir/lib/.libs $LDFLAGS"
} }
function build_iconv() { function build_iconv() {
@ -214,6 +217,56 @@ function build_ncurses() {
popd > /dev/null popd > /dev/null
} }
function build_libexpat() {
# Build libexpat.
#
# Parameters:
# $1: libexpat package directory
# $2: target architecture
#
# Echoes:
# The libexpat build directory
#
# Returns:
# 0: success
# 1: failure
local libexpat_dir="$1"
local target_arch="$2"
local libexpat_build_dir="$(realpath "$libexpat_dir/build-$target_arch")"
echo "$libexpat_build_dir"
mkdir -p "$libexpat_build_dir"
if [[ -f "$libexpat_build_dir/lib/.libs/libexpat.a" ]]; then
>&2 echo "Skipping build: libexpat already built for $target_arch"
return 0
fi
pushd "$libexpat_build_dir" > /dev/null
>&2 fancy_title "Building libexpat for $target_arch"
# Generate configure if it doesnt exist.
if [[ ! -f "$libexpat_build_dir/../expat/configure" ]]; then
>&2 ../expat/buildconf.sh ../expat/
fi
../expat/configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
if [[ $? -ne 0 ]]; then
return 1
fi
make -j$(nproc) 1>&2
if [[ $? -ne 0 ]]; then
return 1
fi
>&2 fancy_title "Finished building libexpat for $target_arch"
popd > /dev/null
}
function build_python() { function build_python() {
# Build python. # Build python.
# #
@ -388,10 +441,11 @@ function build_gdb() {
../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \ ../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \
--enable-tui "$python_flag" \ --enable-tui "$python_flag" \
--with-expat --with-libexpat-type="static" \
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \ "--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
"--with-gmp=$libgmp_prefix" \ "--with-gmp=$libgmp_prefix" \
"--with-mpfr=$libmpfr_prefix" \ "--with-mpfr=$libmpfr_prefix" \
"CC=$CC" "CXX=$CXX" "--host=$HOST" \ "CC=$CC" "CXX=$CXX" "LDFLAGS=$LDFLAGS" "--host=$HOST" \
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2 "CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
return 1 return 1
@ -530,7 +584,13 @@ function build_gdb_with_dependencies() {
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
return 1 return 1
fi fi
set_ncurses_link_variables "$ncursesw_build_dir"
libexpat_build_dir="$(build_libexpat "$packages_dir/libexpat" "$target_arch")"
if [[ $? -ne 0 ]]; then
return 1
fi
set_up_lib_search_paths "$ncursesw_build_dir" "$libexpat_build_dir"
if [[ "$with_python" == "yes" ]]; then if [[ "$with_python" == "yes" ]]; then
local gdb_python_dir="$packages_dir/binutils-gdb/gdb/python/lib/" local gdb_python_dir="$packages_dir/binutils-gdb/gdb/python/lib/"

@ -0,0 +1 @@
Subproject commit 2691aff4304a6d7e053199c205620136481b9dd1