Author: jkeenan
Date: Sat Mar 29 09:38:56 2008
New Revision: 26625

Added:
   branches/ports/config/auto/ports.pm   (contents, props changed)
   branches/ports/t/steps/auto_ports-01.t   (contents, props changed)
Modified:
   branches/ports/config/auto/gmp.pm
   branches/ports/config/auto/readline.pm
   branches/ports/lib/Parrot/Configure/Step/List.pm
   branches/ports/lib/Parrot/Configure/Step/Methods.pm

Log:
Create config step class auto::ports to identify location of Macports.  Move
_handle_darwin_for_macports() out of config/auto/readline.pm and
config/auto/gmp.pm and into lib/Parrot/Configure/Step/Methods.pm.  Add
auto::ports to lib/Parrot/Configure/Step/List.pm.  Add one placeholder test
file.


Modified: branches/ports/config/auto/gmp.pm
==============================================================================
--- branches/ports/config/auto/gmp.pm   (original)
+++ branches/ports/config/auto/gmp.pm   Sat Mar 29 09:38:56 2008
@@ -34,7 +34,6 @@
     my %data;
     $data{description} = q{Determining if your platform supports GMP};
     $data{result}      = q{};
-    $data{macports_root} = File::Spec->catdir( '/', 'opt', 'local' );
     $data{cc_run_expected} =
 
"6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151
 0\n";
 
@@ -89,23 +88,6 @@
     return 1;
 }
 
-sub _handle_darwin_for_macports {
-    my $self = shift;
-    my ($conf, $osname, $file) = @_;
-    if ( $osname =~ /darwin/ ) {
-        my $macports_root = $self->{macports_root};
-        my $macports_lib_dir = qq{$macports_root/lib};
-        my $macports_include_dir = qq{$macports_root/include};
-        if ( -f qq{$macports_include_dir/$file} ) {
-            $conf->data->add( ' ', linkflags => "-L$macports_lib_dir" );
-            $conf->data->add( ' ', ldflags   => "-L$macports_lib_dir" );
-            $conf->data->add( ' ', ccflags   => "-I$macports_include_dir" );
-        }
-    }
-    return 1;
-}
-
-
 sub _handle_mswin32 {
     my ($conf, $osname, $cc) = @_;
     if ( $osname =~ /mswin32/i ) {

Added: branches/ports/config/auto/ports.pm
==============================================================================
--- (empty file)
+++ branches/ports/config/auto/ports.pm Sat Mar 29 09:38:56 2008
@@ -0,0 +1,93 @@
+# Copyright (C) 2005-2007, The Perl Foundation.
+# $Id$
+
+=head1 NAME
+
+config/auto/ports.pm - Determine Macports location on Darwin
+
+=head1 DESCRIPTION
+
+If the operating system is Darwin, this class determines whether or not
+Macports is installed in the default location.
+
+B<Note:>  No provision is yet made for Macports installation in non-default
+locations.
+
+B<Note:>  This step is currently Darwin/Macports-specific because it
+consolidates code previously found in multiple configuration step classes.
+With some modification it may be suitable for application to BSD F<ports>
+programs in general, but as there was no BSD-specific code in the
+configuration step classes, that modification has not yet been made.
+
+=cut
+
+package auto::ports;
+
+use strict;
+use warnings;
+
+use File::Spec;
+use base qw(Parrot::Configure::Step);
+
+use Parrot::Configure::Utils ':auto';
+use Parrot::BuildUtil;
+
+
+sub _init {
+    my $self = shift;
+    my %data;
+    $data{description} = q{Determining Macports location on Darwin};
+    $data{result}      = q{};
+    $data{ports_root} = File::Spec->catdir( '/', 'opt', 'local' );
+    return \%data;
+}
+
+sub runstep {
+    my ( $self, $conf ) = ( shift, shift );
+    my $osname = $conf->data->get_p5( 'OSNAME' );
+    my $verbose = $conf->options->get( 'verbose' );
+    unless ($osname =~ /darwin/) {
+        print "Operating system is $osname; Macports is Darwin only\n"
+            if $verbose;
+        $self->set_result('skipped');
+        return 1;
+    }
+    my $ports_base_dir = $self->{ports_root};
+    my $ports_lib_dir = qq{$ports_base_dir/lib};
+    my $ports_include_dir = qq{$ports_base_dir/include};
+    my @unlocateables;
+    foreach my $dir ($ports_base_dir, $ports_lib_dir, $ports_include_dir) {
+        push @unlocateables, $dir unless (-d $dir);
+    }
+    if (@unlocateables) {
+        print "Could not locate ports directories:  @unlocateables\n"
+            if $verbose;
+        $self->set_result('failed');
+        return;
+    }
+    else {
+        $conf->data->set(
+            ports_base_dir       => $ports_base_dir,
+            ports_lib_dir        => $ports_lib_dir,
+            ports_include_dir    => $ports_include_dir,
+        );
+        $self->set_result('ports located');
+        return 1;
+    }
+}
+
+1;
+
+=head1 AUTHOR
+
+James E Keenan, consolidating code written by Alberto Sim�es, Leopold Toetsch
+and others.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Modified: branches/ports/config/auto/readline.pm
==============================================================================
--- branches/ports/config/auto/readline.pm      (original)
+++ branches/ports/config/auto/readline.pm      Sat Mar 29 09:38:56 2008
@@ -30,7 +30,6 @@
     my %data;
     $data{description} = q{Determining if your platform supports readline};
     $data{result}      = q{};
-    $data{macports_root} = File::Spec->catdir( '/', 'opt', 'local' );
     return \%data;
 }
 
@@ -51,12 +50,6 @@
     # On OS X check the presence of the readline header in the standard
     # Fink/macports locations.
     $self->_handle_darwin_for_fink($conf, $osname, 'readline/readline.h');
-
-    # Since this config step class is the only one that checks for a
-    # macports-installed program, we have not yet had need to create an
-    # 'auto::macports' config step and do not yet have enough basis to extract
-    # this code into a Parrot::Configure::Step::Methods method analogous to
-    # _handle_darwin_for_fink().
     $self->_handle_darwin_for_macports($conf, $osname, q{readline/readline.h});
 
     $conf->cc_gen('config/auto/readline/readline.in');
@@ -93,22 +86,6 @@
     return 1;
 }
 
