httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject Re: towards a 2.05-dev release
Date Sun, 24 Apr 2005 15:12:47 GMT
On Sat, 23 Apr 2005, Joe Schaefer wrote:

> Randy Kobes <randy@theoryx5.uwinnipeg.ca> writes:
>
> > On Sat, 23 Apr 2005, Joe Schaefer wrote:
> > [ ... ]
> >> What about the Makefile foo we talked about
> >> for the cpan client?
> >
> > I suppose one of the issues here is that the top-level
> > Makefile.PL calls ./configure, which then writes the
> > Makefile, whereas CPAN.pm likes to have Makefile generated
> > by ExtUtils::MakeMaker?
>
> Right. IIRC we discussed fudging that by putting some
> comments at the top of the generated Makefile.  I left
> some comment space at the top of Makefile.am; would that
> help any?

I forgot about that - you're right, I think that would
be enough to trick CPAN clients into following
prerequisites. At least for CPAN.pm, something like
=======================================================
#   MakeMaker Parameters:

#     PREREQ_PM => { BAR::FOO=>q[0.12], FOO::BAR=>q[0] }

# --- MakeMaker post_initialize section:

==============================================================
is looked for in the generated Makefile (up to the
"post_initialize" line), and if a PREREQ_PM string
is found, that's used to populate the prerequisities
list. So we could do something like the following
(the patch is longer than it looks, as I redid the
Win32 stuff to also test the prerequsites in the same
way):
==============================================================
Index: Makefile.PL
===================================================================
--- Makefile.PL	(revision 164473)
+++ Makefile.PL	(working copy)
@@ -8,51 +8,78 @@
 use constant PERL_PATH => $Config{perlpath}; # XXX
 use constant WIN32 => ($^O =~ /Win32/);

+my %prereqs;
+
 sub test_prereq {
-    system (PERL_PATH, "build/version_check.pl", @_) == 0
-        or die "Please upgrade $_[0] first.\n";
+    my $mod = shift;
+    my $cmd = join " ", PERL_PATH, "build/version_check.pl", $mod;
+    my $response = qx{$cmd};
+    print $response;
+    return if $response =~ / ok$/;
+    $response =~ /unsupported \((\S+) or/;
+    $prereqs{$mod} = $1;
 }

 test_prereq perl => PERL_PATH;

+my %opts;
+undef @opts{qw(with-apache2-apxs with-apache1-apxs with-apache2-src
+               with-perl with-apache2-httpd
+               with-apr-config with-apu-config apxs)};
 if (WIN32) {
-    push @ARGV, '--with-perl=' . PERL_PATH;
-    my @args = (PERL_PATH, 'win32/Configure.pl', @ARGV);
-    print "@args\n";
-    system(@args) == 0 or die "system @args failed: $?";
+    undef $opts{'with-apache2'};
 }
-else {
-    my %opts;
-    undef @opts{qw(with-apache2-apxs with-apache1-apxs with-apache2-src
-                   with-perl with-apache2-httpd
-                   with-apr-config with-apu-config apxs)};

-    my @flags = qw/enable-maintainer-mode enable-perl-glue disable-perl-glue/;
-    my %args;
-    # grab from @ARGV only the options that we expect
-    GetOptions(\%args, (map "$_=s", keys %opts), @flags);
+my @flags = qw/enable-maintainer-mode enable-perl-glue disable-perl-glue/;
+my %args;
+# grab from @ARGV only the options that we expect
+GetOptions(\%args, (map "$_=s", keys %opts), @flags);

-    $args{"with-perl"} = PERL_PATH;
-    my $opts = "";
-    $opts .= "--enable-maintainer-mode " if $args{"enable-maintainer-mode"};
+$args{"with-perl"} = PERL_PATH;
+my $opts = "";
+$opts .= "--enable-maintainer-mode " if $args{"enable-maintainer-mode"};

-    unless (exists $args{"disable-perl-glue"}) {
-        $opts .= "--enable-perl-glue ";
-        test_prereq "mod_perl";
-        test_prereq "Apache::Test";
-        test_prereq "ExtUtils::MakeMaker";
-        test_prereq "ExtUtils::XSBuilder";
-        test_prereq "Test::More";
-    }
+unless (exists $args{"disable-perl-glue"}) {
+    $opts .= "--enable-perl-glue ";
+    test_prereq "mod_perl";
+    test_prereq "Apache::Test";
+    test_prereq "ExtUtils::MakeMaker";
+    test_prereq "ExtUtils::XSBuilder";
+    test_prereq "Test::More";
+}

-    delete @args{@flags};
-    $args{"with-apache2-apxs"} = delete $args{apxs}
-        if exists $args{apxs} and not exists $args{"with-apache2-apxs"};
+delete @args{@flags};
+$args{"with-apache2-apxs"} = delete $args{apxs}
+    if exists $args{apxs} and not exists $args{"with-apache2-apxs"};

-    $args{"with-perl-opts"} = "@ARGV" if @ARGV;
+$args{"with-perl-opts"} = "@ARGV" if @ARGV;

+my @prereqs = map {"$_ => q[$prereqs{$_}]"} keys %prereqs;
+my $prereq_string = '';
+if (@prereqs) {
+    $prereq_string = 'PREREQ_PM => {' . (join ', ', @prereqs) . '}';
+}
+
+my $makefile_front =  <<"END";
+# This is a trick to get CPAN clients to follow prerequisites
+# Don't edit this file, edit Makefile.PL instead
+#
+#    ANY CHANGES HERE WILL BE LOST
+#
+#      $prereq_string
+#
+# --- MakeMaker post_initialize section:
+
+END
+
+if (WIN32) {
+    my @opts = map{qq/--$_="$args{$_}"/} keys %args;
+    my @args = (PERL_PATH, 'win32/Configure.pl', @opts);
+    print "@args\n";
+    system(@args) == 0 or die "system @args failed: $?";
+}
+else {
     $opts .= join " ", map {qq/--$_="$args{$_}"/} keys %args;
-
     my $cmd = "./configure $opts";
     print "$cmd\n";
     exec  $cmd;
Index: build/version_check.pl
===================================================================
--- build/version_check.pl	(revision 164481)
+++ build/version_check.pl	(working copy)
@@ -151,8 +151,11 @@
 $_ = 0 for @saw[@saw .. $#version]; # ensure @saw has enough entries
 for (0.. $#version) {
     last if $version[$_] < $saw[$_];
-    die <<EOM if $version[$_] > $saw[$_];
+    if ($version[$_] > $saw[$_]) {
+        print <<EOM;
 $0 failed: $tool version $saw unsupported ($version or greater is required).
 EOM
+        exit;
+    }
 }
 print "$tool: $saw ok\n";

========================================================================

Upon running 'perl Makefile.PL', $makefile_front is
available to add to the top of the generated Makefile. For
unix, would it work to create a 'Makefile.am.in' (being the
current Makefile.am), and then have Makefile.PL create a
Makefile.am consisting of $makefile_front, followed by
Makefile.am.in, and then run ./configure? If so, I'll do
this, and also do the corresponding thing for Win32.

-- 
best regards,
randy

Mime
View raw message