package Apache::Dispatch; require 5.005; use strict; use lib 'lib'; use Apache::Dispatch::Util; use ExtUtils::MakeMaker; my $HAS_APACHE_TEST = eval { require Apache::Test; require Apache::TestMM; Apache::TestMM->import(qw(test clean)); Apache::TestMM::filter_args(); my %args = @Apache::TestMM::Argv; return 0 unless ( ( Apache::TestConfig->can('custom_config_path') and -f Apache::TestConfig->custom_config_path() ) or $args{apxs} or $args{httpd} or $ENV{APACHE_TEST_HTTPD} or $ENV{APACHE_TEST_APXS} ); Apache::TestMM::generate_script('t/TEST'); return 1; }; sub MY::test { eval { require Test::More } or return <MM::clean(@_); } ## which mp version ( 1.2x or 2.0.x) my ( $mp_wanted, $mp_ver ) = &get_mp_ver(); print STDERR "Using mod_perl/$mp_ver\n\n"; my %prereq = (); my %makefile_params = ( 'VERSION' => '0.10_01', ); if ( $mp_wanted == 2 ) { # mod_perl2 specific makefile $prereq{'mod_perl2'} = 1.99023; # this covers the naming change $makefile_params{'NAME'} = 'Apache2::Dispatch'; $makefile_params{'PREREQ_PM'} = \%prereq; WriteMakefile(%makefile_params); } elsif ( $mp_wanted == 1 ) { # mod_perl1 specific makefile eval { require Apache::ExtUtils; require Apache::src; }; # Build directives using xs or PerlSetVar my $pureperl; if ( $@ || $ENV{DISPATCH_PUREPERL} ) { print "Building without Custom Apache Directives, use 'PerlSetVar' for configuration.\n\n"; $makefile_params{'PL_FILES'} = { 'set_pureperl.PL' => '1' }; $makefile_params{'C'} = []; } else { print "Building with Custom Apache Directives ('DispatchPrefix'). You will need a C compiler and Apache/mod_perl sources.\n\n"; $makefile_params{'PL_FILES'} = { 'set_pureperl.PL' => '0' }; $makefile_params{'clean'} = { FILES => '*.xs*' }; import Apache::ExtUtils qw(command_table); my @directives = Apache::Dispatch::Util->directives(); command_table( \@directives ); my $inc = Apache::src->new->inc; die "Can't find mod_perl header files installed" unless $inc; $makefile_params{'INC'} = $inc; } $makefile_params{'PREREQ_PM'} = { mod_perl => 1.2401 }; WriteMakefile( NAME => __PACKAGE__, PREREQ_PM => \%prereq, %makefile_params, ); } # The next sub inspired by Apache::Peek 1.05 sub get_mp_ver { my $at_ver; my %at_args; if ($HAS_APACHE_TEST) { %at_args = @Apache::TestMM::Argv; } elsif ( @ARGV ) { %at_args = @ARGV; $at_args{'httpd'} = $at_args{'-httpd'}; $at_args{'apxs'} = $at_args{'-apxs'}; } if ( $at_args{'apxs'} && $at_args{'httpd'} ) { # probably mp2 ($at_ver) = `$at_args{'httpd'} -v` =~ m!Apache\/(\d{1})!; if ( $at_ver == 1 ) { die <