perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject [mp2] including a Win32 apxs?
Date Thu, 06 Nov 2003 02:09:52 GMT
Hi,
  I was wondering how it would be felt to include an offer
in mp2 to get a Win32 version of apxs, if this was not
detected. There's a tar.gz archive on perl.apache.org that
contains this (plus apr-config and apu-config), so it would
be a matter of fetching and extracting this, then running
the included configure script to install. If this seems OK,
it'd be nice to detect the absence of apxs early on in the
build process so as the rest of the build can use the
installed scripts - the following diff does this for the
top-level Makefile.PL, but perhaps a better place is in
Apache::Build? Thanks.

========================================================
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.129
diff -u -r1.129 Makefile.PL
--- Makefile.PL	5 Nov 2003 09:52:18 -0000	1.129
+++ Makefile.PL	6 Nov 2003 01:57:50 -0000
@@ -44,6 +44,8 @@
 my $build = Apache::Build->new(init => 1);
 my $code  = ModPerl::Code->new;

+fetch_apxs() if WIN32;
+
 configure();
 perl_version_check($build);

@@ -418,6 +420,58 @@
 EOF
         }
     }
+}
+
+sub fetch_apxs {
+    my $prefix = $build->{MP_AP_PREFIX};
+    return if -e catfile($prefix, 'bin', 'apxs.bat');
+    print << 'END';
+
+I could not find an apxs utility on your system, which will
+be used in certain parts of the build, if available. This
+utility (and the apr-config and apu-config utilities) have not
+yet been ported to Apache2 on Win32, but a development port
+is available, which I can install for you, if you like.
+
+END
+
+    my $ans = $build->prompt('Install apxs?', 'yes');
+    return unless $ans =~ /^y/i;
+    require Archive::Tar; require Compress::Zlib;
+    require LWP::Simple; import LWP::Simple qw(is_success getstore);
+    require File::Path; import File::Path qw(rmtree);
+    my $file = 'apxs_win32.tar.gz';
+    my $remote = 'http://perl.apache.org/dist/win32-bin/' . $file;
+    print "Fetching $remote ... ";
+    unless (is_success(getstore($remote, $file))) {
+        warn "Download of $remote failed";
+        return;
+    }
+    print " done!\n";
+
+    my $arc = Archive::Tar->new($file, 1);
+    $arc->extract($arc->list_files());
+    my $dir = 'apxs';
+    unless (-d $dir) {
+        warn "Unpacking $file failed";
+        return;
+    }
+    print "chdir $dir\n";
+    chdir $dir or do {
+        warn "chdir to $dir failed: $!";
+        return;
+    };
+    my @args = ($^X, 'Configure.pl', "--with-apache2=$prefix");
+    print "@args\n";
+    system(@args) == 0 or do {
+        warn "system @args failed: $?";
+        return;
+    };
+    chdir '..';
+    rmtree($dir, 1, 1) or warn "rmtree of $dir failed: $!";
+    print "unlink $file\n\n";
+    unlink $file or warn "unlink of $file failed: $!";
+    return 1;
 }

 package MY;
===============================================================

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message