1
- # This -*- perl -*- script writes the Makefile for libwww-perl
1
+ # ! perl -w
2
2
3
- require 5.005 ;
3
+ require 5.006 ;
4
4
use strict;
5
- use ExtUtils::MakeMaker qw( WriteMakefile prompt) ;
6
- use Config qw( %Config) ;
7
-
8
- # --- Configuration section ---
9
-
10
- my @programs_to_install = qw( lwp-request lwp-mirror lwp-rget lwp-download) ;
11
- my @request_aliases = qw( GET HEAD POST) ;
12
-
13
- # --- End Configuration - You should not have to change anything below this line
14
-
15
-
16
- # Allow us to suppress all program installation with the -n (library only)
17
- # option. This is for those that don't want to mess with the configuration
18
- # section of this file.
19
- use Getopt::Std;
20
- use vars qw( $opt_n) ;
21
- unless (getopts(" n" )) {
22
- die " Usage: $0 [-n]\n " ;
23
- }
24
- @programs_to_install = () if $opt_n || grep /^LIB=/, @ARGV ;
25
-
26
- # Check if we should try to run tests that talk to ourself
27
- system (qq( "$^X" talk-to-ourself) );
28
- if ($? ) {
29
- print <<EOT ;
30
-
31
- You appear to have a misconfigured system, so I will disable tests
32
- that try to talk HTTP to a local server.
33
- EOT
34
- unlink (" t/CAN_TALK_TO_OURSELF" );
35
- }
36
- else {
37
- open (CAN_TALK_TO_OURSELF, " >t/CAN_TALK_TO_OURSELF" ) || die " Can't create CAN_TALK_TO_OURSELF: $! " ;
38
- close (CAN_TALK_TO_OURSELF);
39
- }
40
-
41
- # Check if we should try to run the live tests
42
- open (CHANGES, " Changes" ) || die " Can't open Changes: $! " ;
43
- my $release_date ;
44
- while (<CHANGES>) {
45
- if (/ ^(\d {4}-\d {2}-\d {2})\D / ) {
46
- $release_date = $1 ;
47
- last ;
48
- }
49
- }
50
- close (CHANGES);
51
- die " Can't figure out release date" unless $release_date ;
52
- # print "Release date: $release_date\n";
53
-
54
- my $some_time_ago = sprintf " %04d-%02d-%02d" ,
55
- sub { ($_ [5]+1900, $_ [4]+1, $_ [3])}-> (localtime (time - 45 * 24*60*60));
56
- if ($some_time_ago lt $release_date ) {
57
- # Check if we have internet connection
58
- require IO::Socket;
59
- my $s = IO::Socket::INET-> new(PeerAddr => " www.google.com:80" ,
60
- Timeout => 10,
61
- );
62
- if ($s ) {
63
- # XXX could try to send a GET to it???
64
- close ($s );
65
-
66
- print <<EOT ;
67
-
68
- You appear to be directly connected to the Internet. I have some tests
69
- that tries to access some sites on the net to verify that the new HTTP/1.1
70
- support works as it should.
71
-
72
- EOT
73
-
74
- if (prompt(" Do you want to enable these tests?" , " y" ) =~ / ^y/i ) {
75
- open (ENABLED, " >t/live/ENABLED" ) || die " Can't enable: $! " ;
76
- close (ENABLED);
77
- }
78
- else {
79
- unlink (" t/live/ENABLED" );
80
- }
81
- }
82
- }
83
-
84
- if (@programs_to_install ) {
85
- print <<EOT ;
86
-
87
- This package comes with some sample programs that I can try
88
- to install in $Config {installscript}.
89
-
90
- Note that you can avoid these questions by passing
91
- the '-n' option to 'Makefile.PL'.
92
-
93
- EOT
94
- my @tmp ;
95
- for (@programs_to_install ) {
96
- if (prompt(" Do you want to install $_ ?" , " y" ) =~ / ^y/ ) {
97
- push (@tmp , $_ );
98
- }
99
- }
100
- @programs_to_install = @tmp ;
101
- }
102
-
103
- if (grep ($_ eq ' lwp-request' , @programs_to_install ) && @request_aliases ) {
104
- print <<EOT ;
105
-
106
- The lwp-request program will use the name it is invoked with to
107
- determine what HTTP method to use. I can set up alias for the most
108
- common HTTP methods. These alias are also installed in
109
- $Config {installscript}.
110
-
111
- EOT
112
- my @tmp ;
113
- for my $alias (@request_aliases ) {
114
- my $default = " n" ;
115
- if (prompt(" Do you want to install the $alias alias?" , $default ) =~ / ^y/ ) {
116
- push (@tmp , $alias );
117
- }
118
- }
119
- @request_aliases = @tmp ;
120
- }
121
- else {
122
- @request_aliases = ();
123
- }
124
-
125
- if (@request_aliases ) {
5
+ use ExtUtils::MakeMaker qw( WriteMakefile) ;
6
+ use Getopt::Long qw( GetOptions) ;
7
+
8
+ GetOptions(\my %opt ,
9
+ ' aliases' ,
10
+ ' no-programs|n' ,
11
+ ' live-tests' ,
12
+ ) or do {
13
+ die " Usage: $0 [--aliases] [--no-programs] [--live-tests]\n " ;
14
+ };
15
+
16
+ my @prog ;
17
+ push (@prog , qw( lwp-request lwp-mirror lwp-rget lwp-download) )
18
+ unless $opt {' no-programs' } || grep /^LIB=/, @ARGV ;
19
+
20
+ if ($opt {' aliases' } && grep (/ lwp-request/ , @prog )) {
126
21
require File::Copy;
127
- for (@request_aliases ) {
22
+ for (qw( GET HEAD POST ) ) {
128
23
File::Copy::copy(" bin/lwp-request" , " bin/$_ " ) || die " Can't copy bin/$_ " ;
129
- chmod (0755, " bin/$_ " );
130
- push (@programs_to_install , $_ );
24
+ chmod (0755, " bin/$_ " );
25
+ push (@prog , $_ );
131
26
}
132
27
}
133
28
134
-
135
- # Ok, now it is time to really generate the Makefile
29
+ system ($^X, " talk-to-ourself" );
30
+ flag_file(" t/CAN_TALK_TO_OUTSELF" , $? == 0);
31
+ flag_file(" t/live/ENABLED" , $opt {' live-tests' });
136
32
137
33
WriteMakefile(
138
- NAME => ' LWP' ,
139
- DISTNAME => ' libwww-perl' ,
140
- VERSION_FROM => ' lib/LWP.pm' ,
141
- EXE_FILES => [ map " bin/$_ " , @programs_to_install ],
142
- PREREQ_PM => { ' URI ' => " 1.10 " ,
143
- ' MIME::Base64 ' => " 2.1 " ,
144
- ' Net::FTP ' => " 2.58 " ,
145
- ' HTML::Tagset ' => 0 ,
146
- ' HTML::Parser ' => " 3.33 " ,
147
- ' Digest::MD5 ' => 0 ,
148
- ' Compress::Zlib ' => " 1.10 " ,
149
- } ,
150
- ' clean ' => { FILES => join ( " " , map " bin/ $_ " , @request_aliases ) },
151
- ' dist ' => { COMPRESS => ' gzip -9f ' , SUFFIX => ' gz ' , },
34
+ NAME => ' LWP' ,
35
+ DISTNAME => ' libwww-perl' ,
36
+ VERSION_FROM => ' lib/LWP.pm' ,
37
+ EXE_FILES => [ map " bin/$_ " , @prog ],
38
+ PREREQ_PM => {
39
+ ' URI ' => " 1.10 " ,
40
+ ' MIME::Base64 ' => " 2.1 " ,
41
+ ' Net::FTP ' => " 2.58 " ,
42
+ ' HTML::Tagset ' => 0 ,
43
+ ' HTML::Parser ' => " 3.33 " ,
44
+ ' Digest::MD5 ' => 0 ,
45
+ ' Compress::Zlib ' => " 1.10 " ,
46
+ },
47
+ clean => { FILES => join ( " " , map " bin/ $_ " , grep /^[A-Z]+ $/ , @prog ) },
152
48
);
49
+ exit ;
153
50
154
51
155
-
156
- package MY ;
157
-
158
- # What happens when we say 'make test'
159
- sub test
52
+ sub MY ::test
160
53
{
161
54
q(
162
55
TEST_VERBOSE=0
@@ -168,22 +61,12 @@ test: all
168
61
}
169
62
170
63
171
- # Determine things that should *not* be installed
172
- sub libscan
173
- {
174
- my ($self , $path ) = @_ ;
175
- return ' ' if $path =~ m /\. (pl|dtd|sgml)$ / ;
176
- return ' ' if $path =~ m :\b CVS/: ;
177
- return ' ' if $path =~ m / ~$ / ;
178
- $path ;
179
- }
180
-
181
- # Pass libwww-perl version number to pod2man
182
- sub manifypods
183
- {
184
- my $self = shift ;
185
- my $ver = $self -> {VERSION } || " " ;
186
- local ($_ ) = $self -> SUPER::manifypods(@_ );
187
- s / pod2man\s *$/ pod2man --release libwww-perl-$ver / m ;
188
- $_ ;
64
+ sub flag_file {
65
+ my ($file , $create ) = @_ ;
66
+ if ($create ) {
67
+ open (my $fh , " >" , $file ) || die " Can't create $file : $! " ;
68
+ }
69
+ else {
70
+ unlink ($file );
71
+ }
189
72
}
0 commit comments