Here is a new version of the static mod_perl build patch. I think it addresses all the problems raised by the previous one. It doesn't require patching httpd
at all anymore! So, here it is for comments[1]:

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 27 May 2004 17:08:36 -0000
@@ -225,6 +225,10 @@
     #ModPerl::BuildMM will use Apache::BuildConfig in subdir/Makefile.PL's
     $build->save;

+    if ($build->should_build_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->should_build_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: docs/user/install/install.pod
===================================================================
RCS file: /home/cvs/modperl-docs/src/docs/2.0/user/install/install.pod,v
retrieving revision 1.54
diff -u -I$Id -r1.54 install.pod
--- docs/user/install/install.pod       20 Apr 2004 01:59:57 -0000      1.54
+++ docs/user/install/install.pod       27 May 2004 17:08:36 -0000
@@ -383,28 +383,10 @@
 mod_perl is built once as I<mod_perl.a> and I<mod_perl.so>, but
 afterwards you can choose which of the two to use.

-META: The following is not implemented yet.
-
-  mod_perl and ends up with a src/modules/perl/mod_perl.{so,a} and
-  src/modules/perl/ldopts.  to link modperl static with httpd, we just
-  need some config.m4 magic to add `ldopts` and mod_perl.a to the build.
-  so one could then build httpd like so:
-
-  ln -s ~/apache/modperl-2.0/src/modules/perl $PWD/src/modules
-  ./configure --with-mpm=prefork --enable-perl=static ...
-
-  we not be configuring/building httpd for the user as 1.x attempted.
-
-  downside is one will need to have configured httpd first, so that
-  headers generated.  so it will probably be more like:
-
-  ./configure --with-mpm=prefork ...
-  (go build modperl)
-  ./config.nice --enable-perl=static && make
-
-  we could of course provide a wrapper script todo this, but don't want
-  to have this stuff buried and tangled like it is in 1.x
+=head4 MP_DO_HTTPD

+Configure and build httpd in C<MP_AP_PREFIX>, linking mod_perl statically
+to it.

 =head4 MP_STATIC_EXTS

@@ -549,6 +531,12 @@

   MP_OPTIONS_FILE=~/.my_mod_perl2_opts

+=head4 MP_AP_CONFIGURE
+
+The command-line arguments to pass to httpd's configure script.
+
+C<MP_AP_CONFIGURE> has no effect unless C<MP_DO_HTTPD> is also
+specified.


=head3 mod_perl-specific Compiler Options 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 27 May 2004 17:08:40 -0000 @@ -244,6 +244,47 @@ return $self->{mpm_name} = $mpm_name; }

+sub should_build_httpd {
+    my ($self) = @_;
+    return $self->{MP_DO_HTTPD} ? 1 : 0;
+}
+
+sub configure_httpd {
+    my ($self) = @_;
+
+    unless ($self->{MP_AP_CONFIGURE}) {
+        error "You specified MP_DO_HTTPD but did not specify the " .
+              "arguments to httpd's ./configure with MP_AP_CONFIGURE";
+        exit 1;
+    }
+
+    unless ($self->{MP_USE_STATIC}) {
+        error "When building httpd, you must set MP_USE_STATIC=1";
+        exit 1;
+    }
+
+    debug "Configuring httpd in $self->{MP_AP_PREFIX}";
+
+    my $httpd = File::Spec->catfile($self->{MP_AP_PREFIX}, 'httpd');
+    push @Apache::TestMM::Argv, ('-httpd' => $httpd);
+
+    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 27 May 2004 17:08:40 -0000
@@ -220,6 +220,8 @@
 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
+DO_HTTPD       0    Wether to build httpd
 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
Index: t/response/TestAPI/module.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestAPI/module.pm,v
retrieving revision 1.11
diff -u -I$Id -r1.11 module.pm
--- t/response/TestAPI/module.pm        7 May 2004 01:47:13 -0000       1.11
+++ t/response/TestAPI/module.pm        27 May 2004 17:08:40 -0000
@@ -87,7 +87,7 @@
     #.so
     {
         my $build = Apache::BuildConfig->new;
-        my $expect = $build->{MODPERL_LIB_SHARED} ? 1 : 0;
+        my $expect = $build->should_build_httpd ? 0 : 1;
         ok t_cmp($expect, Apache::Module::loaded('mod_perl.so'),
                  "Apache::Module::loaded('mod_perl.so')");
     }
Index: todo/release
===================================================================
RCS file: /home/cvs/modperl-2.0/todo/release,v
retrieving revision 1.27
diff -u -I$Id -r1.27 release
--- todo/release        26 May 2004 02:34:45 -0000      1.27
+++ todo/release        27 May 2004 17:08:40 -0000
@@ -46,15 +46,6 @@
   of child_exit.
   owner: stas

-* static build - if we make it working on OpenBSD, AIX and FreeBSD,
-  then it's not important to fix the DSO issues, otherwise make the
-  DSO issues in (todo/bugs_build) a release issue.
-  httpd-apreq-2 has recently implemented a static build support, we
-  could probably try to re-use some of the code that was written to do
-  that, though they use autoconf, which is not quite what we
-  want. Anyway it's something to look at.
-  owner: gozer
-
 * META.yml. Generate META.yml (make dist does that), add Apache-Test
   as a private resource, so it won't be attempted to be indexed by
   PAUSE, add NO_META=>1 to WriteMakefile() which tells EU::MM not to


[1]:http://svn.ectoplasm.org/gozer/opt/src/apache.org/mod_perl/2.0/patches/static-build.patch

--
--------------------------------------------------------------------------------
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

Attachment: signature.asc
Description: OpenPGP digital signature



Reply via email to