perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject Re: [mp2] including a Win32 apxs?
Date Thu, 06 Nov 2003 15:30:54 GMT
On Thu, 6 Nov 2003, Stas Bekman wrote:

[...]
> > +sub fetch_apxs {
> > +    my $prefix = $build->{MP_AP_PREFIX};
>
> are you sure it's always set to a sensible value?

That's a good point - the diff below will check that.
Thanks.

> > +    return if -e catfile($prefix, 'bin', 'apxs.bat1');
>
> I sure don't know what I'm talking about but why 'bat1'?
> Shouldn't that be 'bat'?

Sorry about that - that was a remnant of testing things. It
should be '.bat'.

> the problem with the suggested build/fetch_win32_apxs.pl
> is that if the user wants to abort the install and start
> again it's going to be fetched again. I think
> fetch_win32_apxs.pl should just fetch and fetch_apxs()
> should return if it finds the files already. May be
> s/fetch_apxs/run_win32_apxs/ which will fetch the files if
> they weren't fetched already?

That's another good point - in the diff below, the .tar.gz
file won't be fetched again if it's already present. Also
below, I moved the messages formerly in Makefile.PL to the
fetch_win32_apxs.pl script.

=========================================================
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 15:26:32 -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,13 @@
 EOF
         }
     }
+}
+
+sub fetch_apxs {
+    my $prefix = $build->{MP_AP_PREFIX} || '';
+    my $script = catfile($build->{cwd}, 'build', 'fetch_win32_apxs.pl');
+    my @args = ($^X, $script, "--with-apache2=$prefix");
+    system(@args) == 0 or die "system @args failed: $?";
 }

 package MY;
Index: build/fetch_win32_apxs.pl
===================================================================
RCS file: build/fetch_win32_apxs.pl
diff -N build/fetch_win32_apxs.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ build/fetch_win32_apxs.pl	6 Nov 2003 15:26:33 -0000
@@ -0,0 +1,74 @@
+#!C:/Perl/bin/perl
+use strict;
+use warnings;
+use Getopt::Long;
+use File::Spec::Functions;
+use Archive::Tar;
+use File::Path;
+use LWP::Simple;
+use ExtUtils::MakeMaker qw(prompt);
+
+die "This is intended for Win32" unless ($^O =~ /Win32/i);
+
+my $prefix;
+GetOptions( 'with-apache2=s' => \$prefix);
+unless ($prefix and -d $prefix) {
+    die << 'END';
+
+I could not determine a valid Apache2 directory. Please
+run this script specifying the option
+   --with-apache2=/Path/to/Apache2
+where /Path/to/Apache2 is the location of your installed
+Apache2 top-level directory.
+
+END
+}
+
+exit 0 if (-e catfile($prefix, 'bin', 'apxs.bat'));
+
+print << 'END';
+
+I could not find an apxs utility, which will be used in certain parts
+of the build, if present. 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. You can either
+
+- ignore installing apxs by answering "no" at the prompt below
+  (mod_perl will still build),
+- install apxs by answering "yes" at the prompt below,
+- quit now, run the "fetch_win32_apxs.pl" script in the build/ directory
+  to fetch and install the utilities, and then rebuild mod_perl,
+- quit now, and from http://perl.apache.org/dist/win32-bin/ grab
+  apxs_win32.tar.gz; when unpacked, this contains a README explaining
+  how to install the utilities. Afterwards, rebuild mod_perl.
+
+END
+
+my $ans = prompt('Install apxs now?', 'yes');
+exit 0 unless $ans =~ /^y/i;
+
+my $file = 'apxs_win32.tar.gz';
+unless (-e $file) {
+    my $remote = 'http://perl.apache.org/dist/win32-bin/' . $file;
+    print "Fetching $remote ... ";
+    die "Download of $remote failed"
+        unless (is_success(getstore($remote, $file)));
+    print " done!\n";
+}
+
+my $dir = 'apxs';
+my $arc = Archive::Tar->new($file, 1);
+$arc->extract($arc->list_files());
+die "Unpacking $file failed" unless (-d $dir);
+
+print "chdir $dir\n";
+chdir $dir or die "chdir to $dir failed: $!";
+
+my @args = ($^X, 'Configure.pl', "--with-apache2=$prefix");
+print "@args\n";
+system(@args) == 0 or die "system @args failed: $?";
+
+chdir '..';
+#rmtree($dir, 1, 1) or warn "rmtree of $dir failed: $!";
+#print "unlink $file\n\n";
+#unlink $file or warn "unlink of $file failed: $!";

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

-- 
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