|
|
Author: particle
Date: Thu Jul 24 10:27:46 2008
New Revision: 375
Added:
mod_parrot/branches/configure/config/init/
mod_parrot/branches/configure/config/init/defaults.pm
mod_parrot/branches/configure/lib/ModParrot/Configure/Step/
mod_parrot/branches/configure/lib/ModParrot/Configure/Step.pm
mod_parrot/branches/configure/lib/ModParrot/Configure/Step/Methods.pm
Modified:
mod_parrot/branches/configure/Configure.pl
Log:
[config] add init::defaults step and dependencies
Modified: mod_parrot/branches/configure/Configure.pl
==============================================================================
--- mod_parrot/branches/configure/Configure.pl (original)
+++ mod_parrot/branches/configure/Configure.pl Thu Jul 24 10:27:46 2008
@@ -252,21 +252,6 @@
__END__
-## parts stolen from mod_perl
-## step init::defaults
-my %threaded_mpms = map { $_ => 1}
- qw(worker winnt beos mpmt_os2 netware leader perchild threadpool);
-
-sub mpm_is_threaded
-{
- return $threaded_mpms{$_[0]};
-}
-
-my $parrot_build_dir = '../parrot';
-my $apxs = '/usr/local/apache/bin/apxs';
-my $perl = $^X;
-
-
## step commandline config
my $res = GetOptions(
'parrot-build-dir=s' => \$parrot_build_dir,
@@ -385,5 +370,5 @@
}
-## step whatever
+## op conclusion
print "\nType 'make' to build mod_parrot.\n\n";
Added: mod_parrot/branches/configure/config/init/defaults.pm
==============================================================================
--- (empty file)
+++ mod_parrot/branches/configure/config/init/defaults.pm Thu Jul 24
10:27:46 2008
@@ -0,0 +1,61 @@
+# $Id$
+
+=head1 NAME
+
+config/init/defaults.pm - Configuration Defaults
+
+=head1 DESCRIPTION
+
+Sets up the configuration system's default values and data structures.
+
+=cut
+
+package init::defaults;
+
+use strict;
+use warnings;
+
+use base qw(ModParrot::Configure::Step);
+
+use lib '../lib', '/usr/local/parrot/trunk/lib';
+use Parrot::Config;
+
+
+sub _init {
+ my $self = shift;
+ my %data;
+ $data{description} = q{Setting up Configure's default values};
+ $data{result} = q{};
+ return \%data;
+}
+
+
+sub runstep {
+ my ( $self, $conf ) = @_;
+
+ # We need a Glossary somewhere!
+ $conf->data->set(
+ parrot_build_dir => '../parrot',
+ apxs => '/usr/local/apache/bin/apxs',
+ perl => $^X,
+
+ debugging => $conf->options->get('debugging') ? 1 : 0,
+ optimize => '',
+ verbose => $conf->options->get('verbose'),
+
+ cflags => $PConfig{cflags},
+ make => $PConfig{make},
+ );
+
+ return $self;
+}
+
+
+sub _mpm_is_threaded {
+ return !!grep $_ => qw/
+ worker winnt beos mpmt_os2 netware leader perchild threadpool
+ /;
+}
+
+
+1;
Added: mod_parrot/branches/configure/lib/ModParrot/Configure/Step.pm
==============================================================================
--- (empty file)
+++ mod_parrot/branches/configure/lib/ModParrot/Configure/Step.pm Thu Jul
24 10:27:46 2008
@@ -0,0 +1,117 @@
+# Copyright (C) 2001-2005, The Perl Foundation.
+# $Id: Step.pm 26015 2008-02-23 11:50:35Z paultcochrane $
+
+=pod
+
+=head1 NAME
+
+ModParrot::Configure::Step - Configuration step base class
+
+=head1 SYNOPSIS
+
+ use base qw(ModParrot::Configure::Step);
+
+=head1 DESCRIPTION
+
+The C<ModParrot::Configure::Step> module contains the constructor and
+utility methods that should be inherited by all configuration steps.
+
+=head1 USAGE
+
+=cut
+
+package ModParrot::Configure::Step;
+
+use strict;
+use warnings;
+use base qw( ModParrot::Configure::Step::Methods );
+
+=head2 Methods
+
+=over 4
+
+=item * C<new()>
+
+Basic constructor.
+
+Accepts no arguments and returns a L<ModParrot::Configure::Step::> object.
+Requires user to define an C<_init()> method in the inheriting configuration
+class. This initializer sets a C<description> attribute in the object's data
+structure and may set other attributes as well. Should the initializer fail
+to set a C<description> attribute, the constructor sets it to be an empty
+string. Hence, when a configuration step is executed by L<Configure.pl>, the
+description for that step is always defined but may not be a true value.
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $self = bless {}, $class;
+ my $dataref = $self->_init($class);
+ %$self = %$dataref;
+ unless ( defined ($self->{description}) ) {
+ $self->{description} = q{};
+ }
+ return $self;
+}
+
+=item * C<description()>
+
+Accepts no arguments and returns the value of the description attribute. The
+description ought to be set in the C<_init()> initializer in the inheriting
+class's namespace. If it was not set there, the constructor sets it to an
+empty string.
+
+=cut
+
+sub description {
+ my $self = shift;
+ return $self->{description};
+}
+
+=item * C<set_result()>
+
+Accepts a scalar value and assigns it to the inheriting class's C<$result>
+variable. Returns the inheriting class's name.
+
+=cut
+
+sub set_result {
+ my ( $self, $result ) = @_;
+ $self->{result} = $result;
+ return $self;
+}
+
+=item * C<result()>
+
+Accepts no arguments and returns the value of C<$result> from the inheriting
+class's namespace.
+
+=cut
+
+sub result {
+ my $self = shift;
+ return $self->{result};
+}
+
+=back
+
+=head1 AUTHOR
+
+Joshua Hoblitt C<jhoblitt@xxxxxxxx>
+
+=head1 SEE ALSO
+
+F<docs/configuration.pod>, L<ModParrot::Configure>,
L<ModParrot::Configure::Data>,
+L<ModParrot::Configure::Compiler>
+
+=cut
+
+1;
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Added: mod_parrot/branches/configure/lib/ModParrot/Configure/Step/Methods.pm
==============================================================================
--- (empty file)
+++ mod_parrot/branches/configure/lib/ModParrot/Configure/Step/Methods.pm
Thu Jul 24 10:27:46 2008
@@ -0,0 +1,238 @@
+# Copyright (C) 2001-2007, The Perl Foundation.
+# $Id: Methods.pm 28686 2008-06-24 19:59:13Z bernhard $
+
+package ModParrot::Configure::Step::Methods;
+use strict;
+use warnings;
+use Carp;
+
+=head1 NAME
+
+ModParrot::Configure::Step::Methods - Methods for selected configuration steps
+
+=head1 DESCRIPTION
+
+The ModParrot::Configure::Step::Methods module provides methods inherited by
+ModParrot::Configure::Step which are used internally by the C<runstep()> method
+of more than one configuration step class but which are not intended for
+general use in all configuration step classes.
+
+The methods in this module should not be considered
+part of the public interface of ModParrot::Configure::Step. They merely
refactor
+code which at one point was repeated in multiple configuration step classes
+and which need access to the data in the ModParrot::Configure::Step object.
+
+Since the methods are not part of the public interface, their names should
+begin with an underscore 'C<_>'.
+
+=head1 METHODS
+
+=head2 C<_recheck_settings()>
+
+ $self->_recheck_settings($conf, $libs, $ccflags, $linkflags, $verbose);
+
+Currently used in configuration step classes auto::gmp, auto::readline,
+auto::gdbm, and auto::opengl.
+
+=cut
+
+sub _recheck_settings {
+ my ($self, $conf, $libs, $ccflags, $linkflags, $verbose) = @_;
+ $conf->data->set( 'libs', $libs );
+ $conf->data->set( 'ccflags', $ccflags );
+ $conf->data->set( 'linkflags', $linkflags );
+ print " (no) " if $verbose;
+ $self->set_result('no');
+}
+
+=head2 C<_handle_darwin_for_fink()>
+
+ $self->_handle_darwin_for_fink($conf, $libs, $osname, $file);
+
+Currently used in configuration step classes auto::gmp, auto::readline and
+auto::gdbm.
+
+Modifies settings for C<linkflags>, C<ldflags> and C<ccflags> in the
+ModParrot::Configure object's data structure.
+
+=cut
+
+sub _handle_darwin_for_fink {
+ my ($self, $conf, $osname, $file) = @_;
+ if ( $osname =~ /darwin/ ) {
+ my $fink_lib_dir = $conf->data->get('fink_lib_dir');
+ my $fink_include_dir = $conf->data->get('fink_include_dir');
+ if ( (defined $fink_lib_dir) && (defined $fink_include_dir) ) {
+ if ( -f "$fink_include_dir/$file" ) {
+ my %intended = (
+ linkflags => "-L$fink_lib_dir",
+ ldflags => "-L$fink_lib_dir",
+ ccflags => "-I$fink_include_dir",
+ );
+ _add_flags_not_yet_seen($conf, \%intended);
+ }
+ }
+ }
+ return 1;
+}
+
+=head2 C<_handle_darwin_for_macports()>
+
+ $self->_handle_darwin_for_macports($conf, $libs, $osname, $file);
+
+Currently used in configuration step classes auto::gmp, auto::readline and
+auto::opengl.
+
+Modifies settings for C<linkflags>, C<ldflags> and C<ccflags> in the
+ModParrot::Configure object's data structure.
+
+Potentially expandable to cover all BSD-ports systems -- but as yet there has
+been no demand.
+
+=cut
+
+sub _handle_darwin_for_macports {
+ my ($self, $conf, $osname, $file) = @_;
+ if ( $osname =~ /darwin/ ) {
+# my $ports_root = $conf->data->get( 'ports_base_dir' );
+ my $ports_lib_dir = $conf->data->get( 'ports_lib_dir' );
+ my $ports_include_dir = $conf->data->get( 'ports_include_dir' );
+ if ( defined $ports_lib_dir && defined $ports_include_dir ) {
+ if ( -f qq{$ports_include_dir/$file} ) {
+ my %intended = (
+ linkflags => "-L$ports_lib_dir",
+ ldflags => "-L$ports_lib_dir",
+ ccflags => "-I$ports_include_dir",
+ );
+ _add_flags_not_yet_seen($conf, \%intended);
+ }
+ }
+ }
+ return 1;
+}
+
+=head2 C<_add_to_libs()>
+
+ $self->_add_to_libs( {
+ conf => $conf,
+ osname => $osname,
+ cc => $cc,
+ win32_gcc => '-lalpha32 -lalpha32 -lopenalpha32',
+ win32_nongcc => 'alpha.lib',
+ darwin => 'alphadarwin.lib',
+ default => '-lalpha',
+ } );
+
+B<Purpose>: In a number of configuration step classes, the class's
+C<runstep()> method adds libraries to the single whitespace-delimited string
found in
+the ModParrot::Configure object's C<libs> attribute. The libraries to be added
+are either OS-specific or OS/C-compiler-specific. This method enables the
+developer of a configuration step class to define a default value for such a
+flag -- usually the value that is appropriate to Unix-like systems -- and,
+optionally, to define non-default values for certain OSes or OS/C-compiler
+combinations. We currently support settings for:
+
+=over 4
+
+=item * MSWin32 with F<gcc> as the C-compiler.
+
+=item * MSWin32 with any C-compiler other than F<gcc>.
+
+=item * Darwin.
+
+=back
+
+B<Arguments>: Reference to a hash. Four of the hash's key-value pairs are
+required:
+
+=over 4
+
+=item * C<conf>
+
+The ModParrot::Configure object. Supplied within C<runstep()>.
+
+=item * C<osname>
+
+The name of the operating system. Supplied within C<runstep()>.
+
+=item * C<cc>
+
+The name of the C-compiler. Supplied within C<runstep()>.
+
+=item * C<default>
+
+Libraries to be added where no OS-specific or OS/C-compiler-specific libraries
+are to be added. Single whitespace-delimited string.
+
+=back
+
+These optional settings are currently supported and, if provided, will
+supersede the value in C<default>.
+
+=over 4
+
+=item * C<win32_gcc>
+
+Libraries to be added where OS is mswin32 and C-compiler is F<gcc>.
+Single whitespace-delimited string.
+
+=item * C<win32_nongcc>
+
+Libraries to be added where OS is mswin32 and C-compiler is not F<gcc>.
+Single whitespace-delimited string.
+
+=item * C<darwin>
+
+Libraries to be added where OS is Darwin. Do not supply a value if the value
+you need is the same as C<default>. Single whitespace-delimited string.
+
+=back
+
+B<Return Value>: Returns true value upon success.
+
+=cut
+
+sub _add_to_libs {
+ my $self = shift;
+ my $args = shift;
+ croak "_add_to_libs() takes hashref: $!" unless ref($args) eq 'HASH';
+ my $platform =
+ (($args->{osname} =~ /mswin32/i ||
+ $args->{osname} =~ /cygwin/i) &&
+ $args->{cc} =~ /^gcc/i) ? 'win32_gcc'
+ : $args->{osname} =~ /mswin32/i ? 'win32_nongcc'
+ : $args->{osname} =~ /darwin/i ? 'darwin'
+ : 'default';
+ my $libs = defined($args->{$platform})
+ ? $args->{$platform}
+ : $args->{default};
+ $args->{conf}->data->add(' ', libs => $libs);
+ return 1;
+}
+
+sub _add_flags_not_yet_seen {
+ my ($conf, $intended) = @_;
+ foreach my $flag (keys %{ $intended }) {
+ my $flagstr = $conf->data->get($flag);
+ my @elements = split /\s+/, $flagstr;
+ my %seen = map {$_, 1} @elements;
+ $conf->data->add( ' ', $flag => $intended->{$flag} )
+ unless $seen{$intended->{$flag}};
+ }
+}
+
+
+=head1 SEE ALSO
+
+ModParrot::Configure::Step.
+
+=cut
+
+1;
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
|
|