Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/registry/libxml2/build-libxml2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ if [ -z "$ZLIB_PREFIX" ]; then
ZLIB_PREFIX="$LEGACY_ZLIB"
fi

if [ ! -f "$ZLIB_PREFIX/lib/libz.a" ]; then
echo "ERROR: zlib not found at $ZLIB_PREFIX" >&2
if [ ! -f "$ZLIB_PREFIX/lib/libz.a" ] || [ ! -f "$ZLIB_PREFIX/include/zlib.h" ]; then
echo "ERROR: zlib headers and archive not found at $ZLIB_PREFIX" >&2
exit 1
fi
ZLIB_CPPFLAGS="-I$ZLIB_PREFIX/include"
ZLIB_LDFLAGS="-L$ZLIB_PREFIX/lib"

# --- Fetch + verify source ---
if [ ! -d "$SRC_DIR" ]; then
Expand Down Expand Up @@ -93,6 +95,8 @@ wasm32posix-configure \
--without-threads \
--with-zlib="$ZLIB_PREFIX" \
--prefix="$INSTALL_DIR" \
CPPFLAGS="$ZLIB_CPPFLAGS" \
LDFLAGS="$ZLIB_LDFLAGS" \
CFLAGS="-O2"

# Compile directly without libtool. Source list mirrors Makefile.am's
Expand All @@ -112,15 +116,16 @@ SOURCES=(
schematron.c
)

CFLAGS="-O2 -DHAVE_CONFIG_H -I. -I./include"
# The hand compile bypasses configure's generated Makefiles, so carry the
# resolver-owned zlib include path into this phase explicitly.
COMPILE_FLAGS=(-O2 -DHAVE_CONFIG_H -I. -I./include "$ZLIB_CPPFLAGS")

echo "==> Compiling libxml2 source files..."
OBJS=()
for src in "${SOURCES[@]}"; do
if [ -f "$src" ]; then
obj="${src%.c}.o"
# shellcheck disable=SC2086
wasm32posix-cc $CFLAGS -c "$src" -o "$obj"
wasm32posix-cc "${COMPILE_FLAGS[@]}" -c "$src" -o "$obj"
OBJS+=("$obj")
fi
done
Expand Down
Loading