Stas Bekman wrote:
Philippe M. Chiasson wrote:

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


Looks too easy :)


I know...

Index: Makefile.PL

[...]

+    if ($build->should_build_httpd) {
+        ModPerl::MM::add_dep(\$string, pure_all => 'do_httpd');


you've changed the function name but not the make target (do_httpd)

Noted.


+=head4 MP_DO_HTTPD


and here.

I suggest: build_httpd and MP_BUILD_HTTPD

Does sound better.


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


May be it's better if it matches the build name? but I guess it's fine.

Not sure what you mean there.

More over we have this AP vs httpd thing. May be it'll be more consistent if we use Apache everywhere?

$build->should_build_apache
build_apache make target
=head4 MP_BUILD_APACHE
=head4 MP_AP_CONFIGURE

Another set could be:

$build->should_build_apache
ap_build make target
=head4 MP_AP_BUILD
=head4 MP_AP_CONFIGURE

?

Here is a revised patch that still works for me. (http://svn.ectoplasm.org/gozer/opt/src/apache.org/mod_perl/2.0/patches/static-build.patch)

# $Id: static-build.patch 173 2004-06-14 21:50:02Z gozer $

This finally enables linking mod_perl statically into httpd.

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 14 Jun 2004 21:49:39 -0000
@@ -225,6 +225,10 @@
     #ModPerl::BuildMM will use Apache::BuildConfig in subdir/Makefile.PL's
     $build->save;

+    if ($build->should_build_apache) {
+        $build->configure_apache();
+    }
+
     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_apache) {
+        ModPerl::MM::add_dep(\$string, pure_all => 'ap_build');
+        $string .= qq[\nap_build:\n\tcd "$build->{MP_AP_PREFIX}" && make\n];
+    }
+
     ModPerl::MM::add_dep(\$string, pure_all => 'modperl_lib');

     $string .= <<'EOF';
Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.225
diff -u -I$Id -r1.225 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm        31 May 2004 03:49:40 -0000      1.225
+++ Apache-Test/lib/Apache/TestConfig.pm        14 Jun 2004 21:49:39 -0000
@@ -936,6 +936,7 @@
     # untaint some %ENV fields
     local @ENV{ qw(PATH IFS CDPATH ENV BASH_ENV) };

+    $ENV{PATH} = '/bin:/usr/bin:/usr/local/bin';
     my $handle = Symbol::gensym();
     open $handle, "$cmd|" or die "$cmd failed: $!";

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       14 Jun 2004 21:49:39 -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_AP_BUILD

+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_AP_BUILD> 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 14 Jun 2004 21:49:39 -0000 @@ -244,6 +244,47 @@ return $self->{mpm_name} = $mpm_name; }

+sub should_build_apache {
+    my ($self) = @_;
+    return $self->{MP_AP_BUILD} ? 1 : 0;
+}
+
+sub configure_apache {
+    my ($self) = @_;
+
+    unless ($self->{MP_AP_CONFIGURE}) {
+        error "You specified MP_AP_BUILD 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 14 Jun 2004 21:49:39 -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
+AP_BUILD       0    Whether 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        14 Jun 2004 21:49:39 -0000
@@ -87,7 +87,7 @@
     #.so
     {
         my $build = Apache::BuildConfig->new;
-        my $expect = $build->{MODPERL_LIB_SHARED} ? 1 : 0;
+        my $expect = $build->should_build_apache ? 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.29
diff -u -I$Id -r1.29 release
--- todo/release        9 Jun 2004 14:46:22 -0000       1.29
+++ todo/release        14 Jun 2004 21:49:39 -0000
@@ -55,15 +55,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


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