use ExtUtils::MakeMaker;

print "Preparing to install ReDIF perl package.\n";

do ( "Configure" ) 
    or die "Configure failed, so do I";

require 5.8.0;

my $copy = {
	    'lib/ReDIF/Parser/Input.pm.5.8' => 'lib/ReDIF/Parser/Input.pm',
	    'lib/ReDIF/Unicode.pm.5.8'      => 'lib/ReDIF/Unicode.pm',
	    };

foreach $f ( keys %$copy ) {
  copy_file( $f , $copy->{$f} );
}

sub copy_file {
  my $from = shift;
  my $to   = shift;

  if ( not -e $from 
       or not -r $from ) {
    return undef;
  }

  open  IN, "<", $from;
  my @input = <IN>;
  close IN;

  open  OUT, ">", $to;
  print OUT @input;
  close OUT;

  print "copied $from -> $to\n";

  return 1;
}


eval 'use Carp::Assert;';
if( @$ ) {
  print 
"You need Carp::Assert module if you plan to use ReDIF::Record.\n",
"Also with it you will avoid some errors during make test.\n",
"Otherwise it is not necessary.\n";
}


WriteMakefile(
	      'NAME'	=> 'ReDIF-perl',
	      'VERSION_FROM' => 'lib/ReDIF/Parser.pm',
	      'EXE_FILES' => [ 'rech', 'rere' ],
	      'PREREQ_PM' => {
	      },
	      
	      'dist'      => {
		  TARFLAGS => '-cvf',
		  COMPRESS => 'gzip -9f', 
		  SUFFIX   => '.gz',
	      },
	      
);
