After thinkering about all the problems with my initial solutions
and looking a bit more closely at httpd's build system, I've come
up with a solution that doesn't involve any patching.

It would be used like this

$> perl Makefile.PL \
    MP_USE_STATIC=1 \
    MP_AP_CONFIGURE="--with-mpm=prefork --enable-debug [...]"
$> make

The Makefile.PL runs httpd's ./configure and enables mod_perl
The make command will build httpd first and then mod_perl (a required
order)

There are 2 small issues left that I can think of.

First, should make install also install httpd ? Or maybe use another
configurable option MP_AP_INSTALL=1 to control it

Second, right now, make test will only work if called like

$> make test APACHE_TEST_HTTPD=/path/to/httpd/src/httpd

I can't figure out how to pass this httpd location to t/TEST at
configure time to avoid this. Stas ?

Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.137
diff -u -I$Id -r1.137 Makefile.PL
--- Makefile.PL 4 Mar 2004 03:36:18 -0000       1.137
+++ Makefile.PL 6 May 2004 18:43:25 -0000
@@ -225,6 +225,10 @@
     #ModPerl::BuildMM will use Apache::BuildConfig in subdir/Makefile.PL's
     $build->save;

+    if ($build->do_httpd) {
+        $build->configure_httpd();
+    }
+
     ModPerl::TestRun->generate_script;
     ModPerl::TestReport->generate_script;
     Apache::TestSmokePerl->generate_script;
@@ -460,6 +464,11 @@
     my $self = shift;
     my $string = $self->ModPerl::BuildMM::MY::top_targets;

+    if ($build->do_httpd) {
+        ModPerl::MM::add_dep(\$string, pure_all => 'do_httpd');
+        $string .= qq[\ndo_httpd:\n\tcd "$build->{MP_AP_PREFIX}" && make\n];
+    }
+
     ModPerl::MM::add_dep(\$string, pure_all => 'modperl_lib');

     $string .= <<'EOF';
Index: lib/Apache/Build.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
retrieving revision 1.162
diff -u -I$Id -r1.162 Build.pm
--- lib/Apache/Build.pm 27 Apr 2004 17:26:28 -0000      1.162
+++ lib/Apache/Build.pm 6 May 2004 18:43:25 -0000
@@ -244,6 +244,33 @@
     return $self->{mpm_name} = $mpm_name;
 }

+sub do_httpd {
+    my ($self) = @_;
+    return $self->{MP_AP_CONFIGURE} ? 1 : 0;
+}
+
+sub configure_httpd {
+    my ($self) = @_;
+
+    debug "Configuring httpd in $self->{MP_AP_PREFIX}";
+
+    my $mplib = "$self->{MP_LIBNAME}$Config{lib_ext}";
+    my $mplibpath = catfile($self->{cwd}, qw(src modules perl), $mplib);
+
+    local $ENV{BUILTIN_LIBS} = $mplibpath;
+    local $ENV{AP_LIBS} = $self->ldopts;
+    local $ENV{MODLIST} = 'perl';
+
+    #XXX: -Wall and/or -Werror at httpd configure time breaks things
+    local $ENV{CFLAGS} = join ' ', grep { ! /\-Wall|\-Werror/ }
+        split /\s+/, $ENV{CFLAGS};
+
+    my $cd = qq(cd $self->{MP_AP_PREFIX});
+    my $cmd = qq(./configure $self->{MP_AP_CONFIGURE});
+    debug "Running $cmd";
+    system("$cd && $cmd") == 0 or die "httpd: $cmd failed";
+}
+
 #--- Perl Config stuff ---

 my %gtop_config = ();
Index: lib/ModPerl/BuildOptions.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/BuildOptions.pm,v
retrieving revision 1.26
diff -u -I$Id -r1.26 BuildOptions.pm
--- lib/ModPerl/BuildOptions.pm 4 Mar 2004 06:01:06 -0000       1.26
+++ lib/ModPerl/BuildOptions.pm 6 May 2004 18:43:25 -0000
@@ -220,6 +220,7 @@
 STATIC_EXTS    0    Build Apache::*.xs as static extensions
 APXS           0    Path to apxs
 AP_PREFIX      0    Apache installation or source tree prefix
+AP_CONFIGURE   0    Apache ./configure arguments
 APR_CONFIG     0    Path to apr-config
 XS_GLUE_DIR    1    Directories containing extension glue
 INCLUDE_DIR    1    Add directories to search for header files


-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to