#!/bin/sh

# Configuration script to find cflags and libs paths for libxml2
# But more importantly to give a proper error message if unavailable

if command -v xml2-config >/dev/null 2>&1; then
    CFLAGS=$(xml2-config --cflags)
    LIBS=$(xml2-config --libs)
else
    echo "================== ERROR CONFIGURING LIBSOC ================="
    echo "xml2-config was not found"
    echo "Make sure that the libxml2 development package is installed" 
    echo "For Ubuntu, Debian etc install with apt install libxml2-dev"
    echo "For CentOS, Fedora etc install with yum install libxml2-devel"
    echo "For Solaris install with pkg install libxml2_dev"
    echo "============================================================="
    exit 1
fi

sed -e "s|@cflags@|$CFLAGS|" -e "s|@libs@|$LIBS|" src/Makevars.in >src/Makevars

exit 0
