xref: /netbsd-src/external/bsd/unbound/dist/contrib/ios/install_expat.sh (revision d0eba39ba71d0ccd0f91ae4c5ff83442e84710bf)
1*d0eba39bSchristos#!/usr/bin/env bash
2*d0eba39bSchristos
3*d0eba39bSchristosecho "Downloading Expat"
4*d0eba39bSchristosif ! 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*d0eba39bSchristosthen
6*d0eba39bSchristos    echo "Failed to download Expat"
7*d0eba39bSchristos    exit 1
8*d0eba39bSchristosfi
9*d0eba39bSchristos
10*d0eba39bSchristosecho "Unpacking Expat"
11*d0eba39bSchristosrm -rf ./expat-2.2.9
12*d0eba39bSchristosif ! tar -xf expat-2.2.9.tar.gz;
13*d0eba39bSchristosthen
14*d0eba39bSchristos    echo "Failed to unpack Expat"
15*d0eba39bSchristos    exit 1
16*d0eba39bSchristosfi
17*d0eba39bSchristos
18*d0eba39bSchristoscd expat-2.2.9 || exit 1
19*d0eba39bSchristos
20*d0eba39bSchristosexport PKG_CONFIG_PATH="$IOS_PREFIX/lib/pkgconfig"
21*d0eba39bSchristos
22*d0eba39bSchristosecho "Configuring Expat"
23*d0eba39bSchristosif ! ./configure \
24*d0eba39bSchristos       --build="$AUTOTOOLS_BUILD" --host="$AUTOTOOLS_HOST" \
25*d0eba39bSchristos       --prefix="$IOS_PREFIX" ; then
26*d0eba39bSchristos    echo "Error: Failed to configure Expat"
27*d0eba39bSchristos    cat config.log
28*d0eba39bSchristos    exit 1
29*d0eba39bSchristosfi
30*d0eba39bSchristos
31*d0eba39bSchristos# Cleanup warnings, https://github.com/libexpat/libexpat/issues/383
32*d0eba39bSchristosecho "Fixing Makefiles"
33*d0eba39bSchristos(IFS="" find "$PWD" -name 'Makefile' -print | while read -r file
34*d0eba39bSchristosdo
35*d0eba39bSchristos    cp -p "$file" "$file.fixed"
36*d0eba39bSchristos    sed 's|-Wduplicated-cond ||g; s|-Wduplicated-branches ||g; s|-Wlogical-op ||g' "$file" > "$file.fixed"
37*d0eba39bSchristos    mv "$file.fixed" "$file"
38*d0eba39bSchristos
39*d0eba39bSchristos    cp -p "$file" "$file.fixed"
40*d0eba39bSchristos    sed 's|-Wrestrict ||g; s|-Wjump-misses-init ||g; s|-Wmisleading-indentation ||g' "$file" > "$file.fixed"
41*d0eba39bSchristos    mv "$file.fixed" "$file"
42*d0eba39bSchristosdone)
43*d0eba39bSchristos
44*d0eba39bSchristosecho "Building Expat"
45*d0eba39bSchristosif ! make; then
46*d0eba39bSchristos    echo "Failed to build Expat"
47*d0eba39bSchristos    exit 1
48*d0eba39bSchristosfi
49*d0eba39bSchristos
50*d0eba39bSchristosecho "Installing Expat"
51*d0eba39bSchristosif ! make install; then
52*d0eba39bSchristos    echo "Failed to install Expat"
53*d0eba39bSchristos    exit 1
54*d0eba39bSchristosfi
55*d0eba39bSchristos
56*d0eba39bSchristosexit 0
57