#!/bin/sh

set -e

BINARY="$AUTOPKGTEST_TMP/binary"
SOURCE="$AUTOPKGTEST_TMP/binary.c"

cat >"$SOURCE" <<-EOF
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>

#include <hiredict/hiredict.h>

int main (int argc, char **argv) {
  char *s;
  int len;
  
  len = redictFormatCommand(&s, "PING");
  if (len < 0) {
    return 1;
  }
  redictFreeCommand(s);
  return 0;
}
EOF

HIREDICT_CFLAGS="`pkgconf --cflags hiredict`"
HIREDICT_LIBS="`pkgconf --libs hiredict`"
gcc -o "$BINARY" $HIREDICT_CFLAGS -Wall -Werror "$SOURCE" $HIREDICT_LIBS
chmod 755 "$BINARY"
"$BINARY"

