#!/bin/sh

n=runc
S=`dirname $0`/../main
D=$HOME/.cache/easylang

mkdir -p $D

test ! -e $D/$n && compile=1
h="$S/kfunc.h $S/klib.h $S/klex.h $S/kparse.h $S/../native/kbgr_nosdl.c $0"
f="$S/kbas.c"
for i in $f $h; do
  test $i -nt $D/$n && compile=1
done

if test $compile; then
  rm -f $D/$n
  cc=clang
  which $cc >/dev/null || cc=gcc
  echo "Compiling easylang (with $cc) ..." >&2

  $cc -Wall -O2 -D__NOSDL__ -I$S -O $f -lm -o $D/$n
  echo "done" >&2
fi

test -x $D/$n && $D/$n $*

