use 5.010000;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    NAME              => 'LATMOS::Accounts',
    VERSION           => '0.0.25', # finds $VERSION
    PREREQ_PM         => {
        'Net::LDAP' => undef,
        'Unicode::Map8' => undef,
        'DBD::Pg' => undef,
        'Crypt::RSA' => undef,
        'MIME::Base64' => undef,
        'Term::ReadKey' => undef,
        'Config::IniFiles' => undef,
        'Mail::Sendmail' => undef,
        'Net::DNS' => undef,
        'Template' => undef,
        'Sys::Syslog' => undef,
        'Pod::Usage' => undef,
        'Unicode::String' => undef,
        'Crypt::Cracklib' => undef,
    }, # e.g., Module::Name => 1.1
    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
      (ABSTRACT_FROM  => 'lib/LATMOS/Accounts.pm', # retrieve abstract from module
       AUTHOR         => 'Thauvin Olivier <olivier.thauvin@latmos.ipsl.fr>') : ()),
    EXE_FILES => [ qw(
        bin/la-acls
        bin/la-qacls
        bin/la-attributes
        bin/la-config
        bin/la-create
        bin/la-crypt-passwd
        bin/la-delete
        bin/la-edit
        bin/la-group
        bin/la-guser
        bin/la-passwd
        bin/la-query
        bin/la-rename
        bin/la-search
        bin/la-sync
        bin/la-sync-list
        bin/la-sync-manager
        bin/la-warn-expire
        bin/la-web-directory
        ) ],
);

package MY;

sub postamble {
    <<EOF;
.PHONY .= svnmanifest

svnmanifest:
\tsvn ls -R| grep -v "/\$\$"  > MANIFEST

ChangeLog:
\tsvn log > ChangeLog

latmos-accounts.spec: latmos-accounts.spec.in Makefile
\tsed -e 's/\@VERSION@/\$(VERSION)/' < \$< > \$@

rpm: \$(DISTVNAME).tar.gz latmos-accounts.spec
\tmkdir ./noarch || :
\trpmbuild -ba --clean\\
\t --define "_sourcedir `pwd`" \\
\t --define "_specdir `pwd`" \\
\t --define "_srcrpmdir `pwd`" \\
\t --define "_rpmdir `pwd`" \\
\t latmos-accounts.spec

EOF
}

sub install {
    my ($self) = @_;
    my $section = $self->SUPER::install();

    $section =~ s/(^install ::.*)/$1 install_config install_templates/m;

    $section .= q[
install_config ::
	install -d $(DESTDIR)/etc
	install sample/latmos-account.ini $(DESTDIR)/etc/latmos-account.ini

install_templates ::
	install -d $(DESTDIR)/usr/share/latmos-accounts/templates
	$(ABSPERLRUN) -MExtUtils::Install -e 'install({ templates => @ARGV })' \\
		$(DESTDIR)/usr/share/latmos-accounts/templates 
];
  
    return $section;
}
