#
# This shell file generates a list of OBJECTS and SOURCES suitable for
#	including in a buildfile.
# Args: source-suffix-pattern object-suffix path...
#	source-suffix-pattern: matches the suffix part of a source file name
#	object-suffix: The suffix of binary files
#	path: a list if directories, separated by :
# Output (in the file object.list): A list of sources, and binary files to make

set eol='$'
# First, list the the directories, giving tmp1
/bin/ls >tmp1
foreach dir (`echo $argv[3-] | sed "s/:/ /g"`)
    /bin/ls -d $dir/* >>tmp1
end
# Remove non-source files, and duplicates
<tmp1 sed -n -e "/$1$eol/p" | awk -f ../../unique.awk >tmp2
#Massage: Output SOURCES= line, then OBJECTS= line.
<tmp2 sed -n -e 'H' -e '${g' -e 's/\n/ /g' -e 's/^/SOURCES =/' -e p \
	-e 's/$/ /' -e 's/^SOURCES/OBJECTS/' -e 's/[^ ]*\///g' \
	-e "s/\([^ ]*\)$1 /\1$2 /g" -e p -e '}' > object.list
rm tmp1 tmp2
