1 # This -*- perl -*- script writes the Makefile for libwww-perl
5 use ExtUtils::MakeMaker qw(WriteMakefile prompt);
6 use Config qw(%Config);
8 #--- Configuration section ---
10 my @programs_to_install = qw(lwp-request lwp-mirror lwp-rget lwp-download);
11 my @request_aliases = qw(GET HEAD POST);
13 #--- End Configuration - You should not have to change anything below this line
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.
21 unless (getopts("n")) {
22 die "Usage: $0 [-n]\n";
24 @programs_to_install = () if $opt_n || grep /^LIB=/, @ARGV;
26 # Check if we should try to run tests that talk to ourself
27 system(qq("$^X" talk-to-ourself));
31 You appear to have a misconfigured system, so I will disable tests
32 that try to talk HTTP to a local server.
34 unlink("t/CAN_TALK_TO_OURSELF");
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);
41 # Check if we should try to run the live tests
42 open(CHANGES, "Changes") || die "Can't open Changes: $!";
45 if (/^(\d{4}-\d{2}-\d{2})\D/) {
51 die "Can't figure out release date" unless $release_date;
52 #print "Release date: $release_date\n";
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
59 my $s = IO::Socket::INET->new(PeerAddr => "www.google.com:80",
63 # XXX could try to send a GET to it???
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.
74 if (prompt("Do you want to enable these tests?", "y") =~ /^y/i) {
75 open(ENABLED, ">t/live/ENABLED") || die "Can't enable: $!";
78 # Figure out if the compress lib works and signal that with
79 # a file for the test suite to find. We don't want the
80 # test script to do this 'require' itself because we want
81 # to test that the module loads it on demand as it should.
83 require Compress::Zlib;
84 Compress::Zlib->VERSION(1.10);
85 open(ZLIB_OK, ">t/live/ZLIB_OK") || die "Can't create ZLIB_OK: $!";
86 print ZLIB_OK "$Compress::Zlib::VERSION\n";
91 unlink("t/live/ZLIB_OK");
95 unlink("t/live/ENABLED");
100 if (@programs_to_install) {
103 This package comes with some sample programs that I can try
104 to install in $Config{installscript}.
106 Note that you can avoid these questions by passing
107 the '-n' option to 'Makefile.PL'.
111 for (@programs_to_install) {
112 if (prompt("Do you want to install $_?", "y") =~ /^y/) {
116 @programs_to_install = @tmp;
119 if (grep($_ eq 'lwp-request', @programs_to_install) && @request_aliases) {
122 The lwp-request program will use the name it is invoked with to
123 determine what HTTP method to use. I can set up alias for the most
124 common HTTP methods. These alias are also installed in
125 $Config{installscript}.
129 for my $alias (@request_aliases) {
131 if (prompt("Do you want to install the $alias alias?", $default) =~ /^y/) {
135 @request_aliases = @tmp;
138 @request_aliases = ();
141 # Check for non-standard modules that are used by this library.
143 my $missing_modules = 0;
145 print "\nChecking for URI...........";
155 The URI module must be installed. WWW without URIs would not
159 sleep(2); # Don't hurry too much
164 print "Checking for HTML::Parser..";
166 require HTML::HeadParser;
167 HTML::Parser->VERSION(3.33);
174 The HTML::Parser is needed to extract correct base URI information from
175 HTML so that we can resolve relative links correctly. The HTML::Form
176 module also needs HTML::TokeParser to work.
179 sleep(2); # Don't hurry too much
185 print "Checking for MIME::Base64..";
187 require MIME::Base64;
188 #MIME::Base64->VERSION('2.00');
195 The Base64 encoding is used in authentication headers in HTTP.
198 sleep(2); # Don't hurry too much
204 print "Checking for Net::FTP......";
207 Net::FTP->VERSION('2.58');
214 The libwww-perl library normally use the Net::FTP module when
215 accessing ftp servers. You would have to install this package or
216 configure your application to use a proxy server for making ftp
217 requests work. Net::FTP is part of the 'libnet' distribution.
220 sleep(2); # Don't hurry too much
226 print "Checking for Digest::MD5 ..";
235 The Digest::MD5 library is needed if you want to be able use the
236 experimental "Digest Access Authentication" scheme. Since very few
237 servers implement this authentication scheme, you should normally not
238 worry too much about this.
246 print <<EOT if $missing_modules;
247 The missing modules can be obtained from CPAN. Visit
248 <URL:http://www.perl.com/CPAN/> to find a CPAN site near you.
254 if (@request_aliases) {
256 for (@request_aliases) {
257 File::Copy::copy("bin/lwp-request", "bin/$_") || die "Can't copy bin/$_";
258 chmod(0755, "bin/$_");
259 push(@programs_to_install, $_);
264 # Ok, now it is time to really generate the Makefile
268 DISTNAME => 'libwww-perl',
269 VERSION_FROM => 'lib/LWP.pm',
270 EXE_FILES => [ map "bin/$_", @programs_to_install ],
271 PREREQ_PM => { 'URI' => "1.10",
272 'MIME::Base64' => "2.1",
273 'Net::FTP' => "2.58",
275 'HTML::Parser' => "3.33",
277 'Compress::Zlib' => "1.10",
279 'clean' => { FILES => join(" ", map "bin/$_", @request_aliases) },
280 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
287 # What happens when we say 'make test'
294 $(FULLPERL) t/TEST $(TEST_VERBOSE)
300 # Determine things that should *not* be installed
303 my($self, $path) = @_;
304 return '' if $path =~ m/\.(pl|dtd|sgml)$/;
305 return '' if $path =~ m:\bCVS/:;
306 return '' if $path =~ m/~$/;
310 # Pass libwww-perl version number to pod2man
314 my $ver = $self->{VERSION} || "";
315 local($_) = $self->SUPER::manifypods(@_);
316 s/pod2man\s*$/pod2man --release libwww-perl-$ver/m;