Skip to content

Commit 8f4fd34

Browse files
committed
Simplify the Makefile.PL (no interactivity)
1 parent 3b5fc90 commit 8f4fd34

File tree

2 files changed

+58
-212
lines changed

2 files changed

+58
-212
lines changed

Makefile.PL

Lines changed: 48 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,55 @@
1-
# This -*- perl -*- script writes the Makefile for libwww-perl
1+
#!perl -w
22

3-
require 5.005;
3+
require 5.006;
44
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)) {
12621
require File::Copy;
127-
for (@request_aliases) {
22+
for (qw(GET HEAD POST)) {
12823
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, $_);
13126
}
13227
}
13328

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'});
13632

13733
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) },
15248
);
49+
exit;
15350

15451

155-
156-
package MY;
157-
158-
# What happens when we say 'make test'
159-
sub test
52+
sub MY::test
16053
{
16154
q(
16255
TEST_VERBOSE=0
@@ -168,22 +61,12 @@ test: all
16861
}
16962

17063

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:\bCVS/:;
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+
}
18972
}

README

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,28 @@ and functions that allow you to write WWW clients. The library also
1010
contain modules that are of more general use and even classes that
1111
help you implement simple HTTP servers.
1212

13-
There are actually two versions of libwww-perl: one for Perl4, and one
14-
for Perl5. Both have a similar architecture, loosely based on the CERN
15-
Library of Common Code (nowadays known as 'w3c-libwww').
16-
17-
The Perl4 version was maintained by Roy Fielding, and was the
18-
basis for tools such as MOMSpider. The perl4 version of libwww-perl
19-
and much more information about its libraries can still be found at:
20-
http://www.ics.uci.edu/pub/websoft/libwww-perl/
21-
22-
The Perl5 version (this package) is a complete rewrite for Perl5: the
23-
code is organized in Modules, provides an Object Oriented API, and
24-
offers lots of extended functionality.
25-
26-
2713

2814
PREREQUISITES
2915

3016
In order to install and use this package you will need Perl version
31-
5.005 or better. Some modules within this package depend on other
17+
5.6 or better. Some modules within this package depend on other
3218
packages that are distributed separately from Perl. We recommend that
3319
you have the following packages installed before you install
3420
libwww-perl:
3521

3622
URI
3723
MIME-Base64
24+
HTML-Tagset
3825
HTML-Parser
3926
libnet
4027
Digest-MD5
4128
Compress-Zlib
4229

43-
These packages should be available on CPAN (see below).
44-
4530
If you want to access sites using the https protocol, then you need to
4631
install the Crypt::SSLeay or the IO::Socket::SSL module. The
4732
README.SSL file will tell you more about how libwww-perl supports SSL.
4833

4934

50-
5135
INSTALLATION
5236

5337
You install libwww-perl using the normal perl module distribution drill:
@@ -57,29 +41,16 @@ You install libwww-perl using the normal perl module distribution drill:
5741
make test
5842
make install
5943

60-
You can edit the configuration section of Makefile.PL to select which
61-
programs to install in addition to the library itself. If you don't
62-
want to install any programs (only the library files) and don't want
63-
to mess with the Makefile.PL then pass the '-n' option to Makefile.PL:
64-
65-
perl Makefile.PL -n
66-
67-
If you want to install a private copy of libwww-perl in your home
68-
directory, then you should try to produce the initial Makefile with
69-
something like this command:
70-
71-
perl Makefile.PL LIB=~/perl
72-
73-
The Makefile.PL program will start out by checking your perl
74-
installation for a few packages that are recommended to be installed
75-
together with libwww-perl.
44+
If you don't want to install any programs (only the library files) then
45+
pass the '--no-programs' option to Makefile.PL:
7646

47+
perl Makefile.PL --no-programs
7748

7849

7950
DOCUMENTATION
8051

81-
See ./lib/LWP.pm for an overview of the library. See ./ChangeLog for
82-
recent changes.
52+
See the lib/LWP.pm file for an overview of the library. See the
53+
Changes file for recent changes.
8354

8455
POD style documentation is included in all modules and scripts. These
8556
are normally converted to manual pages and installed as part of the
@@ -88,18 +59,11 @@ utility to extract and read documentation from the module files
8859
directly.
8960

9061

91-
9262
SUPPORT
9363

94-
Questions about how to use this library should be directed to the
95-
comp.lang.perl.modules USENET Newsgroup. Bug reports and suggestions
96-
for improvements can be sent to the <[email protected]> mailing
97-
list. This mailing list is also the place for general discussions and
98-
development of the libwww-perl package.
99-
100-
You can join the mailing list by sending a message to
101-
102-
^^^^^^^^^^
64+
Bug reports and suggestions for improvements can be sent to the
65+
<[email protected]> mailing list. This mailing list is also the place
66+
for general discussions and development of the libwww-perl package.
10367

10468

10569
AVAILABILITY
@@ -118,7 +82,6 @@ You can also browse the git repository at:
11882
http://gitorious.org/projects/libwww-perl
11983

12084

121-
12285
COPYRIGHT
12386

12487
� 1995-2008 Gisle Aas. All rights reserved.

0 commit comments

Comments
 (0)