1#line 1
2package Module::AutoInstall;
3
4use strict;
5use Cwd                 ();
6use ExtUtils::MakeMaker ();
7
8use vars qw{$VERSION};
9BEGIN {
10	$VERSION = '1.03';
11}
12
13# special map on pre-defined feature sets
14my %FeatureMap = (
15    ''      => 'Core Features',    # XXX: deprecated
16    '-core' => 'Core Features',
17);
18
19# various lexical flags
20my ( @Missing, @Existing,  %DisabledTests, $UnderCPAN,     $HasCPANPLUS );
21my (
22    $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps
23);
24my ( $PostambleActions, $PostambleUsed );
25
26# See if it's a testing or non-interactive session
27_accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN );
28_init();
29
30sub _accept_default {
31    $AcceptDefault = shift;
32}
33
34sub missing_modules {
35    return @Missing;
36}
37
38sub do_install {
39    __PACKAGE__->install(
40        [
41            $Config
42            ? ( UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} )
43            : ()
44        ],
45        @Missing,
46    );
47}
48
49# initialize various flags, and/or perform install
50sub _init {
51    foreach my $arg (
52        @ARGV,
53        split(
54            /[\s\t]+/,
55            $ENV{PERL_AUTOINSTALL} || $ENV{PERL_EXTUTILS_AUTOINSTALL} || ''
56        )
57      )
58    {
59        if ( $arg =~ /^--config=(.*)$/ ) {
60            $Config = [ split( ',', $1 ) ];
61        }
62        elsif ( $arg =~ /^--installdeps=(.*)$/ ) {
63            __PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) );
64            exit 0;
65        }
66        elsif ( $arg =~ /^--default(?:deps)?$/ ) {
67            $AcceptDefault = 1;
68        }
69        elsif ( $arg =~ /^--check(?:deps)?$/ ) {
70            $CheckOnly = 1;
71        }
72        elsif ( $arg =~ /^--skip(?:deps)?$/ ) {
73            $SkipInstall = 1;
74        }
75        elsif ( $arg =~ /^--test(?:only)?$/ ) {
76            $TestOnly = 1;
77        }
78        elsif ( $arg =~ /^--all(?:deps)?$/ ) {
79            $AllDeps = 1;
80        }
81    }
82}
83
84# overrides MakeMaker's prompt() to automatically accept the default choice
85sub _prompt {
86    goto &ExtUtils::MakeMaker::prompt unless $AcceptDefault;
87
88    my ( $prompt, $default ) = @_;
89    my $y = ( $default =~ /^[Yy]/ );
90
91    print $prompt, ' [', ( $y ? 'Y' : 'y' ), '/', ( $y ? 'n' : 'N' ), '] ';
92    print "$default\n";
93    return $default;
94}
95
96# the workhorse
97sub import {
98    my $class = shift;
99    my @args  = @_ or return;
100    my $core_all;
101
102    print "*** $class version " . $class->VERSION . "\n";
103    print "*** Checking for Perl dependencies...\n";
104
105    my $cwd = Cwd::cwd();
106
107    $Config = [];
108
109    my $maxlen = length(
110        (
111            sort   { length($b) <=> length($a) }
112              grep { /^[^\-]/ }
113              map  {
114                ref($_)
115                  ? ( ( ref($_) eq 'HASH' ) ? keys(%$_) : @{$_} )
116                  : ''
117              }
118              map { +{@args}->{$_} }
119              grep { /^[^\-]/ or /^-core$/i } keys %{ +{@args} }
120        )[0]
121    );
122
123    # We want to know if we're under CPAN early to avoid prompting, but
124    # if we aren't going to try and install anything anyway then skip the
125    # check entirely since we don't want to have to load (and configure)
126    # an old CPAN just for a cosmetic message
127
128    $UnderCPAN = _check_lock(1) unless $SkipInstall;
129
130    while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) {
131        my ( @required, @tests, @skiptests );
132        my $default  = 1;
133        my $conflict = 0;
134
135        if ( $feature =~ m/^-(\w+)$/ ) {
136            my $option = lc($1);
137
138            # check for a newer version of myself
139            _update_to( $modules, @_ ) and return if $option eq 'version';
140
141            # sets CPAN configuration options
142            $Config = $modules if $option eq 'config';
143
144            # promote every features to core status
145            $core_all = ( $modules =~ /^all$/i ) and next
146              if $option eq 'core';
147
148            next unless $option eq 'core';
149        }
150
151        print "[" . ( $FeatureMap{ lc($feature) } || $feature ) . "]\n";
152
153        $modules = [ %{$modules} ] if UNIVERSAL::isa( $modules, 'HASH' );
154        $modules = [ @{$modules} ]; # Copy to keep original
155
156        unshift @$modules, -default => &{ shift(@$modules) }
157          if ( ref( $modules->[0] ) eq 'CODE' );    # XXX: bugward combatability
158
159        while ( my ( $mod, $arg ) = splice( @$modules, 0, 2 ) ) {
160            if ( $mod =~ m/^-(\w+)$/ ) {
161                my $option = lc($1);
162
163                $default   = $arg    if ( $option eq 'default' );
164                $conflict  = $arg    if ( $option eq 'conflict' );
165                @tests     = @{$arg} if ( $option eq 'tests' );
166                @skiptests = @{$arg} if ( $option eq 'skiptests' );
167
168                next;
169            }
170
171            printf( "- %-${maxlen}s ...", $mod );
172
173            if ( $arg and $arg =~ /^\D/ ) {
174                unshift @$modules, $arg;
175                $arg = 0;
176            }
177
178            # XXX: check for conflicts and uninstalls(!) them.
179            my $cur = _load($mod);
180            if (_version_cmp ($cur, $arg) >= 0)
181            {
182                print "loaded. ($cur" . ( $arg ? " >= $arg" : '' ) . ")\n";
183                push @Existing, $mod => $arg;
184                $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
185            }
186            else {
187                if (not defined $cur)   # indeed missing
188                {
189                    print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n";
190                }
191                else
192                {
193                    # no need to check $arg as _version_cmp ($cur, undef) would satisfy >= above
194                    print "too old. ($cur < $arg)\n";
195                }
196
197                push @required, $mod => $arg;
198            }
199        }
200
201        next unless @required;
202
203        my $mandatory = ( $feature eq '-core' or $core_all );
204
205        if (
206            !$SkipInstall
207            and (
208                $CheckOnly
209                or ($mandatory and $UnderCPAN)
210                or $AllDeps
211                or _prompt(
212                    qq{==> Auto-install the }
213                      . ( @required / 2 )
214                      . ( $mandatory ? ' mandatory' : ' optional' )
215                      . qq{ module(s) from CPAN?},
216                    $default ? 'y' : 'n',
217                ) =~ /^[Yy]/
218            )
219          )
220        {
221            push( @Missing, @required );
222            $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
223        }
224
225        elsif ( !$SkipInstall
226            and $default
227            and $mandatory
228            and
229            _prompt( qq{==> The module(s) are mandatory! Really skip?}, 'n', )
230            =~ /^[Nn]/ )
231        {
232            push( @Missing, @required );
233            $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
234        }
235
236        else {
237            $DisabledTests{$_} = 1 for map { glob($_) } @tests;
238        }
239    }
240
241    if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) {
242        require Config;
243        print
244"*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n";
245
246        # make an educated guess of whether we'll need root permission.
247        print "    (You may need to do that as the 'root' user.)\n"
248          if eval '$>';
249    }
250    print "*** $class configuration finished.\n";
251
252    chdir $cwd;
253
254    # import to main::
255    no strict 'refs';
256    *{'main::WriteMakefile'} = \&Write if caller(0) eq 'main';
257}
258
259sub _running_under {
260    my $thing = shift;
261    print <<"END_MESSAGE";
262*** Since we're running under ${thing}, I'll just let it take care
263    of the dependency's installation later.
264END_MESSAGE
265    return 1;
266}
267
268# Check to see if we are currently running under CPAN.pm and/or CPANPLUS;
269# if we are, then we simply let it taking care of our dependencies
270sub _check_lock {
271    return unless @Missing or @_;
272
273    my $cpan_env = $ENV{PERL5_CPAN_IS_RUNNING};
274
275    if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) {
276        return _running_under($cpan_env ? 'CPAN' : 'CPANPLUS');
277    }
278
279    require CPAN;
280
281    if ($CPAN::VERSION > '1.89') {
282        if ($cpan_env) {
283            return _running_under('CPAN');
284        }
285        return; # CPAN.pm new enough, don't need to check further
286    }
287
288    # last ditch attempt, this -will- configure CPAN, very sorry
289
290    _load_cpan(1); # force initialize even though it's already loaded
291
292    # Find the CPAN lock-file
293    my $lock = MM->catfile( $CPAN::Config->{cpan_home}, ".lock" );
294    return unless -f $lock;
295
296    # Check the lock
297    local *LOCK;
298    return unless open(LOCK, $lock);
299
300    if (
301            ( $^O eq 'MSWin32' ? _under_cpan() : <LOCK> == getppid() )
302        and ( $CPAN::Config->{prerequisites_policy} || '' ) ne 'ignore'
303    ) {
304        print <<'END_MESSAGE';
305
306*** Since we're running under CPAN, I'll just let it take care
307    of the dependency's installation later.
308END_MESSAGE
309        return 1;
310    }
311
312    close LOCK;
313    return;
314}
315
316sub install {
317    my $class = shift;
318
319    my $i;    # used below to strip leading '-' from config keys
320    my @config = ( map { s/^-// if ++$i; $_ } @{ +shift } );
321
322    my ( @modules, @installed );
323    while ( my ( $pkg, $ver ) = splice( @_, 0, 2 ) ) {
324
325        # grep out those already installed
326        if ( _version_cmp( _load($pkg), $ver ) >= 0 ) {
327            push @installed, $pkg;
328        }
329        else {
330            push @modules, $pkg, $ver;
331        }
332    }
333
334    return @installed unless @modules;  # nothing to do
335    return @installed if _check_lock(); # defer to the CPAN shell
336
337    print "*** Installing dependencies...\n";
338
339    return unless _connected_to('cpan.org');
340
341    my %args = @config;
342    my %failed;
343    local *FAILED;
344    if ( $args{do_once} and open( FAILED, '.#autoinstall.failed' ) ) {
345        while (<FAILED>) { chomp; $failed{$_}++ }
346        close FAILED;
347
348        my @newmod;
349        while ( my ( $k, $v ) = splice( @modules, 0, 2 ) ) {
350            push @newmod, ( $k => $v ) unless $failed{$k};
351        }
352        @modules = @newmod;
353    }
354
355    if ( _has_cpanplus() and not $ENV{PERL_AUTOINSTALL_PREFER_CPAN} ) {
356        _install_cpanplus( \@modules, \@config );
357    } else {
358        _install_cpan( \@modules, \@config );
359    }
360
361    print "*** $class installation finished.\n";
362
363    # see if we have successfully installed them
364    while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
365        if ( _version_cmp( _load($pkg), $ver ) >= 0 ) {
366            push @installed, $pkg;
367        }
368        elsif ( $args{do_once} and open( FAILED, '>> .#autoinstall.failed' ) ) {
369            print FAILED "$pkg\n";
370        }
371    }
372
373    close FAILED if $args{do_once};
374
375    return @installed;
376}
377
378sub _install_cpanplus {
379    my @modules   = @{ +shift };
380    my @config    = _cpanplus_config( @{ +shift } );
381    my $installed = 0;
382
383    require CPANPLUS::Backend;
384    my $cp   = CPANPLUS::Backend->new;
385    my $conf = $cp->configure_object;
386
387    return unless $conf->can('conf') # 0.05x+ with "sudo" support
388               or _can_write($conf->_get_build('base'));  # 0.04x
389
390    # if we're root, set UNINST=1 to avoid trouble unless user asked for it.
391    my $makeflags = $conf->get_conf('makeflags') || '';
392    if ( UNIVERSAL::isa( $makeflags, 'HASH' ) ) {
393        # 0.03+ uses a hashref here
394        $makeflags->{UNINST} = 1 unless exists $makeflags->{UNINST};
395
396    } else {
397        # 0.02 and below uses a scalar
398        $makeflags = join( ' ', split( ' ', $makeflags ), 'UNINST=1' )
399          if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } );
400
401    }
402    $conf->set_conf( makeflags => $makeflags );
403    $conf->set_conf( prereqs   => 1 );
404
405
406
407    while ( my ( $key, $val ) = splice( @config, 0, 2 ) ) {
408        $conf->set_conf( $key, $val );
409    }
410
411    my $modtree = $cp->module_tree;
412    while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
413        print "*** Installing $pkg...\n";
414
415        MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall;
416
417        my $success;
418        my $obj = $modtree->{$pkg};
419
420        if ( $obj and _version_cmp( $obj->{version}, $ver ) >= 0 ) {
421            my $pathname = $pkg;
422            $pathname =~ s/::/\\W/;
423
424            foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) {
425                delete $INC{$inc};
426            }
427
428            my $rv = $cp->install( modules => [ $obj->{module} ] );
429
430            if ( $rv and ( $rv->{ $obj->{module} } or $rv->{ok} ) ) {
431                print "*** $pkg successfully installed.\n";
432                $success = 1;
433            } else {
434                print "*** $pkg installation cancelled.\n";
435                $success = 0;
436            }
437
438            $installed += $success;
439        } else {
440            print << ".";
441*** Could not find a version $ver or above for $pkg; skipping.
442.
443        }
444
445        MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall;
446    }
447
448    return $installed;
449}
450
451sub _cpanplus_config {
452	my @config = ();
453	while ( @_ ) {
454		my ($key, $value) = (shift(), shift());
455		if ( $key eq 'prerequisites_policy' ) {
456			if ( $value eq 'follow' ) {
457				$value = CPANPLUS::Internals::Constants::PREREQ_INSTALL();
458			} elsif ( $value eq 'ask' ) {
459				$value = CPANPLUS::Internals::Constants::PREREQ_ASK();
460			} elsif ( $value eq 'ignore' ) {
461				$value = CPANPLUS::Internals::Constants::PREREQ_IGNORE();
462			} else {
463				die "*** Cannot convert option $key = '$value' to CPANPLUS version.\n";
464			}
465		} else {
466			die "*** Cannot convert option $key to CPANPLUS version.\n";
467		}
468	}
469	return @config;
470}
471
472sub _install_cpan {
473    my @modules   = @{ +shift };
474    my @config    = @{ +shift };
475    my $installed = 0;
476    my %args;
477
478    _load_cpan();
479    require Config;
480
481    if (CPAN->VERSION < 1.80) {
482        # no "sudo" support, probe for writableness
483        return unless _can_write( MM->catfile( $CPAN::Config->{cpan_home}, 'sources' ) )
484                  and _can_write( $Config::Config{sitelib} );
485    }
486
487    # if we're root, set UNINST=1 to avoid trouble unless user asked for it.
488    my $makeflags = $CPAN::Config->{make_install_arg} || '';
489    $CPAN::Config->{make_install_arg} =
490      join( ' ', split( ' ', $makeflags ), 'UNINST=1' )
491      if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } );
492
493    # don't show start-up info
494    $CPAN::Config->{inhibit_startup_message} = 1;
495
496    # set additional options
497    while ( my ( $opt, $arg ) = splice( @config, 0, 2 ) ) {
498        ( $args{$opt} = $arg, next )
499          if $opt =~ /^force$/;    # pseudo-option
500        $CPAN::Config->{$opt} = $arg;
501    }
502
503    local $CPAN::Config->{prerequisites_policy} = 'follow';
504
505    while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
506        MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall;
507
508        print "*** Installing $pkg...\n";
509
510        my $obj     = CPAN::Shell->expand( Module => $pkg );
511        my $success = 0;
512
513        if ( $obj and _version_cmp( $obj->cpan_version, $ver ) >= 0 ) {
514            my $pathname = $pkg;
515            $pathname =~ s/::/\\W/;
516
517            foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) {
518                delete $INC{$inc};
519            }
520
521            my $rv = $args{force} ? CPAN::Shell->force( install => $pkg )
522                                  : CPAN::Shell->install($pkg);
523            $rv ||= eval {
524                $CPAN::META->instance( 'CPAN::Distribution', $obj->cpan_file, )
525                  ->{install}
526                  if $CPAN::META;
527            };
528
529            if ( $rv eq 'YES' ) {
530                print "*** $pkg successfully installed.\n";
531                $success = 1;
532            }
533            else {
534                print "*** $pkg installation failed.\n";
535                $success = 0;
536            }
537
538            $installed += $success;
539        }
540        else {
541            print << ".";
542*** Could not find a version $ver or above for $pkg; skipping.
543.
544        }
545
546        MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall;
547    }
548
549    return $installed;
550}
551
552sub _has_cpanplus {
553    return (
554        $HasCPANPLUS = (
555            $INC{'CPANPLUS/Config.pm'}
556              or _load('CPANPLUS::Shell::Default')
557        )
558    );
559}
560
561# make guesses on whether we're under the CPAN installation directory
562sub _under_cpan {
563    require Cwd;
564    require File::Spec;
565
566    my $cwd  = File::Spec->canonpath( Cwd::cwd() );
567    my $cpan = File::Spec->canonpath( $CPAN::Config->{cpan_home} );
568
569    return ( index( $cwd, $cpan ) > -1 );
570}
571
572sub _update_to {
573    my $class = __PACKAGE__;
574    my $ver   = shift;
575
576    return
577      if _version_cmp( _load($class), $ver ) >= 0;  # no need to upgrade
578
579    if (
580        _prompt( "==> A newer version of $class ($ver) is required. Install?",
581            'y' ) =~ /^[Nn]/
582      )
583    {
584        die "*** Please install $class $ver manually.\n";
585    }
586
587    print << ".";
588*** Trying to fetch it from CPAN...
589.
590
591    # install ourselves
592    _load($class) and return $class->import(@_)
593      if $class->install( [], $class, $ver );
594
595    print << '.'; exit 1;
596
597*** Cannot bootstrap myself. :-( Installation terminated.
598.
599}
600
601# check if we're connected to some host, using inet_aton
602sub _connected_to {
603    my $site = shift;
604
605    return (
606        ( _load('Socket') and Socket::inet_aton($site) ) or _prompt(
607            qq(
608*** Your host cannot resolve the domain name '$site', which
609    probably means the Internet connections are unavailable.
610==> Should we try to install the required module(s) anyway?), 'n'
611          ) =~ /^[Yy]/
612    );
613}
614
615# check if a directory is writable; may create it on demand
616sub _can_write {
617    my $path = shift;
618    mkdir( $path, 0755 ) unless -e $path;
619
620    return 1 if -w $path;
621
622    print << ".";
623*** You are not allowed to write to the directory '$path';
624    the installation may fail due to insufficient permissions.
625.
626
627    if (
628        eval '$>' and lc(`sudo -V`) =~ /version/ and _prompt(
629            qq(
630==> Should we try to re-execute the autoinstall process with 'sudo'?),
631            ((-t STDIN) ? 'y' : 'n')
632        ) =~ /^[Yy]/
633      )
634    {
635
636        # try to bootstrap ourselves from sudo
637        print << ".";
638*** Trying to re-execute the autoinstall process with 'sudo'...
639.
640        my $missing = join( ',', @Missing );
641        my $config = join( ',',
642            UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} )
643          if $Config;
644
645        return
646          unless system( 'sudo', $^X, $0, "--config=$config",
647            "--installdeps=$missing" );
648
649        print << ".";
650*** The 'sudo' command exited with error!  Resuming...
651.
652    }
653
654    return _prompt(
655        qq(
656==> Should we try to install the required module(s) anyway?), 'n'
657    ) =~ /^[Yy]/;
658}
659
660# load a module and return the version it reports
661sub _load {
662    my $mod  = pop;    # class/instance doesn't matter
663    my $file = $mod;
664
665    $file =~ s|::|/|g;
666    $file .= '.pm';
667
668    local $@;
669    return eval { require $file; $mod->VERSION } || ( $@ ? undef: 0 );
670}
671
672# Load CPAN.pm and it's configuration
673sub _load_cpan {
674    return if $CPAN::VERSION and $CPAN::Config and not @_;
675    require CPAN;
676    if ( $CPAN::HandleConfig::VERSION ) {
677        # Newer versions of CPAN have a HandleConfig module
678        CPAN::HandleConfig->load;
679    } else {
680    	# Older versions had the load method in Config directly
681        CPAN::Config->load;
682    }
683}
684
685# compare two versions, either use Sort::Versions or plain comparison
686# return values same as <=>
687sub _version_cmp {
688    my ( $cur, $min ) = @_;
689    return -1 unless defined $cur;  # if 0 keep comparing
690    return 1 unless $min;
691
692    $cur =~ s/\s+$//;
693
694    # check for version numbers that are not in decimal format
695    if ( ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./ ) {
696        if ( ( $version::VERSION or defined( _load('version') )) and
697             version->can('new')
698            ) {
699
700            # use version.pm if it is installed.
701            return version->new($cur) <=> version->new($min);
702        }
703        elsif ( $Sort::Versions::VERSION or defined( _load('Sort::Versions') ) )
704        {
705
706            # use Sort::Versions as the sorting algorithm for a.b.c versions
707            return Sort::Versions::versioncmp( $cur, $min );
708        }
709
710        warn "Cannot reliably compare non-decimal formatted versions.\n"
711          . "Please install version.pm or Sort::Versions.\n";
712    }
713
714    # plain comparison
715    local $^W = 0;    # shuts off 'not numeric' bugs
716    return $cur <=> $min;
717}
718
719# nothing; this usage is deprecated.
720sub main::PREREQ_PM { return {}; }
721
722sub _make_args {
723    my %args = @_;
724
725    $args{PREREQ_PM} = { %{ $args{PREREQ_PM} || {} }, @Existing, @Missing }
726      if $UnderCPAN or $TestOnly;
727
728    if ( $args{EXE_FILES} and -e 'MANIFEST' ) {
729        require ExtUtils::Manifest;
730        my $manifest = ExtUtils::Manifest::maniread('MANIFEST');
731
732        $args{EXE_FILES} =
733          [ grep { exists $manifest->{$_} } @{ $args{EXE_FILES} } ];
734    }
735
736    $args{test}{TESTS} ||= 't/*.t';
737    $args{test}{TESTS} = join( ' ',
738        grep { !exists( $DisabledTests{$_} ) }
739          map { glob($_) } split( /\s+/, $args{test}{TESTS} ) );
740
741    my $missing = join( ',', @Missing );
742    my $config =
743      join( ',', UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} )
744      if $Config;
745
746    $PostambleActions = (
747        ($missing and not $UnderCPAN)
748        ? "\$(PERL) $0 --config=$config --installdeps=$missing"
749        : "\$(NOECHO) \$(NOOP)"
750    );
751
752    return %args;
753}
754
755# a wrapper to ExtUtils::MakeMaker::WriteMakefile
756sub Write {
757    require Carp;
758    Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
759
760    if ($CheckOnly) {
761        print << ".";
762*** Makefile not written in check-only mode.
763.
764        return;
765    }
766
767    my %args = _make_args(@_);
768
769    no strict 'refs';
770
771    $PostambleUsed = 0;
772    local *MY::postamble = \&postamble unless defined &MY::postamble;
773    ExtUtils::MakeMaker::WriteMakefile(%args);
774
775    print << "." unless $PostambleUsed;
776*** WARNING: Makefile written with customized MY::postamble() without
777    including contents from Module::AutoInstall::postamble() --
778    auto installation features disabled.  Please contact the author.
779.
780
781    return 1;
782}
783
784sub postamble {
785    $PostambleUsed = 1;
786
787    return <<"END_MAKE";
788
789config :: installdeps
790\t\$(NOECHO) \$(NOOP)
791
792checkdeps ::
793\t\$(PERL) $0 --checkdeps
794
795installdeps ::
796\t$PostambleActions
797
798END_MAKE
799
800}
801
8021;
803
804__END__
805
806#line 1057
807