xref: /freebsd/contrib/unbound/contrib/android/install_expat.sh (revision be771a7b7f4580a30d99e41a5bb1b93a385a119d)
1#!/usr/bin/env bash
2
3LIBEXPAT_FNAME=expat-2.7.0
4LIBEXPAT_VERSION_DIR=R_2_7_0
5
6echo "Downloading Expat"
7if ! curl -L -k -s -o $LIBEXPAT_FNAME.tar.gz https://github.com/libexpat/libexpat/releases/download/$LIBEXPAT_VERSION_DIR/$LIBEXPAT_FNAME.tar.gz;
8then
9    echo "Failed to download Expat"
10    exit 1
11fi
12
13echo "Unpacking Expat"
14rm -rf ./$LIBEXPAT_FNAME
15if ! tar -xf $LIBEXPAT_FNAME.tar.gz;
16then
17    echo "Failed to unpack Expat"
18    exit 1
19fi
20
21cd $LIBEXPAT_FNAME || exit 1
22
23echo "Configuring Expat"
24if ! ./configure --build="$AUTOTOOLS_BUILD" --host="$AUTOTOOLS_HOST" --prefix="$ANDROID_PREFIX"; then
25    echo "Error: Failed to configure Expat"
26    exit 1
27fi
28
29# Cleanup warnings, https://github.com/libexpat/libexpat/issues/383
30echo "Fixing Makefiles"
31(IFS="" find "$PWD" -name 'Makefile' -print | while read -r file
32do
33    cp -p "$file" "$file.fixed"
34    sed 's|-Wduplicated-cond ||g; s|-Wduplicated-branches ||g; s|-Wlogical-op ||g' "$file" > "$file.fixed"
35    mv "$file.fixed" "$file"
36
37    cp -p "$file" "$file.fixed"
38    sed 's|-Wrestrict ||g; s|-Wjump-misses-init ||g; s|-Wmisleading-indentation ||g' "$file" > "$file.fixed"
39    mv "$file.fixed" "$file"
40done)
41
42echo "Building Expat"
43if ! make; then
44    echo "Failed to build Expat"
45    exit 1
46fi
47
48echo "Installing Expat"
49if ! make install; then
50    echo "Failed to install Expat"
51    exit 1
52fi
53
54exit 0
55