#!/bin/sh

echo "testing C library"

# generate the config.h file
meson setup --errorlogs build

cat build/meson-logs/meson-log.txt

# build C examples
for f in example/*.c; do
    echo gcc -o "${f%.c}" "$(pkg-config --cflags libxrl)" "$f" "$(pkg-config --libs libxrl)" -lm
    gcc -o "${f%.c}" $(pkg-config --cflags libxrl) $f $(pkg-config --libs libxrl) -lm
    echo "run ${f%.c}"
    ./"${f%.c}"
done;

# build all unit tests
for f in tests/*.c; do
    echo gcc -o "${f%.c}" "$(pkg-config --cflags libxrl)" -Isrc -Ibuild "$f" "$(pkg-config --libs libxrl)" -lm
    gcc -o "${f%.c}" $(pkg-config --cflags libxrl) -Isrc -Ibuild $f $(pkg-config --libs libxrl) -lm
    echo "run ${f%.c}"
    ./"${f%.c}"
done;
