#!/bin/sh
# autopkgtest check: Build and run a program against libepub, to verify that
# the headers and pkg-config file are installed correctly
# the sample epub is taken from:
# http://code.google.com/p/epub-samples/wiki/SamplesListing
#
# (C) 2013 Vibhav Pant
# Author: Vibhav Pant <vibhavp@ubuntu.com>

set -e

MYDIR=$(dirname $(readlink -f $0))
WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > libepub_test.c
#include <epub.h>
#include <stdio.h>
#include <assert.h>

int main(void)
{
	struct epub *e;
	e = epub_open("$MYDIR/sample.epub", 0);
	assert(e != NULL);
	epub_set_debug(e,1);;
	epub_close(e);
	epub_cleanup();
	return 0;
}
EOF

gcc -o libepub_test libepub_test.c -lepub -Wall -Werror
echo "build: OK"
[ -x libepub_test ]
./libepub_test
echo "run: OK"