-sub _handle_darwin_for_macports {
-    my $self = shift;
-    my ($conf, $osname, $file) = @_;
-    if ( $osname =~ /darwin/ ) {
-        my $macports_root = $self->{macports_root};
-        my $macports_lib_dir = qq{$macports_root/lib};
-        my $macports_include_dir = qq{$macports_root/include};
-        if ( -f qq{$macports_include_dir/$file} ) {
-            $conf->data->add( ' ', linkflags => "-L$macports_lib_dir" );
-            $conf->data->add( ' ', ldflags   => "-L$macports_lib_dir" );
-            $conf->data->add( ' ', ccflags   => "-I$macports_include_dir" );
-        }
-    }
-    return 1;
-}
-
 sub _evaluate_cc_run {
     my ($self, $verbose) = @_;
     my $has_readline = 1;

Modified: branches/ports/lib/Parrot/Configure/Step/List.pm
==============================================================================
--- branches/ports/lib/Parrot/Configure/Step/List.pm    (original)
+++ branches/ports/lib/Parrot/Configure/Step/List.pm    Sat Mar 29 09:38:56 2008
@@ -21,6 +21,7 @@
     auto::gcc
     auto::backtrace
     auto::fink
+    auto::ports
     auto::msvc
     auto::attributes
     auto::warnings

Modified: branches/ports/lib/Parrot/Configure/Step/Methods.pm
==============================================================================
--- branches/ports/lib/Parrot/Configure/Step/Methods.pm (original)
+++ branches/ports/lib/Parrot/Configure/Step/Methods.pm Sat Mar 29 09:38:56 2008
@@ -83,6 +83,22 @@
     return 1;
 }
 
+sub _handle_darwin_for_macports {
+    my $self = shift;
+    my ($conf, $osname, $file) = @_;
+    if ( $osname =~ /darwin/ ) {
+        my $ports_root = $self->{ports_root};
+        my $ports_lib_dir = qq{$ports_root/lib};
+        my $ports_include_dir = qq{$ports_root/include};
+        if ( -f qq{$ports_include_dir/$file} ) {
+            $conf->data->add( ' ', linkflags => "-L$ports_lib_dir" );
+            $conf->data->add( ' ', ldflags   => "-L$ports_lib_dir" );
+            $conf->data->add( ' ', ccflags   => "-I$ports_include_dir" );
+        }
+    }
+    return 1;
+}
+
 =back
 
 =head1 SEE ALSO

Added: branches/ports/t/steps/auto_ports-01.t
==============================================================================

Reply via email to