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 Fri, 07 Nov 2003 05:21:10 GMT
On Thu, 6 Nov 2003, Stas Bekman wrote:

> Randy Kobes wrote:
> very neat! A few more comments:
>
> > =========================================================
> > Index: Makefile.PL
> > ===================================================================
> [...]
> > +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: $?";
> >  }
>
> can you please call it win32_fetch_apxs, or fetch_apxs_win32, or similar and
> probably add a short comment before it explaining why is it needed.

Sure - that's done below.

> > +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 '..';
>
> just to avoid problems in the future it's the best to
> store cwd before chdir and at the end to chdir back to
> that stored $cwd, instead of hardcoding '..', so if later
> you decide to change 'apxs' with 'whatever/apxs' it'll
> still work just fine.

Good idea - thanks! Here's a reworked version:

==============================================================
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.130
diff -u -r1.130 Makefile.PL
--- Makefile.PL	7 Nov 2003 00:56:31 -0000	1.130
+++ Makefile.PL	7 Nov 2003 05:20: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,13 @@
 EOF
         }
     }
+}
+
+sub fetch_apxs {
+    my $prefix = $build->{MP_AP_PREFIX} || '';
+    my $script = catfile($build->{cwd}, 'build', 'win32_fetch_apxs');
+    my @args = ($^X, $script, "--with-apache2=$prefix");
+    system(@args) == 0 or die "system @args failed: $?";
 }

 package MY;
Index: build/win32_fetch_apxs
===================================================================
RCS file: build/win32_fetch_apxs
diff -N build/win32_fetch_apxs
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ build/win32_fetch_apxs	7 Nov 2003 05:20:51 -0000
@@ -0,0 +1,89 @@
+#!C:/Perl/bin/perl
+###################################################################
+# apxs, apr-config, and apu-config are Apache utilities used      #
+# to both get certain configuration information and also to       #
+# assist in building Apache modules. These utilities have not     #
+# yet been officially ported to Win32. The following will fetch   #
+# and install a development version of these scripts which can    #
+# be used in both mod_perl 2 and Apache C modules.                #
+#                                                                 #
+# Please report problems in installing or using these utilties to #
+# Randy Kobes <randy@theoryx5.uwinnipeg.ca>                       #
+###################################################################
+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);
+use Cwd;
+
+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 $cwd = getcwd;
+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 $cwd;
+#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