#!/bin/sh

# ==========================================================================
# elastic-comp
# ==========================================================================
# Script to ease byte compilation from '.ec' to '.ecc'
# --------------------------------------------------------------------------
#   AUTHOR:  Marco Pantaleoni         E-mail: panta@elasticworld.org
#
#   Created: 19 Nov 1999
#
#   $Id$
# --------------------------------------------------------------------------
#    Copyright (C) 1999-2001 Marco Pantaleoni. All rights reserved.
#
#  The contents of this file are subject to the elastiC License version 1.0
#  (the "elastiC License"); you may not use this file except in compliance
#  with the elastiC License. You may obtain a copy of the elastiC License at
#  http://www.elasticworld.org/LICENSE
#
#  IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTORS BE LIABLE TO ANY PARTY
#  FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
#  ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
#  DERIVATIVES THEREOF, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
#  POSSIBILITY OF SUCH DAMAGE.
#
#  THE AUTHOR AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
#  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
#  IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHOR AND DISTRIBUTORS HAVE
#  NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
#  MODIFICATIONS.
#
#  See the elastiC License for the specific language governing rights and
#  limitations under the elastiC License.
# ==========================================================================

# This script compiles all `.ec' files given as arguments, using the
# elastic 'ecc' compiler, and put the resulting '.ecc' files into
# the current directory, ignoring the original directories used in
# arguments.
#
# This script manages in such a way that all elastic files to
# be compiled are made visible between themselves, in the event
# they are mutually dependent.

if test $# = 0 ; then
   echo 1>&2 "No files given to $0"
   exit 1
else
   if test -z "$ECC" ; then
      # Just assume ecc is called "ecc".
      ECC=ecc;
   fi

   tempdir=ecc.$$
   mkdir $tempdir
   cp $* $tempdir
   cd $tempdir

   for i in *.ec ; do
     #ELASTICPATH=".";
     #export ELASTICPATH=".";
     #$ECC $i;
     ELASTICPATH="." $ECC $i
   done
   mv *.ecc ..

   cd ..
   rm -fr $tempdir
fi
