#!/bin/sh
# autopkgtest check: Build and run a program against gcab, to verify that the
# headers and pkg-config file are installed correctly
# (C) 2012 Canonical Ltd.
# (C) 2018-2019 Simon McVittie
# Authors: Martin Pitt, Simon McVittie

set -eux

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

int main(void)
{
    g_assert_cmpuint (GCAB_TYPE_FILE, !=, G_TYPE_INVALID);
    return 0;
}
EOF

# Deliberately word-splitting pkg-config's output:
# shellcheck disable=SC2046
gcc -o gcab-test test.c $(pkg-config --cflags --libs libgcab-1.0)
echo "build: OK"
[ -x gcab-test ]
./gcab-test
echo "run: OK"
