#!/bin/sh
set -e

WORKDIR=`mktemp -d`
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF >buildtest.c
#include <stdio.h>
#include <chewing.h>

int main()
{
    ChewingContext *ctx;
    ctx = chewing_new();
    if (!ctx) {
        fprintf(stderr, "chewing_new() fails.\n");
        return -1;
    };
    chewing_delete(ctx);
    return 0;
}
EOF

gcc -o buildtest buildtest.c `pkg-config --cflags --libs chewing`
./buildtest
