#!/bin/sh
# autopkgtest check: Build and run a program against gnome-autoar, 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' > trivial.c
#include <gnome-autoar/gnome-autoar.h>

int main(void)
{
    g_assert_true(autoar_check_mime_type_supported("application/zip"));
    return 0;
}
EOF

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