#!/bin/sh
# autopkgtest check: Build and run a program against libxml2, to verify that the
# headers and pkg-config file are installed correctly
# (C) 2012 Canonical Ltd.
# Author: Daniel Holbach <daniel.holbach@ubuntu.com>
#         Picca Frédéric-Emmnauel <picca@debian.org>

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > hkltest.c
#include <hkl.h>

int
main(void)
{
    size_t n;
    HklFactory **factory = hkl_factory_get_all(&n);

    if (factory == NULL)
        return (1);
    return (0);
}
EOF

gcc -o hkltest hkltest.c `pkg-config --cflags --libs hkl`
echo "build: OK"
[ -x hkltest ]
./hkltest
echo "run: OK"
