Author: particle
Date: Wed Jul 20 13:28:15 2005
New Revision: 173
Modified:
mod_parrot/branches/particle-win32/Configure.pl
mod_parrot/branches/particle-win32/Makefile.in
Log:
beginning the march towards windows builds... starting with a more robust Configure.pl
Modified: mod_parrot/branches/particle-win32/Configure.pl
==============================================================================
--- mod_parrot/branches/particle-win32/Configure.pl (original)
+++ mod_parrot/branches/particle-win32/Configure.pl Wed Jul 20 13:28:15 2005
@@ -1,107 +1,345 @@
-# $Id$
+#!perl -w
+#$Id$
# Copyright (c) 2004 Jeff Horwitz
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+
+=head1 NAME
+
+Configure.pl - mod_parrot's Configuration Script
+
+=head1 SYNOPSIS
+
+ % perl Configure.pl [options]
+
+=head1 DESCRIPTION
+
+This is mod_parrot's configuration script. It should be run to create the
+necessary system-specific files before building mod_parrot.
+
+=head2 Command-line Options
+
+General Options
+
+=over
+
+=item C<--help>
+
+Prints out a description of the options and exits.
+
+=item C<--version>
+
+Prints out the version number of Configure.pl and exits.
+
+=item C<--verbose>
+
+Tells Configure.pl to output extra information about the configuration
+data it is setting.
+
+=item C<--prefix>
+
+Sets the location where mod_parrot will be installed.
+
+=item C<--ask>
+
+This turns on the user prompts.
+
+=back
+
+Compile Options
+
+=over
+
+=item C<--debugging=0>
+
+Debugging is turned on by default. Use this to disable it.
+
+=back
+
+mod_parrot Options
+
+=over
+
+=item C<--parrot-build-dir=(dir)>
+
+Specify the parrot build directory. Defaults to '../parrot'.
+
+=item C<--apxs=(file)>
+
+Specify the location of apxs. Defaults to '/usr/local/apache/bin/apxs'.
+
+=item C<--perl=(file)>
+
+Specify the location of perl. Defaults to '$^X'.
+
+=back
+
+=head1 LICENSE
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+=cut
# mod_parrot configuration script
+# parts stolen from mod_perl (some modified)
+
+use 5.005_02;
+
+use strict;
+use vars qw(%args $VERSION);
+$|++;
+
+my $VERSION = '0.3';
use Getopt::Long;
-# parts stolen from mod_perl
-my %threaded_mpms = map { $_ => 1}
- qw(worker winnt beos mpmt_os2 netware leader perchild threadpool);
-sub mpm_is_threaded
+## define configuration steps
+my @steps= qw(
+ discover_apache_include_dir
+ discover_mpm
+ config_for_mpm
+ set_cflags
+ set_ldflags
+ set_libs
+ generate_makefile
+ create_test_infrastructure
+);
+
+## handle options
+my %args = ();
+
+## set option defaults
+$args{debugging} = 1;
+$args{parrot_build_dir} = '../parrot';
+$args{apxs} = '/usr/local/apache/bin/apxs';
+$args{perl} = $^X;
+
+for( @ARGV ) {
+ GetOptions( \%args,
+ qw( help version verbose prefix ask ),
+ 'debugging=i',
+ 'parrot-build-dir=s',
+ 'axps=s',
+ 'perl=s',
+ ) or die "error while parsing options: $!";
+}
+
+## general option code
+$args{help} and do {
+ print <<"HELP";
+$0 - mod_parrot Configure $VERSION
+
+General Options:
+
+ --help Show this text
+ --version Show version information
+ --verbose Output extra information
+ --prefix Set the installation prefix
+ --ask Have Configure ask for commonly-changed info
+
+Compile Options:
+ --debugging=0 Disable debugging, default = 1
+
+mod_parrot Options:
+ --parrot-build-dir=(dir) Set the parrot build directory
+ --apxs=(file) Set the location of apxs
+ --perl=(file) Set the location of perl
+HELP
+ exit;
+};
+
+$args{version} and do {
+ my $svnid = '$Id$';
+ print <<"VERSION";
+mod_parrot Configure $VERSION
+$svnid
+VERSION
+ exit;
+};
+
+
+## start configuring
+print <<"HELLO";
+mod_parrot Configure $VERSION
+Copyright (c) 2004 Jeff Horwitz
+
+Hello, I'm Configure. My job is to poke and prod your system to
+figure out how to build mod_parrot. The process is completely
+automated, unless you passed in the `--ask' flag on the command
+line, in which case it'll prompt you for a few pieces of info.
+
+Since you're running this script, you obviously have Perl 5;
+I'll be pulling some defaults from its configuration.
+HELLO
+
+## run the actual steps
+runsteps( %args );
+
+print <<"BYE";
+
+Okay, we're done!
+
+You can now use `make' (or your platform's equivalent to `make') to build
+your mod_parrot. After that, you can use `make test' to run the test suite.
+
+BYE
+
+
+
+exit(0);
+
+
+
+# where are apache includes?
+sub discover_apache_include_dir
{
- return $threaded_mpms{$_[0]};
+ warn "axps: <$args{axps}>\n";
+ $args{apache_include_dir} = qx|$args{apxs} -q INCLUDEDIR|
+ or die "couldn't find apache include dir";
}
-my $parrot_build_dir = '../parrot';
-my $apxs = '/usr/local/apache/bin/apxs';
-my $perl = $^X;
-my $res = GetOptions(
- 'parrot-build-dir=s' => \$parrot_build_dir,
- 'apxs=s' => \$apxs
-);
+# discover mpm -- we don't use this yet, but we might
+sub discover_mpm
+{
+ my $mpm = `$args{apxs} -q MPM_NAME`
+ or die "Couldn't find Apache MPM";
+ chomp($mpm);
+ $args{mpm} = $mpm;
+}
+
+
+sub config_for_mpm { print "\nConfiguring mod_parrot for $args{mpm} MPM.\n"; }
+
+
+sub set_cflags
+{
+ my $cflags = " -I$args{parrot_build_dir}/include";
+ $cflags .= ' -DMPM_IS_THREADED'
+ if( mpm_is_threaded($args{mpm}) );
+ $args{cflags} = $cflags;
+}
+
+
+sub set_ldflags
+{
+ $args{ldflags} =
+ parrot_config('ldflags') . " -L$args{parrot_build_dir}/blib/lib";
+}
+
+
+sub set_libs { $args{libs} = parrot_config('libs') . ' -lparrot'; }
+
+
+sub generate_makefile
+{
+ print "Generating Makefile...";
+ my $template;
+ {
+ open(MAKEFILE_IN, "Makefile.in") or die $!;
+ local $/;
+ $template = <MAKEFILE_IN>;
+ close(MAKEFILE_IN);
+ }
+
+ my @vars= sort { length $a <=> length $b }
+ qw( cflags ldflags libs apxs perl
+ parrot_source parrot apache_include_dir );
+
+ for my $token ( @vars )
+ {
+ $template =~ s/(?gx) \@ uc($token) \@ /$args{lc($token)}/;
+ }
+# $template =~ s/\@CFLAGS\@/$args{cflags}/g;
+# $template =~ s/\@LDFLAGS\@/$args{ldflags}/g;
+# $template =~ s/\@LIBS\@/$args{libs}/g;
+# $template =~ s/\@APXS\@/$args{apxs}/g;
+# $template =~ s/\@PERL\@/$args{perl}/g;
+# $template =~ s/\@PARROT_SOURCE\@/$args{parrot_build_dir}/g;
+# $template =~ s/\@PARROT\@/$args{parrot_build_dir}\/parrot/g;
+# $template =~ s/\@APACHE_INCLUDE_DIR\@/$args{apache_include_dir}/g;
+ open(MAKEFILE, ">Makefile") or die $!;
+ print MAKEFILE $template;
+ close(MAKEFILE);
+ print "done.\n";
+}
+
+=for comment
+
+sub create_test_infrastructure
+{
+ print "Creating testing infrastructure...";
+ eval {use Apache::TestConfig; use Apache::TestRun;};
+ print "missing Apache::Test -- SKIPPING\n", next if $@;
+
+ # don't use installed mod_parrot
+ package ModParrot::TestRun;
+ use base Apache::TestRun;
+ use Apache::TestConfig;
+
+ sub pre_configure
+ {
+ my $self = shift;
+ Apache::TestConfig::autoconfig_skip_module_add('mod_parrot.c');
+ $self->SUPER::pre_configure();
+ }
+
+ package main;
+ use Apache::TestMM;
+ push(@ARGV, '-apxs', $args{apxs});
+ Apache::TestMM::filter_args();
+ ModParrot::TestRun->generate_script();
+ print "done.\n";
+}
+
+=cut
+
+sub mpm_is_threaded
+{
+ grep { $_[0] eq $_ }
+ qw(worker winnt beos mpmt_os2 netware leader perchild threadpool);
+}
-$res || die "error while parsing options";
sub parrot_config
{
my $config = shift;
- my $value = `cd $parrot_build_dir; ./parrot parrot-config.imc $config`;
+ my $value =
+ `cd $args{parrot_build_dir}; ./parrot parrot-config.imc $config`;
chomp($value);
return $value;
}
-$| = 1;
-# where are apache includes?
-my $apache_include_dir = `$apxs -q INCLUDEDIR`;
+sub runsteps
+{
+ my( %args ) = @_;
-# discover mpm -- we don't use this yet, but we might
-my $mpm = `$apxs -q MPM_NAME`;
-$mpm or die "Couldn't find Apache MPM";
-chomp($mpm);
-print "\nConfiguring mod_parrot for $mpm MPM.\n";
-
-# we can't use the config verbatim -- apxs chokes on it, so we use what we can
-my $cflags = " -I$parrot_build_dir/include";
-$cflags .= " -DMPM_IS_THREADED" if (mpm_is_threaded($mpm));
-my $ldflags = parrot_config('ldflags') . " -L$parrot_build_dir/blib/lib";
-my $libs = parrot_config('libs') . ' -lparrot';
-
-print "Generating Makefile...";
-my $template;
-{
- open(MAKEFILE_IN, "Makefile.in") or die $!;
- local $/;
- $template = <MAKEFILE_IN>;
- close(MAKEFILE_IN);
-}
-$template =~ s/\@CFLAGS\@/$cflags/g;
-$template =~ s/\@LDFLAGS\@/$ldflags/g;
-$template =~ s/\@LIBS\@/$libs/g;
-$template =~ s/\@APXS\@/$apxs/g;
-$template =~ s/\@PERL\@/$perl/g;
-$template =~ s/\@PARROT_SOURCE\@/$parrot_build_dir/g;
-$template =~ s/\@PARROT\@/$parrot_build_dir\/parrot/g;
-$template =~ s/\@APACHE_INCLUDE_DIR\@/$apache_include_dir/g;
-open(MAKEFILE, ">Makefile") or die $!;
-print MAKEFILE $template;
-close(MAKEFILE);
-print "done.\n";
-
-# don't use installed mod_parrot
-package ModParrot::TestRun;
-use base Apache::TestRun;
-use Apache::TestConfig;
-
-sub pre_configure
-{
- my $self = shift;
- Apache::TestConfig::autoconfig_skip_module_add('mod_parrot.c');
- $self->SUPER::pre_configure();
-}
-
-package main;
-use Apache::TestMM;
-print "Creating testing infrastructure...";
-push(@ARGV, '-apxs', $apxs);
-Apache::TestMM::filter_args();
-ModParrot::TestRun->generate_script();
-print "done.\n";
+ local $SIG{__WARN__} = sub {
+ warn $_[0] unless $_[0] =~ /^Subroutine runstep redefined at config/
+ };
+
+ my $verbose = $args{verbose};
+ my $n = 0;
-print "\nType 'make' to build mod_parrot.\n\n";
+ for (@steps) {
+ no strict 'refs';
+
+# die "<($_): " . ref( *{'__PACKAGE__' . $_} ) . '>';
+# die "No $_" unless 'CODE' eq ref *{'__PACKAGE__::' . $_};
+
+ print "performing $_...";
+ &$_();
+ print "done\n";
+ }
+}
Modified: mod_parrot/branches/particle-win32/Makefile.in
==============================================================================
--- mod_parrot/branches/particle-win32/Makefile.in (original)
+++ mod_parrot/branches/particle-win32/Makefile.in Wed Jul 20 13:28:15 2005
@@ -8,7 +8,7 @@ LIBS=@LIBS@
PERL=@PERL@
APXS=@APXS@
PARROT_SOURCE=@PARROT_SOURCE@
-PARROT=@PARROT@
+PARROT=@PARROT_SOURCE@/@PARROT@
SOURCE_FILES=mod_parrot.c parrot_util.c modparrot_config.c nci.c context.c
PARROT_OBJS=$(PARROT_SOURCE)/src/parrot_config.o
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.