#!/bin/bash

# Copyright (C) 2004 by Steve Litt, all rights reserved.
# Licensed under version 2 of the GNU General Public License
# See the COPYING file
# NO WARRANTY!!!!

if test "$1" = "" -o "$2" != ""; then
	echo emdlcompile.sh usage:
	echo ./emdlcompile.sh    full_path_to_emdl_file
	exit
fi

if test "$EMDL_DIRECTORY" = "" -o     \
	"$EMDL_CONFIG" = "" -o        \
	"$UMENU_DIRECTORY" = "" -o    \
	"$NODE_DIRECTORY" = "" -o     \
	"$UMENU_MENUDIR" = "" -o      \
	"$UMENU_PROGRAMDIR" = "" -o   \
	"$EMDL_TEMP" = ""; then

	echo EMDL_DIRECTORY is         \>$EMDL_DIRECTORY\<  
	echo EMDL_CONFIG is            \>$EMDL_CONFIG\<
	echo UMENU_DIRECTORY is        \>$UMENU_DIRECTORY\<
	echo NODE_DIRECTORY is         \>$NODE_DIRECTORY\<
	echo UMENU_MENUDIR is          \>$UMENU_MENUDIR\<
	echo UMENU_PROGRAMDIR is       \>$UMENU_PROGRAMDIR\<
	echo EMDL_TEMP is              \>$EMDL_TEMP\<             
	echo
	echo ERROR! Must run ./emdlcompile.sh through ./emdlinit.sh

	exit
fi

if test ${1:0:1} = "/";then
	ABSOLUTE_FILENAME=$1
else
	ABSOLUTE_FILENAME=`pwd`/$1
fi

cd $EMDL_TEMP

cat $ABSOLUTE_FILENAME | perl -I$NODE_DIRECTORY $EMDL_DIRECTORY/emdlparser.pl

