use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.

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

# $DEBUG = 1;

my @dirs = ();

# if( not have_module( 'RePEc::Index' ) ) {
#   push @dirs, './RePEc-Index';
# }

# have_module( 'AppConfig'  ) ;
# have_module( 'Storable'   ) ;
# have_module( 'XML::XPath' ) ;
# have_module( 'Carp::Assert' ) ;
# have_module( 'sql_helper' ) ;


# if( not have_module( 'RePEc-Index' ) ) {
#   push @dirs, 'RePEc-Index';
# }



# do ( "configure.pl" ) or die "Configure failed, so do I";


WriteMakefile
  (
   'NAME'		=> 'ARDB',
   'VERSION_FROM'	=> 'lib/ARDB.pm', # finds $VERSION
   'PREREQ_PM'	=>  {
		     'Carp::Assert' => "0.17",
		     'Storable'     => "1.013",
		     'CGI::Untaint' => '',
		     'XML::XPath'   => '1.12',
		     'XML::LibXSLT' => "",
		     'AppConfig'    => "1.52",

		     'sql_helper'   => '0.2',
		     'RePEc::Index' => "",
		     'RePEc::ShortIDs::Client' => '',
		    }, 
   DIR => [ @dirs ],
   ABSTRACT      => 'Abstract Metadata Database',
   AUTHOR        => 'Ivan Baktcheev & Ivan Kurmanov', 

#   dist => { PREOP => '$(CP) /home/ivan/dev/Index/Index/RePEc-Index-0.4.tar.gz $(DISTVNAME)', },

  );



# copied from AxKit's Makefile.PL, http://axkit.org


sub have_module {
    my ($module, $version) = (@_, 0);
    printf("checking for module %s >= version %s... ", $module, $version);


    if ( $version eq '0' ) { 
      $version = '';
    }
    print "eval(\"package Foo; use $module $version;\")\n" if $DEBUG;
    eval "package Foo; use $module $version;";
    if ($@) {
        print $@ if $DEBUG;
        print "no\n";
        return 0;
    }
    print "yes\n";
    return 1;
}

