#!/bin/sh

set -e

PATH=/usr/sbin:$PATH
export PATH

at_exit() {
    echo "info: test exiting"
    rm -f x.cpp x.o
}

trap at_exit INT TERM EXIT

echo "Output from pkg-config --cflags libelf++:"
if pkg-config --cflags libelf++ ; then
    echo "success: pkg-config call succeeded"
else
    echo "error: pkg-config call failed.  Skipping the rest of the tests"
    exit 1
fi

cat > x.cpp <<EOF
#include <elf/elf++.hh>
EOF
c++ $(pkg-config --cflags libelf++) -c x.cpp
if [ -e x.o ] ; then
    echo "success: Compilation produced x.o"
else
    echo "error: Compilation did not procduce x.o"
fi
