1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
use strict;
use warnings FATAL => 'all';
use Apache2;
use Apache::Build;
use constant WIN32 => Apache::Build::WIN32;
require Win32 if WIN32;
use Cwd;
my $cwd = WIN32 ?
Win32::GetLongPathName(cwd) : cwd;
$cwd =~ m{^(.+)/env$} or die "Can't find base directory";
my $base_dir = $1;
my $env_dir = "$base_dir/env";
my $env_dir_libs = WIN32 ?
"$base_dir/win32/libs" : "$env_dir/.libs";
use base 'Apache::TestRun';
$Apache::TestTrace::Level = 'debug';
main::->new->run(@ARGV);
sub pre_configure {
my $self = shift;
# Don't load an installed mod_apreq
Apache::TestConfig::autoconfig_skip_module_add('mod_apreq.c');
}
sub configure {
my $self = shift;
my $cfg = $self->{test_config};
$cfg->preamble(IfModule => '!mod_apreq.c',
qq(LoadModule apreq_module "$env_dir_libs/mod_apreq.so"\n));
bless $cfg, "My::TestConfig";
$self->SUPER::configure();
}
package My::TestConfig;
use Apache::TestTrace;
use Apache::TestConfigC;
use Config;
use Apache::Build;
use constant WIN32 => Apache::Build::WIN32;
use base 'Apache::TestConfig';
sub cmodules_httpd_conf {
my $self = shift;
debug "WRITING httpd.conf with " . join", ",map $_->{name},
@{$self->{cmodules}};
$self->SUPER::cmodules_httpd_conf(@_);
}
sub cmodules_write_makefile {
my($self, $mod) = @_;
my $dversion = $self->server->dversion;
my $name = $mod->{name};
my $makefile = "$mod->{dir}/Makefile";
debug "WRITING $makefile for $name";
my $lib = $self->cmodules_build_so($name);
my $fh = Symbol::gensym();
open $fh, ">$makefile" or die "open $makefile: $!";
if (WIN32) {
my @goners = map {$name . '.' . $_} qw(exp ilk lib pdb so lo);
print $fh <<EOF;
APXS=$self->{APXS}
all: $lib
$lib: $name.c
\$(APXS) -L../../../win32/libs -I../../../src -llibapreq2 -llibhttpd $dversion -p -I$self->{cmodules_dir} -c $name.c
clean:
-erase @goners vc60.pdb
EOF
}
else {
print $fh <<EOF;
APXS=$self->{APXS}
all: $lib
$lib: $name.c
\$(APXS) -L../../../src -I../../../src -lapreq2 $dversion -I$self->{cmodules_dir} -c $name.c
clean:
-rm -rf $name.o $name.lo $name.slo $name.la .libs
EOF
}
close $fh or die "close $makefile: $!";
}
sub cmodules_makefile_vars {
my $make = $ENV{MAKE} || $Config{make};
return <<EOF; # XXX: do we need to propagate all the vars in config.nice?
MAKE=$make
EOF
}
sub cmodules_make {
my $self = shift;
my $targ = shift || 'all';
my $make = $ENV{MAKE} || $Config{make};
my $cmd = "cd $self->{cmodules_dir} && $make $targ";
debug $cmd;
system $cmd;
if ($?) {
die "Failed to build c-modules";
}
}
|