#!/bin/sh
# Compile and run a minimal program against the installed librnnoise to prove
# the -dev package (header + pkg-config + .so symlink) is usable.
set -e

WORK="${AUTOPKGTEST_TMP:-$(mktemp -d)}"

cat > "$WORK/t.c" <<'EOF'
#include <rnnoise.h>
#include <stdlib.h>

int main(void) {
    DenoiseState *st = rnnoise_create(NULL);
    if (!st) return 1;
    int n = rnnoise_get_frame_size();
    float *buf = calloc((size_t)n, sizeof(float));
    if (!buf) return 1;
    rnnoise_process_frame(st, buf, buf);
    free(buf);
    rnnoise_destroy(st);
    return 0;
}
EOF

cc "$WORK/t.c" $(pkgconf --cflags --libs rnnoise) -o "$WORK/t"
"$WORK/t"
echo "OK: linked and ran against librnnoise"
