1*25039b37SCy Schubert#!/usr/bin/env bash
2*25039b37SCy Schubert
3*25039b37SCy Schubertecho "Downloading Expat"
4*25039b37SCy Schubertif ! curl -L -k -s -o expat-2.2.9.tar.gz https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.gz;
5*25039b37SCy Schubertthen
6*25039b37SCy Schubert    echo "Failed to download Expat"
7*25039b37SCy Schubert    exit 1
8*25039b37SCy Schubertfi
9*25039b37SCy Schubert
10*25039b37SCy Schubertecho "Unpacking Expat"
11*25039b37SCy Schubertrm -rf ./expat-2.2.9
12*25039b37SCy Schubertif ! tar -xf expat-2.2.9.tar.gz;
13*25039b37SCy Schubertthen
14*25039b37SCy Schubert    echo "Failed to unpack Expat"
15*25039b37SCy Schubert    exit 1
16*25039b37SCy Schubertfi
17*25039b37SCy Schubert
18*25039b37SCy Schubertcd expat-2.2.9 || exit 1
19*25039b37SCy Schubert
20*25039b37SCy Schubertexport PKG_CONFIG_PATH="$IOS_PREFIX/lib/pkgconfig"
21*25039b37SCy Schubert
22*25039b37SCy Schubertecho "Configuring Expat"
23*25039b37SCy Schubertif ! ./configure \
24*25039b37SCy Schubert       --build="$AUTOTOOLS_BUILD" --host="$AUTOTOOLS_HOST" \
25*25039b37SCy Schubert       --prefix="$IOS_PREFIX" ; then
26*25039b37SCy Schubert    echo "Error: Failed to configure Expat"
27*25039b37SCy Schubert    cat config.log
28*25039b37SCy Schubert    exit 1
29*25039b37SCy Schubertfi
30*25039b37SCy Schubert
31*25039b37SCy Schubert# Cleanup warnings, https://github.com/libexpat/libexpat/issues/383
32*25039b37SCy Schubertecho "Fixing Makefiles"
33*25039b37SCy Schubert(IFS="" find "$PWD" -name 'Makefile' -print | while read -r file
34*25039b37SCy Schubertdo
35*25039b37SCy Schubert    cp -p "$file" "$file.fixed"
36*25039b37SCy Schubert    sed 's|-Wduplicated-cond ||g; s|-Wduplicated-branches ||g; s|-Wlogical-op ||g' "$file" > "$file.fixed"
37*25039b37SCy Schubert    mv "$file.fixed" "$file"
38*25039b37SCy Schubert
39*25039b37SCy Schubert    cp -p "$file" "$file.fixed"
40*25039b37SCy Schubert    sed 's|-Wrestrict ||g; s|-Wjump-misses-init ||g; s|-Wmisleading-indentation ||g' "$file" > "$file.fixed"
41*25039b37SCy Schubert    mv "$file.fixed" "$file"
42*25039b37SCy Schubertdone)
43*25039b37SCy Schubert
44*25039b37SCy Schubertecho "Building Expat"
45*25039b37SCy Schubertif ! make; then
46*25039b37SCy Schubert    echo "Failed to build Expat"
47*25039b37SCy Schubert    exit 1
48*25039b37SCy Schubertfi
49*25039b37SCy Schubert
50*25039b37SCy Schubertecho "Installing Expat"
51*25039b37SCy Schubertif ! make install; then
52*25039b37SCy Schubert    echo "Failed to install Expat"
53*25039b37SCy Schubert    exit 1
54*25039b37SCy Schubertfi
55*25039b37SCy Schubert
56*25039b37SCy Schubertexit 0
57