#!/bin/sh

if [ "$1" = "clean" ]
then
	( cd `dirname $0`; rm -f *.cxx *.so *.o mlt.i ../.lua )
	exit 0
fi

path=`which lua 2> /dev/null`

if [ $? = 0 ]
then
	ln -sf ../mlt.i

	# Invoke swig
	swig -c++ -I../../mlt++ -I../.. -lua mlt.i || exit $?

	# Compile the wrapper
	g++ -fPIC -DPIC -D_GNU_SOURCE -c -rdynamic -pthread -I../.. mlt_wrap.cxx || exit $?

	# Create the module
	g++ -shared mlt_wrap.o -L../../mlt++ -lmlt++ -o mlt.so || exit $?
else
	echo Lua not installed.
	exit 1
fi
