#!@PERL@ -w # -*- perl -*- # @configure_input@ use strict; use DirHandle; @HAVE_PERL_TERMCAP_TRUE@use Term::Cap; use integer; ######################################################################## sub usage () { print "Usage: $0 \n"; exit 1; } @ARGV == 1 or usage; my $tc_gen = shift; $| = 1; print "Removing intermediate files ..." unless $ENV{silent}; ######################################################################## # # Find the junk # my $dir = new DirHandle $tc_gen; my @junk; if (defined $dir) { foreach ($dir->read) { push @junk, "$tc_gen/$_" if /\.[cho]$/ || /\.mk$/ || /^stamp-/ || /\.ib$/; } } undef $dir; ######################################################################## # # Remove the junk # sub pick_cr () { return undef unless -t STDOUT; return undef if $ENV{silent}; return undef unless defined $ENV{TERM}; return undef if defined $ENV{EMACS}; return undef if $ENV{TERM} eq 'emacs'; return undef if $ENV{TERM} eq 'dumb'; @HAVE_PERL_TERMCAP_TRUE@ my $cap = (Tgetent Term::Cap { OSPEED => 9600 })->{'_cr'}; @HAVE_PERL_TERMCAP_TRUE@ return defined $cap ? $cap : "\r"; @HAVE_PERL_TERMCAP_FALSE@ return undef; } if (@junk) { my $cr = pick_cr; if (defined $cr) { my $prior = -1; foreach (1 .. @junk) { my $percent = $_ * 100 / @junk; print $cr, "Removing intermediate files ... $percent%" unless $prior == $percent; $prior = $percent; unlink $junk[$_ - 1]; } } else { unlink @junk; } } print "\n" unless $ENV{silent}; exit 0;