#! /bin/bash
#*******************************************************************************
# E.S.O. - VLT project
#
# "@(#) $Id: vltMakePythonPackDependencies,v 1.2 2004/09/27 09:15:52 mzampare Exp $" 
#
# who       when      what
# --------  --------  ----------------------------------------------
# mzampare 2002-02-15 created 
# mzampare 2002-02-27 package files now under explicit subdirectory under src
# mzampare 2002-02-27 dependency files was incorrect for large directories
# mzampare 2002-03-18 dependencies used a non declared variable
# mzampare 2003-01-15 added sed to avoid CVS clutter
#************************************************************************
#   NAME
#   vltMakePythonPackDependencies - create the makefile to build one python package
# 
#   SYNOPSIS
#
#   vltMakePythonPackDependencies <packageName>
# 
#
#   DESCRIPTION
#   Utility used by vltMakefile.all to create the makefile to build one python package.
#   It is not intended to be used as a standalone command.
#
#
#   The rule is written to standard output.
#
#   <packageName>  The script to be treated
#
#
#   FILES
#   $VLTROOT/include/vltMakefile.all  
#
#   ENVIRONMENT
#
#   RETURN VALUES
#
#   SEE ALSO 
#   vltMakefile.all, Makefile, (GNU) make
#
#   GNU make - Edition 0.41, for make Version 3.64 Beta, April 93
#   VLT Software - Programming Standard - 1.0 10/03/93
#
#   BUGS    
#
#----------------------------------------------------------------------
if [ "${1}" != "" ]
then
    packageName=$1
else
    echo "ERROR: vltMakePythonPackDependencies called with no parameters" >&2
    exit 1
fi

echo "# Dependency file for module: ${packageName}"
echo "# Created automatically by vltMakePythonPackDependencies -  `date '+%d.%m.%y %T'`"
echo "# DO NOT EDIT THIS FILE"

#
# define the dependency file dependent to the Makefile
echo "../object/${packageName}.dpps: Makefile"
echo ""

# if the list of objects is not empty, the rule to build the Python package is written on output.
if [ -d $packageName ]; then 
    objectList=`/bin/ls -1 $packageName 2>/dev/null`
    objectList=`echo $objectList | sed -e 's/CVS//'`
fi
for file in `echo $objectList`
do    
    oList=`echo -n ${packageName}/$file ; echo -n " "; echo -n $oList `
done

if [ "${objectList}" != "" ]
then
    # write on output the rule to build the script.
    echo "../lib/python/site-packages/${packageName}: \$(shell find ${packageName}  -type f | grep -v  '\/CVS\/') Makefile"
    echo "	@echo \"== Making python package: ../lib/python/site-packages/${packageName}\" "
    echo "	\$(AT)vltMakePythonPackage ${packageName} \"\$(shell find ${packageName}  -type f | grep -v '\/CVS\/') \""
    echo "	\$(AT)touch ../lib/python/site-packages/${packageName}"
else
    # write on output the rule to build the script.
    echo "../lib/python/site-packages/${packageName}:  Makefile"
    echo "# ${packageName} directory does not exist or is empty. Nothing to do here."
    echo "# Makefile should define the action for target  '${packageName}:'"
fi



#


#
# ___oOo___
