#!/bin/sh
# Compile the demo against the installed development package, both the way
# the README documents (-lcalendars) and the way a build system would find
# it (pkg-config), then run it.
set -e

TESTDIR=$(dirname "$0")
cp "$TESTDIR/calendar-demo.c" "$AUTOPKGTEST_TMP/"
cd "$AUTOPKGTEST_TMP"

echo "--- linking with -lcalendars ---"
cc -Wall -Wextra -Werror -o demo-plain calendar-demo.c -lcalendars
./demo-plain

echo "--- linking through pkg-config ---"
pkg-config --exists libcalendars
echo "modversion: $(pkg-config --modversion libcalendars)"
# shellcheck disable=SC2046
cc -Wall -Wextra -Werror $(pkg-config --cflags libcalendars) \
    -o demo-pkgconfig calendar-demo.c $(pkg-config --libs libcalendars)
./demo-pkgconfig
