#! /usr/bin/perl
@j=split('\.',$ARGV[0]);
$root=$j[0];
print $ARGV[0];
`jadetex "$root".tex`;
`jadetex "$root".tex`;
`jadetex "$root".tex`;
print "Made DVI";
`dvipdf "$root".dvi`;
print "Made PS";
`dvips "$root".dvi`;
print "Made PDF";
$x=file_size($root.".pdf");
$y=file_size($root.".ps");
$z=file_size($root.".txt");
$v=file_size($root.".rtf");
$l=file_size($root.".xml");
$k=file_size($root.".print.html");
$date=`date +'%-d %B %Y'`;
`xsltproc --novalid --stringparam date "$date" --stringparam file "$root" --stringparam html_size "$k" --stringparam pdf_size "$x" --stringparam ps_size "$y" --stringparam txt_size "$z" --stringparam rtf_size "$v" --stringparam docbook_size "$l" ccsr.xsl "$root".xml >"$root".html`;
sub file_size
{
 my ($g)=@_;
 ($a,$a,$a,$a,$a,$a,$a,$b,$a,$a,$a,$a,$a)=stat($g);
 return human_size($b);
}
sub human_size
{
 my ($b)=@_;
 print "$b\n";
 if ($b<4096)
 {
  return $b." bytes";
 } 
 else
 {
  if ($b<(4096*1024))
  {
  	return int($b/1024)." kbytes";
  }
  else
  {
   if ($b<(4096*1024*1024))
   {
   	return int($b/1024/1024)." mbytes";
   }
  }
 }
}

