#!/usr/local/bin/perl

#
#  Simple script to be used in the generation of the dependencies
#  for the S source.  The primary purpose is to replace the value of
#  SHOME with the symbolic constant '$(SHOME)'.

#  This is normally called something like 
#    gcc -MM $(USUAL_C_FLAGS) *.c | depend > .Makefile.depend

#  So it reads from STDIN in the absence of a any arguments
#  and writes to STDOUT.

$file = $ARGV[0];
$file = "-" unless $#ARGV > -1 ;

$SHOME = $ENV{"SHOME"};
open(FILE,$file) || die "Couldn't open $file";

while (<FILE>) {
  $_ =~ s/$SHOME/\$(SHOME)/g;
  print $_;
}
