File: Makefile.PL

package info (click to toggle)
libmail-imapclient-perl 3.31-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,516 kB
  • sloc: perl: 20,436; makefile: 23
file content (156 lines) | stat: -rw-r--r-- 4,336 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
use ExtUtils::MakeMaker;
use warnings;
use strict;

use 5.008_001;

my @missing;
my %optional = (
    "Authen::NTLM"     => { for => "Authmechanism 'NTLM'" },
    "Authen::SASL"     => { for => "Authmechanism 'DIGEST-MD5'" },
    "Compress::Zlib"   => { for => "COMPRESS DEFLATE support" },
    "Digest::HMAC_MD5" => { for => "Authmechanism 'CRAM-MD5'" },
    "Digest::MD5"      => { for => "Authmechanism 'DIGEST-MD5'" },
    "IO::Socket::SSL"  => { for => "SSL enabled connections (Ssl => 1)" },
    "Test::Pod"        => { for => "Pod tests", ver => "1.00" },
);

foreach my $mod ( sort keys %optional ) {
    my $for = $optional{$mod}->{"for"} || "";
    my $ver = $optional{$mod}->{"ver"} || "";
    eval "use $mod $ver ();";
    push @missing, $mod . ( $for ? " for $for" : "" ) if $@;
}

# similar message to one used in DBI:
if (@missing) {
    print( "The following optional modules were not found:",
        map( "\n\t" . $_, @missing ), "\n" );

    print <<'MSG';
Optional modules are available from any CPAN mirror, reference:
  http://search.cpan.org/
  http://www.perl.com/CPAN/modules/by-module
  http://www.perl.org/CPAN/modules/by-module

MSG
    sleep 3;
}

WriteMakefile(
    NAME             => 'Mail::IMAPClient',
    AUTHOR           => 'Phil Pearl (Lobbes) <phil@zimbra.com>',
    ABSTRACT         => 'IMAP4 client library',
    VERSION_FROM     => 'lib/Mail/IMAPClient.pm',
    MIN_PERL_VERSION => '5.008',
    PREREQ_PM        => {
        'Carp'              => 0,
        'Errno'             => 0,
        'Fcntl'             => 0,
        'IO::File'          => 0,
        'IO::Select'        => 0,
        'IO::Socket'        => 0,
        'IO::Socket::INET'  => 1.26,
        'List::Util'        => 0,
        'MIME::Base64'      => 0,
        'Parse::RecDescent' => 1.94,
        'Test::More'        => 0,
        'File::Temp'        => 0,
    },
    clean => { FILES => 'test.txt' },
);

set_test_data();

exit 0;

###
### HELPERS
###

sub set_test_data {
    unless ( -f "lib/Mail/IMAPClient.pm" ) {
        warn "ERROR: not in installation directory\n";
        return;
    }

    return if -s "./test.txt";

    print <<'__INTRO';
You have the option of running an extended suite of tests during
'make test'. This requires an IMAP server name, user account, and
password to test with.

Note: this prompt will automatically timeout after 60 seconds.

__INTRO

    # HACK: alarm() allows broken interfaces to timeout gracefully...
    # - rt.cpan.org#57659: install fails when using cPanel GUI
    my $yes;
    eval {
        local $SIG{ALRM} = sub { die "alarm\n" };
        alarm(60);
        $yes = prompt "Do you want to run the extended tests? (n/y)";
        alarm(0);
    };
    print "\n" if $@;
    return unless ( $yes and $yes =~ /^y(?:es)?$/i );

    unless ( open TST, '>', "./test.txt" ) {
        warn "ERROR: couldn't open ./test.txt: $!\n";
        return;
    }

    my $server = "";
    until ($server) {
        $server =
            prompt "\nPlease provide the hostname or IP address of "
          . "a host running an\nIMAP server (or QUIT to skip "
          . "the extended tests)";
        chomp $server;
        return if $server =~ /^\s*quit\s*$/i;
    }

    print TST "server=$server\n";

    my $user = "";
    until ($user) {
        $user =
          prompt "\nProvide the username of an account on $server (or QUIT)";
        chomp $user;
        return if $user =~ /^\s*quit\s*$/i;
    }
    print TST "user=$user\n";

    my $passed = "";
    until ($passed) {
        $passed = prompt "\nProvide the password for $user (or QUIT)";
        chomp $passed;
        return if $passed =~ /^\s+$|^quit$/i;
    }

    print TST "passed=$passed\n";

    my $port = prompt "\nPlease provide the port to connect to on $server "
      . "to run the test\n(default is 143)";
    chomp $port;
    $port ||= 143;
    print TST "port=$port\n";

    my $authmech = prompt "\nProvide the authentication mechanism to use "
      . "on $server to\nrun the test (default is LOGIN)";

    chomp $authmech;
    $authmech ||= 'LOGIN';
    print TST "authmechanism=$authmech\n";
    close TST;

    print <<'__THANKS';

The information you provided (including the password!) has been stored
in test.txt and SHOULD BE REMOVED (either by hand or by 'make clean')
after testing.
__THANKS

}