#!C:/Perl/bin/perl
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,
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
$prog
;
for
my
$trial
(
qw(Apache.exe httpd.exe)
) {
next
unless
-e File::Spec->catfile(
$prefix
,
'bin'
,
$trial
);
$prog
=
$trial
;
last
;
}
die
"Could not determine the Apache2 binary name"
unless
$prog
;
LWP::Simple->
import
(
qw(is_success getstore)
);
my
$file
=
'apxs_win32.tar.gz'
;
unless
(-e
$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"
,
"--with-apache-prog=$prog"
);
print
"@args\n"
;
system
(
@args
) == 0 or
die
"system @args failed: $?"
;
chdir
$cwd
;