Skip to content

Commit e97b65c

Browse files
authored
Merge pull request #31 from guyush1/add-libexpat-support
build: added libexpat build support
2 parents 9e7d1ed + d978ca9 commit e97b65c

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
[submodule "src/submodule_packages/pygments"]
1010
path = src/submodule_packages/pygments
1111
url = [email protected]:pygments/pygments.git
12+
[submodule "src/submodule_packages/libexpat"]
13+
path = src/submodule_packages/libexpat
14+
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: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,18 @@ function set_compliation_variables() {
5757
export LDFLAGS="-s"
5858
}
5959

60-
function set_ncurses_link_variables() {
61-
# Set up ncurses library link variables
60+
function set_up_lib_search_paths() {
61+
# Set up library-related linker search paths.
6262
#
6363
# Parameters:
6464
# $1: ncursesw build dir
65+
# $2: libexpat build dir
6566
local ncursesw_build_dir="$1"
67+
local libexpat_build_dir="$2"
6668

67-
# Allow tui mode by adding our custom built static ncursesw library to the linker search path.
68-
export LDFLAGS="-L$ncursesw_build_dir/lib $LDFLAGS"
69+
# I) Allow tui mode by adding our custom built static ncursesw library to the linker search path.
70+
# II) Allow parsing xml files by adding libexpat library to the linker search path.
71+
export LDFLAGS="-L$ncursesw_build_dir/lib -L$libexpat_build_dir/lib/.libs $LDFLAGS"
6972
}
7073

7174
function build_iconv() {
@@ -214,6 +217,56 @@ function build_ncurses() {
214217
popd > /dev/null
215218
}
216219

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

389442
../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \
390443
--enable-tui "$python_flag" \
444+
--with-expat --with-libexpat-type="static" \
391445
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
392446
"--with-gmp=$libgmp_prefix" \
393447
"--with-mpfr=$libmpfr_prefix" \
394-
"CC=$CC" "CXX=$CXX" "--host=$HOST" \
448+
"CC=$CC" "CXX=$CXX" "LDFLAGS=$LDFLAGS" "--host=$HOST" \
395449
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
396450
if [[ $? -ne 0 ]]; then
397451
return 1
@@ -530,7 +584,13 @@ function build_gdb_with_dependencies() {
530584
if [[ $? -ne 0 ]]; then
531585
return 1
532586
fi
533-
set_ncurses_link_variables "$ncursesw_build_dir"
587+
588+
libexpat_build_dir="$(build_libexpat "$packages_dir/libexpat" "$target_arch")"
589+
if [[ $? -ne 0 ]]; then
590+
return 1
591+
fi
592+
593+
set_up_lib_search_paths "$ncursesw_build_dir" "$libexpat_build_dir"
534594

535595
if [[ "$with_python" == "yes" ]]; then
536596
local gdb_python_dir="$packages_dir/binutils-gdb/gdb/python/lib/"

src/submodule_packages/libexpat

Submodule libexpat added at 2691aff

0 commit comments

Comments
 (0)