Ticket #727: 39969.darwin2hints.diff

File 39969.darwin2hints.diff, 72.4 KB (added by jkeenan, 5 years ago)

diff between darwin2hints branch and trunk, showing elimination of two config steps and their consolidation into Darwin hints file

  • lib/Parrot/Configure/Options/Conf/Shared.pm

     
    1818    cgoto 
    1919    configure_trace 
    2020    cxx 
     21    darwin_no_fink 
     22    darwin_no_macports 
    2123    datadir 
    2224    debugging 
    2325    define 
  • lib/Parrot/Configure/Step/List.pm

     
    2020    auto::gcc 
    2121    auto::glibc 
    2222    auto::backtrace 
    23     auto::fink 
    24     auto::macports 
    2523    auto::msvc 
    2624    auto::attributes 
    2725    auto::warnings 
  • lib/Parrot/Configure/Step/Methods.pm

     
    2727 
    2828=head1 METHODS 
    2929 
    30 =head2 C<_handle_darwin_for_fink()> 
    31  
    32     $self->_handle_darwin_for_fink($conf, $libs, $osname, $file); 
    33  
    34 Currently used in configuration step classes auto::gmp, auto::readline and 
    35 auto::gdbm. 
    36  
    37 Modifies settings for C<linkflags>, C<ldflags> and C<ccflags> in the 
    38 Parrot::Configure object's data structure. 
    39  
    40 =cut 
    41  
    42 sub _handle_darwin_for_fink { 
    43     my ($self, $conf, $osname, $file) = @_; 
    44     if ( $osname =~ /darwin/ ) { 
    45         my $fink_lib_dir        = $conf->data->get('fink_lib_dir'); 
    46         my $fink_include_dir    = $conf->data->get('fink_include_dir'); 
    47         if ( (defined $fink_lib_dir) && (defined $fink_include_dir) ) { 
    48             if ( -f "$fink_include_dir/$file" ) { 
    49                 my %intended = ( 
    50                     linkflags => "-L$fink_lib_dir", 
    51                     ldflags   => "-L$fink_lib_dir", 
    52                     ccflags   => "-I$fink_include_dir", 
    53                 ); 
    54                 _add_flags_not_yet_seen($conf, \%intended); 
    55             } 
    56         } 
    57     } 
    58     return 1; 
    59 } 
    60  
    61 =head2 C<_handle_darwin_for_macports()> 
    62  
    63     $self->_handle_darwin_for_macports($conf, $libs, $osname, $file); 
    64  
    65 Currently used in configuration step classes auto::gmp, auto::readline and 
    66 auto::opengl. 
    67  
    68 Modifies settings for C<linkflags>, C<ldflags> and C<ccflags> in the 
    69 Parrot::Configure object's data structure. 
    70  
    71 Potentially expandable to cover all BSD-ports systems -- but as yet there has 
    72 been no demand. 
    73  
    74 =cut 
    75  
    76 sub _handle_darwin_for_macports { 
    77     my ($self, $conf, $osname, $file) = @_; 
    78     if ( $osname =~ /darwin/ ) { 
    79 #        my $ports_root          = $conf->data->get( 'ports_base_dir' ); 
    80         my $ports_lib_dir       = $conf->data->get( 'ports_lib_dir' ); 
    81         my $ports_include_dir   = $conf->data->get( 'ports_include_dir' ); 
    82         if ( defined $ports_lib_dir && defined $ports_include_dir ) { 
    83             if ( -f qq{$ports_include_dir/$file} ) { 
    84                 my %intended = ( 
    85                     linkflags => "-L$ports_lib_dir", 
    86                     ldflags   => "-L$ports_lib_dir", 
    87                     ccflags   => "-I$ports_include_dir", 
    88                 ); 
    89                 _add_flags_not_yet_seen($conf, \%intended); 
    90             } 
    91         } 
    92     } 
    93     return 1; 
    94 } 
    95  
    9630=head2 C<_select_lib()> 
    9731 
    9832    $self->_select_lib( { 
     
    201135    return $libs; 
    202136} 
    203137 
    204 sub _add_flags_not_yet_seen { 
    205     my ($conf, $intended) = @_; 
    206     foreach my $flag (keys %{ $intended }) { 
    207         my $flagstr = $conf->data->get($flag); 
    208         my @elements = split /\s+/, $flagstr; 
    209         my %seen = map {$_, 1} @elements; 
    210         $conf->data->add( ' ', $flag => $intended->{$flag} ) 
    211             unless $seen{$intended->{$flag}}; 
    212     } 
    213 } 
    214  
    215  
    216138=head1 SEE ALSO 
    217139 
    218140Parrot::Configure::Step. 
  • lib/Parrot/Test.pm

     
    963963                      "$PConfig{link} " 
    964964                    . "$PConfig{ld_out}$exe_f " 
    965965                    . "$obj_f $cfg " 
    966                     . "$PConfig{libparrot_linkflags} " 
    967                     . "$PConfig{linkflags} $PConfig{ld_debug} " 
     966                    . "$PConfig{libparrot_linkflags} " 
     967                    . "$PConfig{linkflags} $PConfig{ld_debug} " 
    968968                    . "$iculibs $PConfig{libs}"; 
    969969                my $exit_code = run_command( 
    970970                    $cmd, 
  • MANIFEST

     
    11# ex: set ro: 
    22# $Id$ 
    33# 
    4 # generated by tools/dev/mk_manifest_and_skip.pl Thu Jul  9 23:58:32 2009 UT 
     4# generated by tools/dev/mk_manifest_and_skip.pl Sat Jul 11 16:40:06 2009 UT 
    55# 
    66# See below for documentation on the format of this file. 
    77# 
     
    228228config/auto/env.pm                                          [] 
    229229config/auto/env/test_setenv_c.in                            [] 
    230230config/auto/env/test_unsetenv_c.in                          [] 
    231 config/auto/fink.pm                                         [] 
    232231config/auto/format.pm                                       [] 
    233232config/auto/funcptr.pm                                      [] 
    234233config/auto/funcptr/test_c.in                               [] 
     
    257256config/auto/jit/test_exec_cygwin_c.in                       [] 
    258257config/auto/jit/test_exec_linux_c.in                        [] 
    259258config/auto/jit/test_exec_openbsd_c.in                      [] 
    260 config/auto/macports.pm                                     [] 
    261259config/auto/memalign.pm                                     [] 
    262260config/auto/memalign/test2_c.in                             [] 
    263261config/auto/memalign/test_c.in                              [] 
     
    19471945t/steps/auto/crypto-01.t                                    [test] 
    19481946t/steps/auto/ctags-01.t                                     [test] 
    19491947t/steps/auto/env-01.t                                       [test] 
    1950 t/steps/auto/fink-01.t                                      [test] 
    19511948t/steps/auto/format-01.t                                    [test] 
    19521949t/steps/auto/funcptr-01.t                                   [test] 
    19531950t/steps/auto/gc-01.t                                        [test] 
     
    19611958t/steps/auto/inline-01.t                                    [test] 
    19621959t/steps/auto/isreg-01.t                                     [test] 
    19631960t/steps/auto/jit-01.t                                       [test] 
    1964 t/steps/auto/macports-01.t                                  [test] 
    1965 t/steps/auto/macports-02.t                                  [test] 
    19661961t/steps/auto/memalign-01.t                                  [test] 
    19671962t/steps/auto/msvc-01.t                                      [test] 
    19681963t/steps/auto/neg_0-01.t                                     [test] 
  • Configure.pl

     
    196196 
    197197=back 
    198198 
     199=item C<--configure_trace> 
     200 
     201Store the results of each configuration step in a Storable F<.sto> file on 
     202disk, for later analysis by F<Parrot::Configure::Trace> methods. 
     203 
     204=item Operating system-specific configuration options 
     205 
     206=over 4 
     207 
     208=item C<--darwin_no_fink> 
     209 
     210On Darwin, do not probe for Fink libraries. 
     211 
     212=item C<--darwin_no_macports> 
     213 
     214On Darwin, do not probe for Macports libraries. 
     215 
    199216=back 
    200217 
     218=back 
     219 
    201220=head2 Compile Options 
    202221 
    203222=over 4 
  • t/configure/049-options_test_prepare.t

     
    9494        like($stderr, qr/No tests exist for configure step $not_expected/, 
    9595            "Warning about step class lacking test captured"); 
    9696    } 
    97 #    foreach my $type ( qw| init inter auto gen | ) { 
    98 #        my $t = $type . q(_sometest-01.t); 
    99 #        ok($tests_seen{$t}, "Found needed test"); 
    100 #    } 
    101  
    10297    ok( chdir $cwd, "Able to change back to starting directory"); 
    10398} 
    10499 
  • t/steps/init/hints/darwin-01.t

     
    55 
    66use strict; 
    77use warnings; 
    8 use Test::More; # tests => 26; 
     8use Cwd; 
     9use File::Temp qw( tempdir ); 
     10use Test::More; 
    911plan( skip_all => 'only needs testing on Darwin' ) unless $^O =~ /darwin/i; 
    10 plan( tests =>  1 ); 
     12plan( tests =>  40 ); 
     13#use Test::More qw(no_plan); # tests => 40; 
    1114 
     15use lib qw( lib t/configure/testlib ); 
     16use_ok('config::init::defaults'); 
     17use_ok('config::init::hints'); 
     18use_ok('config::init::hints::darwin'); 
     19use Parrot::Configure; 
     20use Parrot::Configure::Options qw( process_options ); 
     21use Parrot::Configure::Test qw( 
     22    test_step_thru_runstep 
     23    test_step_constructor_and_description 
     24); 
     25use IO::CaptureOutput qw | capture |; 
     26 
     27my $cwd = cwd(); 
     28my ($args, $step_list_ref) = process_options( 
     29    { 
     30        argv => [], 
     31        mode => q{configure}, 
     32    } 
     33); 
     34 
     35my $conf = Parrot::Configure->new; 
     36 
     37test_step_thru_runstep( $conf, q{init::defaults}, $args ); 
     38 
     39##### Tests of some internal subroutines ##### 
     40 
     41##### _precheck() ##### 
     42 
     43my $problematic_flag = 'ccflags'; 
     44my $stored = $conf->data->get($problematic_flag); 
     45 
     46{ 
     47    my ($stdout, $stderr); 
     48    capture( 
     49        sub { init::hints::darwin::_precheck( 
     50            $problematic_flag, $stored, 0 
     51        ) }, 
     52        \$stdout, 
     53        \$stderr, 
     54    ); 
     55    ok( ! $stdout, "_precheck():  Non-verbose mode produced no output" ); 
     56} 
     57 
     58{ 
     59    my ($stdout, $stderr); 
     60    capture( 
     61        sub { init::hints::darwin::_precheck( 
     62            $problematic_flag, $stored, 1 
     63        ) }, 
     64        \$stdout, 
     65        \$stderr, 
     66    ); 
     67    ok( $stdout, "_precheck():  Verbose mode produced output" ); 
     68    like($stdout, qr/Checking\s+$problematic_flag/, 
     69        "_precheck():  Got expected verbose output" ); 
     70    like($stdout, qr/Pre-check:\s+$stored/, 
     71        "_precheck():  Got expected verbose output" ); 
     72} 
     73 
     74{ 
     75    my ($stdout, $stderr); 
     76    capture( 
     77        sub { init::hints::darwin::_precheck( 
     78            $problematic_flag, q{}, 1 
     79        ) }, 
     80        \$stdout, 
     81        \$stderr, 
     82    ); 
     83    ok( $stdout, "_precheck():  Verbose mode produced output" ); 
     84    like($stdout, qr/Checking\s+$problematic_flag/, 
     85        "_precheck():  Got expected verbose output" ); 
     86    like($stdout, qr/Pre-check:\s+\(nil\)/, 
     87        "_precheck():  Got expected verbose output" ); 
     88} 
     89 
     90##### _strip_arch_flags_engine ##### 
     91 
     92{ 
     93    my %defaults = ( 
     94        architectures   => [ qw( i386 ppc64 ppc x86_64 ) ], 
     95    ); 
     96    my $flagsref = {}; 
     97    my $stored = q{-someflag  -arch i386 -someotherflag -arch ppc}; 
     98    my $flag = q{ccflags}; 
     99    $flagsref = init::hints::darwin::_strip_arch_flags_engine( 
     100      $defaults{architectures}, $stored, $flagsref, $flag 
     101    ); 
     102    like( 
     103        $flagsref->{$flag},  
     104        qr{-someflag -someotherflag}, 
     105        "_strip_arch_flags_engine(): '-arch' flags and extra whitespace removed", 
     106    ); 
     107 
     108 
     109} 
     110 
     111##### _postcheck ##### 
     112 
     113{ 
     114    my $flag = 'ccflags'; 
     115    my $flagsref = { 'ccflags' => 'my ccflag' }; 
     116    my ($stdout, $stderr); 
     117 
     118    capture( 
     119        sub { init::hints::darwin::_postcheck( 
     120            $flagsref, $flag, 0 
     121        ) }, 
     122        \$stdout, 
     123        \$stderr, 
     124    ); 
     125    ok( ! $stdout, "_postcheck():  Non-verbose mode produced no output" ); 
     126 
     127    capture( 
     128        sub { init::hints::darwin::_postcheck( 
     129            $flagsref, $flag, 1 
     130        ) }, 
     131        \$stdout, 
     132        \$stderr, 
     133    ); 
     134    ok( $stdout, "_postcheck():  Verbose mode produced output" ); 
     135    like($stdout, qr/Post-check:\s+$flagsref->{$flag}/, 
     136        "_postcheck():  Got expected verbose output" ); 
     137 
     138    $flagsref = { 'ccflags' => undef }; 
     139    capture( 
     140        sub { init::hints::darwin::_postcheck( 
     141            $flagsref, $flag, 1 
     142        ) }, 
     143        \$stdout, 
     144        \$stderr, 
     145    ); 
     146    ok( $stdout, "_postcheck():  Verbose mode produced output" ); 
     147    like($stdout, qr/Post-check:\s+\(nil\)/, 
     148        "_postcheck():  Got expected verbose output" ); 
     149} 
     150 
     151##### _strip_arch_flags ##### 
     152 
     153{ 
     154    my %defaults = ( 
     155        problem_flags   => [ qw( ccflags ldflags ) ], 
     156        architectures   => [ qw( i386 ppc64 ppc x86_64 ) ], 
     157    ); 
     158    my $flagsref = {}; 
     159    my $flag = q{ccflags}; 
     160    my $stored = q{-someflag  -arch i386 -someotherflag -arch ppc}; 
     161    my $oldflag = $conf->data->get( $flag ); 
     162    $conf->data->set( $flag => $stored ); 
     163 
     164    $flagsref = init::hints::darwin::_strip_arch_flags($conf, 0); 
     165    like($flagsref->{$flag}, 
     166        qr/-someflag -someotherflag/, 
     167        "_strip_arch_flags(): '-arch' flags and extra whitespace removed", 
     168    );     
     169 
     170    my ($stdout, $stderr); 
     171    capture( 
     172        sub { 
     173            $flagsref = init::hints::darwin::_strip_arch_flags($conf, 1); 
     174        }, 
     175        \$stdout, 
     176        \$stderr, 
     177    ); 
     178    like($flagsref->{$flag}, 
     179        qr/-someflag -someotherflag/, 
     180        "_strip_arch_flags(): '-arch' flags and extra whitespace removed", 
     181    ); 
     182    like( 
     183        $stdout, 
     184        qr/Stripping -arch flags due to Apple multi-architecture build problems:/, 
     185        "_strip_arch_flags(): Got expected verbose output", 
     186    ); 
     187 
     188    $conf->data->set( $flag => $oldflag ); 
     189} 
     190 
     191##### _strip_ldl_as_needed ##### 
     192 
     193{ 
     194    my $oldflag = $conf->data->get( 'libs ' ); 
     195    my ( $major, $libs ); 
     196 
     197    $major = '7.99.11'; 
     198    local $init::hints::darwin::defaults{uname} = $major; 
     199    $conf->data->set( libs => '-somelib -ldl -someotherlib' ); 
     200    $libs = init::hints::darwin::_strip_ldl_as_needed( 
     201        $conf->data->get( 'libs' ) 
     202    ); 
     203    like( $libs, qr/-somelib\s+-someotherlib/, 
     204        "_strip_ldl_as_needed(): '-ldl' stripped as expected" ); 
     205 
     206    $major = '6.99.11'; 
     207    local $init::hints::darwin::defaults{uname} = $major; 
     208    $conf->data->set( libs => '-somelib -ldl -someotherlib' ); 
     209    $libs = init::hints::darwin::_strip_ldl_as_needed( 
     210        $conf->data->get( 'libs' ) 
     211    ); 
     212    like( $libs, qr/-somelib\s+-ldl\s+-someotherlib/, 
     213        "_strip_ldl_as_needed(): '-ldl' not stripped as expected in older darwin" ); 
     214 
     215    $conf->data->set( libs => $oldflag ); 
     216} 
     217 
     218##### _set_deployment_environment() ##### 
     219 
     220{ 
     221    my $predicted = '10.99'; 
     222    local $ENV{'MACOSX_DEPLOYMENT_TARGET'} = undef; 
     223    no warnings 'once'; 
     224    local $init::hints::darwin::defaults{sw_vers} = qq{$predicted.11}; 
     225    use warnings; 
     226    init::hints::darwin::_set_deployment_environment(); 
     227    is($ENV{'MACOSX_DEPLOYMENT_TARGET'}, $predicted, 
     228        "_set_deployment_environment(): MACOSX_DEPLOYMENT_TARGET set as expected"); 
     229} 
     230 
     231##### _probe_for_fink() ##### 
     232 
     233{ 
     234    my $tdir = tempdir( CLEANUP => 1 ); 
     235    chdir $tdir or die "Unable to change to temporary directory: $!"; 
     236 
     237    local $init::hints::darwin::defaults{fink_conf} = qq{$tdir/fink.conf}; 
     238    ok( ! defined( init::hints::darwin::_probe_for_fink( $conf ) ), 
     239        "_probe_for_fink(): returned undefined value for no config file" ); 
     240    $conf->options->set( 'verbose' => 1 ); 
     241    { 
     242        my ($stdout, $stderr); 
     243        capture( 
     244            sub { init::hints::darwin::_probe_for_fink( $conf ); }, 
     245            \$stdout, 
     246            \$stderr, 
     247        ); 
     248        like( $stdout, qr/Fink configuration file not located/, 
     249            "Got expected verbose output when Fink config not located" ); 
     250    } 
     251    $conf->options->set( 'verbose' => 0 ); 
     252 
     253    my $fink_conf_file = q{fink.conf}; 
     254    open my $CONF, '>', $fink_conf_file 
     255        or die "Unable to open $fink_conf_file for writing: $!"; 
     256    print $CONF "Hello, world, but no Fink info\n"; 
     257    close $CONF or die "Unable to close $fink_conf_file after writing: $!"; 
     258    ok( ! defined( init::hints::darwin::_probe_for_fink( $conf ) ), 
     259        "_probe_for_fink(): returned undefined value for defective config file" ); 
     260 
     261    $conf->options->set( 'verbose' => 1 ); 
     262    { 
     263        my ($stdout, $stderr); 
     264        capture( 
     265            sub { init::hints::darwin::_probe_for_fink( $conf ); }, 
     266            \$stdout, 
     267            \$stderr, 
     268        ); 
     269        like( $stdout, qr/Fink configuration file defective/, 
     270            "Got expected verbose output when Fink config was defective" ); 
     271    } 
     272    $conf->options->set( 'verbose' => 0 ); 
     273 
     274    my $other = qq{$tdir/other_fink.conf}; 
     275    local $init::hints::darwin::defaults{fink_conf} = $other; 
     276    $fink_conf_file = $other; 
     277    open my $OCONF, '>', $fink_conf_file 
     278        or die "Unable to open $fink_conf_file for writing: $!"; 
     279    print $OCONF "Basepath:  /tmp/foobar\n"; 
     280    close $OCONF or die "Unable to close $fink_conf_file after writing: $!"; 
     281    ok( ! defined( init::hints::darwin::_probe_for_fink( $conf ) ), 
     282        "_probe_for_fink(): returned undefined value for missing directories" ); 
     283 
     284    $conf->options->set( 'verbose' => 1 ); 
     285    { 
     286        my ($stdout, $stderr); 
     287        capture( 
     288            sub { init::hints::darwin::_probe_for_fink( $conf ); }, 
     289            \$stdout, 
     290            \$stderr, 
     291        ); 
     292        like( $stdout, qr/Could not locate Fink directories/, 
     293            "Got expected verbose output when Fink directories were missing" ); 
     294    } 
     295    $conf->options->set( 'verbose' => 0 ); 
     296 
     297    chdir $cwd or die "Unable to change back to starting directory: $!"; 
     298} 
     299 
     300##### _probe_for_macports() ##### 
     301 
     302{ 
     303    my $tdir = tempdir( CLEANUP => 1 ); 
     304    chdir $tdir or die "Unable to change to temporary directory: $!"; 
     305 
     306    local $init::hints::darwin::defaults{ports_base_dir} = qq{$tdir/foobar}; 
     307    ok( ! defined( init::hints::darwin::_probe_for_macports( $conf ) ), 
     308        "_probe_for_macports(): returned undefined value for no config file" ); 
     309 
     310    $conf->options->set( 'verbose' => 1 ); 
     311    { 
     312        my ($stdout, $stderr); 
     313        capture( 
     314            sub { init::hints::darwin::_probe_for_macports( $conf ); }, 
     315            \$stdout, 
     316            \$stderr, 
     317        ); 
     318        like( $stdout, qr/Could not locate Macports directories/, 
     319            "Got expected verbose output when Macports directories not found" ); 
     320    } 
     321    $conf->options->set( 'verbose' => 0 ); 
     322} 
     323 
     324##### _probe_for_libraries() ##### 
     325 
     326{ 
     327    $conf->options->set( 'darwin_no_fink' => 1 ); 
     328    $conf->options->set( 'verbose' => 0 ); 
     329    my $lib_dir = $conf->data->get('build_dir') . "/blib/lib"; 
     330    my $flagsref = {}; 
     331    $flagsref->{ldflags} .= " -L$lib_dir"; 
     332    $flagsref->{ccflags} .= " -pipe -fno-common -Wno-long-double "; 
     333    $flagsref->{linkflags} .= " -undefined dynamic_lookup"; 
     334    my %state_before = map { $_ => $flagsref->{$_} } keys %{ $flagsref }; 
     335    ok( ! defined ( init::hints::darwin::_probe_for_libraries( 
     336        $conf, $flagsref, 'fink') 
     337    ), "_probe_for_libraries() returned undef as expected" ); 
     338    is_deeply( $flagsref, { %state_before }, 
     339        "No change in flags, as expected" ); 
     340 
     341    $conf->options->set( 'darwin_no_fink' => 0 ); 
     342} 
     343 
     344##### _add_to_flags() ##### 
     345 
     346{ 
     347    my ( $addl_flags_ref, $flagsref, $title, $verbose ); 
     348    $addl_flags_ref = undef; 
     349    $flagsref = undef; 
     350    $title = 'Fink'; 
     351    $verbose = 0; 
     352    ok( init::hints::darwin::_add_to_flags( 
     353        $addl_flags_ref, $flagsref, $title, $verbose 
     354    ), "_add_to_flags(): returned true value when no probes found" ); 
     355 
     356    $verbose = 1; 
     357    { 
     358        my ($stdout, $stderr); 
     359        capture( 
     360            sub { init::hints::darwin::_add_to_flags( 
     361                $addl_flags_ref, $flagsref, $title, $verbose 
     362            ); }, 
     363            \$stdout, 
     364            \$stderr, 
     365        ); 
     366        like( $stdout, qr/Probe for $title unsuccessful/, 
     367            "_add_to_flags(): got expected verbose output when probe unsuccessful" ); 
     368    } 
     369 
     370    $addl_flags_ref = { 
     371        ldflags   => "-Lfink_lib_dir", 
     372        ccflags   => "-Lfink_include_dir", 
     373        linkflags => "-Lfink_lib_dir", 
     374    }; 
     375    my $lib_dir = $conf->data->get('build_dir') . "/blib/lib"; 
     376    $flagsref = undef; 
     377    $flagsref->{ldflags} = " -L$lib_dir"; 
     378    $flagsref->{ccflags} = " -pipe -fno-common -Wno-long-double "; 
     379    $flagsref->{linkflags} = undef; 
     380    $title = 'Fink'; 
     381    $verbose = 0; 
     382    my $rv = init::hints::darwin::_add_to_flags( 
     383        $addl_flags_ref, $flagsref, $title, $verbose 
     384    ); 
     385    is( $flagsref->{linkflags}, " $addl_flags_ref->{linkflags}", 
     386        "_add_to_flags():  flag added where not previously populated" ); 
     387} 
     388 
    12389pass("Completed all tests in $0"); 
    13390 
    14391################### DOCUMENTATION ################### 
  • t/steps/auto/fink-01.t

     
    1 #! perl 
    2 # Copyright (C) 2007-2009, Parrot Foundation. 
    3 # $Id$ 
    4 # auto/fink-01.t 
    5  
    6 use strict; 
    7 use warnings; 
    8 use Test::More; 
    9 use Carp; 
    10 use File::Temp; 
    11 use lib qw( lib t/configure/testlib ); 
    12  
    13 plan( skip_all => 'fink is Darwin only' ) unless $^O =~ /darwin/i; 
    14 plan( tests => 55 ); 
    15  
    16 use_ok('config::init::defaults'); 
    17 use_ok('config::auto::fink'); 
    18  
    19 use Parrot::Configure; 
    20 use Parrot::Configure::Options qw( process_options ); 
    21 use Parrot::Configure::Test qw( 
    22     test_step_thru_runstep 
    23     rerun_defaults_for_testing 
    24     test_step_constructor_and_description 
    25 ); 
    26 use IO::CaptureOutput qw( capture ); 
    27  
    28 ########## Darwin but no good Fink  ########## 
    29  
    30 my ($args, $step_list_ref) = process_options( { 
    31     argv            => [], 
    32     mode            => q{configure}, 
    33 } ); 
    34  
    35 my $conf = Parrot::Configure->new(); 
    36  
    37 test_step_thru_runstep($conf, q{init::defaults}, $args); 
    38  
    39 my $pkg = q{auto::fink}; 
    40  
    41 $conf->add_steps($pkg); 
    42  
    43 my $serialized = $conf->pcfreeze(); 
    44  
    45 $conf->options->set(%{$args}); 
    46 my $step = test_step_constructor_and_description($conf); 
    47  
    48 # Success in the following test means: 
    49 # (a) OS is Darwin. 
    50 # (b) Either Fink is not installed or it is installed correctly, i.e., we can 
    51 # locate the Fink subdirectories we need for later Parrot configuration steps. 
    52 ok($step->runstep($conf), "runstep() returned true value"); 
    53  
    54 $conf->replenish($serialized); 
    55  
    56 ########## not Darwin ########## 
    57  
    58 ($args, $step_list_ref) = process_options( { 
    59     argv            => [], 
    60     mode            => q{configure}, 
    61 } ); 
    62 # mock not Darwin 
    63 $conf->options->set(%{$args}); 
    64 $step = test_step_constructor_and_description($conf); 
    65 $conf->data->set_p5( 'OSNAME' => 'foobar' ); 
    66 ok($step->runstep($conf), "runstep() returned true value"); 
    67 is($step->result(), q{skipped}, "Got expected result for non-Darwin OS"); 
    68  
    69 $conf->replenish($serialized); 
    70  
    71 ########## no Fink ########## 
    72  
    73 ($args, $step_list_ref) = process_options( { 
    74     argv            => [], 
    75     mode            => q{configure}, 
    76 } ); 
    77 # mock no Fink 
    78 $conf->options->set(%{$args}); 
    79 $step = test_step_constructor_and_description($conf); 
    80 $step->{fink_conf} = q{my_ridiculous_foobar}; 
    81 my $msg = q{Fink not installed}; 
    82  
    83 { 
    84     ok($step->runstep($conf), "runstep() returned true value"); 
    85     is($step->result(), $msg, "Got expected result for $msg"); 
    86 } 
    87  
    88 $conf->replenish($serialized); 
    89  
    90 ########## Darwin but defective Fink ########## 
    91  
    92 ($args, $step_list_ref) = process_options( { 
    93     argv            => [], 
    94     mode            => q{configure}, 
    95 } ); 
    96 $conf->options->set(%{$args}); 
    97 $step = test_step_constructor_and_description($conf); 
    98 { 
    99     # mock Fink config file with no Basepath 
    100     my $tfile = File::Temp->new(); 
    101     open my $fh, ">", $tfile 
    102         or croak "Unable to open temporary file for writing"; 
    103     print $fh "Message: Hello world\n"; 
    104     close $fh or croak "Unable to close temporary file after writing"; 
    105     $step->{fink_conf} = $tfile; 
    106     ok(! defined $step->runstep($conf), 
    107         "runstep() returned undef due to defective Fink config file"); 
    108     is($step->result(), q{failed}, 
    109         "Got expected result for defective Fink Config file"); 
    110 } 
    111  
    112 $conf->replenish($serialized); 
    113  
    114 ########## Darwin but defective Fink ########## 
    115  
    116 ($args, $step_list_ref) = process_options( { 
    117     argv            => [], 
    118     mode            => q{configure}, 
    119 } ); 
    120 $conf->options->set(%{$args}); 
    121 $step = test_step_constructor_and_description($conf); 
    122 { 
    123     # mock Fink config file with non-existent Basepath 
    124     my $tfile = File::Temp->new(); 
    125     open my $fh, ">", $tfile 
    126         or croak "Unable to open temporary file for writing"; 
    127     print $fh "Basepath: /my/phony/directory\n"; 
    128     close $fh or croak "Unable to close temporary file after writing"; 
    129     $step->{fink_conf} = $tfile; 
    130     ok(! defined $step->runstep($conf), 
    131         "runstep() returned undef due to unlocateable Fink directories"); 
    132     is($step->result(), q{failed}, 
    133         "Got expected result for unlocateable Fink directories"); 
    134 } 
    135  
    136 $conf->replenish($serialized); 
    137  
    138 ########## not Darwin; --verbose ########## 
    139  
    140 ($args, $step_list_ref) = process_options( { 
    141     argv            => [ q{--verbose} ], 
    142     mode            => q{configure}, 
    143 } ); 
    144 $conf->options->set(%{$args}); 
    145 $step = test_step_constructor_and_description($conf); 
    146 { 
    147     # mock not Darwin 
    148     my $phony_OS = q{foobar}; 
    149     $conf->data->set_p5( 'OSNAME' => $phony_OS ); 
    150     my ($rv, $stdout); 
    151     capture( 
    152         sub { $rv = $step->runstep($conf); }, 
    153         \$stdout, 
    154     ); 
    155     ok($rv, "runstep() returned true value"); 
    156     is($step->result(), q{skipped}, "Got expected result for non-Darwin OS"); 
    157     like($stdout, 
    158         qr/Operating system is $phony_OS; Fink is Darwin only/, 
    159         "Got expected verbose output when OS is not Darwin"); 
    160 } 
    161  
    162 $conf->replenish($serialized); 
    163  
    164 ########## Darwin; --verbose; no Fink ########## 
    165  
    166 ($args, $step_list_ref) = process_options( { 
    167     argv            => [ q{--verbose} ], 
    168     mode            => q{configure}, 
    169 } ); 
    170 $conf->options->set(%{$args}); 
    171 $step = test_step_constructor_and_description($conf); 
    172 { 
    173     # mock no Fink 
    174     $step->{fink_conf} = q{my_ridiculous_foobar}; 
    175     my $msg = q{Fink not installed}; 
    176     my ($rv, $stdout); 
    177     capture( 
    178         sub { $rv = $step->runstep($conf); }, 
    179         \$stdout, 
    180     ); 
    181     ok($rv, "runstep() returned true value"); 
    182     is($step->result(), $msg, 
    183         "Got expected result for $msg"); 
    184     like($stdout, 
    185         qr/Fink configuration file not located/, 
    186         "Got expected verbose output when OS is not Darwin"); 
    187 } 
    188  
    189 $conf->replenish($serialized); 
    190  
    191 ########## Darwin; --verbose; defective Fink ########## 
    192  
    193 ($args, $step_list_ref) = process_options( { 
    194     argv            => [ q{--verbose} ], 
    195     mode            => q{configure}, 
    196 } ); 
    197 $conf->options->set(%{$args}); 
    198 $step = test_step_constructor_and_description($conf); 
    199 { 
    200     # mock Fink config file with no Basepath 
    201     my $tfile = File::Temp->new(); 
    202     open my $fh, ">", $tfile 
    203         or croak "Unable to open temporary file for writing"; 
    204     print $fh "Message: Hello world\n"; 
    205     close $fh or croak "Unable to close temporary file after writing"; 
    206     $step->{fink_conf} = $tfile; 
    207  
    208     my ($rv, $stdout); 
    209     capture( 
    210         sub { $rv = $step->runstep($conf); }, 
    211         \$stdout, 
    212     ); 
    213     ok(! defined $rv, 
    214         "runstep() returned undef due to defective Fink config file"); 
    215     is($step->result(), q{failed}, 
    216         "Got expected result for defective Fink Config file"); 
    217     like($stdout, 
    218         qr/Fink configuration file defective:  no 'Basepath'/, 
    219         "Got expected verbose output when Fink config file lacked 'Basepath'"); 
    220 } 
    221  
    222 $conf->replenish($serialized); 
    223  
    224 ########## Darwin; --verbose; defective Fink ########## 
    225  
    226 ($args, $step_list_ref) = process_options( { 
    227     argv            => [ q{--verbose} ], 
    228     mode            => q{configure}, 
    229 } ); 
    230 $conf->options->set(%{$args}); 
    231 $step = test_step_constructor_and_description($conf); 
    232 { 
    233     # mock Fink config file with non-existent Basepath 
    234     my $tfile = File::Temp->new(); 
    235     open my $fh, ">", $tfile 
    236         or croak "Unable to open temporary file for writing"; 
    237     print $fh "Basepath: /my/phony/directory\n"; 
    238     close $fh or croak "Unable to close temporary file after writing"; 
    239     $step->{fink_conf} = $tfile; 
    240  
    241     my ($rv, $stdout); 
    242     capture( 
    243         sub { $rv = $step->runstep($conf); }, 
    244         \$stdout, 
    245     ); 
    246     ok(! defined $rv, 
    247         "runstep() returned undef due to unlocateable Fink directories"); 
    248     is($step->result(), q{failed}, 
    249         "Got expected result for unlocateable Fink directories"); 
    250     like($stdout, 
    251         qr/Could not locate Fink directories/, 
    252         "Got expected verbose output for unlocateable Fink directories"); 
    253 } 
    254  
    255 pass("Completed all tests in $0"); 
    256  
    257 ################### DOCUMENTATION ################### 
    258  
    259 =head1 NAME 
    260  
    261 auto/fink-01.t - test auto::fink 
    262  
    263 =head1 SYNOPSIS 
    264  
    265     % prove t/steps/auto/fink-01.t 
    266  
    267 =head1 DESCRIPTION 
    268  
    269 The files in this directory test functionality used by F<Configure.pl>. 
    270  
    271 The tests in this file test auto::fink.  Some tests will run only on Darwin. 
    272 Others simulate how auto::fink runs on operating systems other than Darwin. 
    273  
    274 =head1 AUTHOR 
    275  
    276 James E Keenan 
    277  
    278 =head1 SEE ALSO 
    279  
    280 config::auto::fink, F<Configure.pl>. 
    281  
    282 =cut 
    283  
    284 # Local Variables: 
    285 #   mode: cperl 
    286 #   cperl-indent-level: 4 
    287 #   fill-column: 100 
    288 # End: 
    289 # vim: expandtab shiftwidth=4: 
  • t/steps/auto/macports-01.t

     
    1 #! perl 
    2 # Copyright (C) 2007-2009, Parrot Foundation. 
    3 # $Id$ 
    4 # auto/macports-01.t 
    5  
    6 use strict; 
    7 use warnings; 
    8 use Test::More; 
    9 use Carp; 
    10 use Cwd; 
    11 use File::Spec; 
    12 use File::Temp qw( tempdir ); 
    13 use lib qw( lib t/configure/testlib ); 
    14  
    15 plan( skip_all => 'Macports is Darwin only' ) unless $^O =~ /darwin/; 
    16 plan( tests    => 52 ); 
    17  
    18 use_ok('config::init::defaults'); 
    19 use_ok('config::auto::macports'); 
    20 use Parrot::Configure; 
    21 use Parrot::Configure::Options qw( process_options ); 
    22 use Parrot::Configure::Test qw( 
    23     test_step_thru_runstep 
    24     test_step_constructor_and_description 
    25 ); 
    26 use IO::CaptureOutput qw( capture ); 
    27  
    28 ########## not Darwin ########## 
    29  
    30 my ($args, $step_list_ref) = process_options( { 
    31     argv            => [], 
    32     mode            => q{configure}, 
    33 } ); 
    34  
    35 my $conf = Parrot::Configure->new(); 
    36  
    37 test_step_thru_runstep($conf, q{init::defaults}, $args); 
    38  
    39 my $pkg = q{auto::macports}; 
    40  
    41 $conf->add_steps($pkg); 
    42  
    43 my $serialized = $conf->pcfreeze(); 
    44  
    45 $conf->options->set(%{$args}); 
    46 my $step = test_step_constructor_and_description($conf); 
    47  
    48 # mock not Darwin 
    49 $conf->data->set_p5( 'OSNAME' => 'foobar' ); 
    50 ok($step->runstep($conf), "runstep() returned true value"); 
    51 is($step->result(), q{skipped}, "Got expected result for non-Darwin OS"); 
    52  
    53 $conf->replenish($serialized); 
    54  
    55 ########## Darwin but no Macports ########## 
    56  
    57 ($args, $step_list_ref) = process_options( { 
    58     argv            => [], 
    59     mode            => q{configure}, 
    60 } ); 
    61 $conf->options->set(%{$args}); 
    62 $step = test_step_constructor_and_description($conf); 
    63  
    64 # mock no Macports-default directories 
    65 $step->{ports_root} = File::Spec->catdir( qw( / my ridiculous foobar ) ); 
    66 ok($step->runstep($conf), "runstep() returned true value"); 
    67 is($step->result(), 'no', "Got expected result"); 
    68  
    69 $conf->replenish($serialized); 
    70  
    71 ########## Darwin with Macports ########## 
    72  
    73 ($args, $step_list_ref) = process_options( { 
    74     argv            => [], 
    75     mode            => q{configure}, 
    76 } ); 
    77 $conf->options->set(%{$args}); 
    78 $step = test_step_constructor_and_description($conf); 
    79 my $cwd = cwd(); 
    80  
    81 my $tdir = tempdir( CLEANUP => 1 ); 
    82 $step->{ports_root} = $tdir; 
    83 ok(chdir $tdir, "Able to change to temporary directory"); 
    84 ok( (mkdir 'lib'), "Able to make lib directory"); 
    85 ok( (mkdir 'include'), "Able to make include directory"); 
    86  
    87 ok($step->runstep($conf), "runstep() returned true value"); 
    88 is($step->result(), q{yes}, "Got expected result"); 
    89  
    90 is($conf->data->get('ports_base_dir'), $tdir, 
    91     "ports base directory set as expected"); 
    92 is($conf->data->get('ports_lib_dir'), qq{$tdir/lib}, 
    93     "ports 'lib' directory set as expected"); 
    94 is($conf->data->get('ports_include_dir'), qq{$tdir/include}, 
    95     "ports 'include' directory set as expected"); 
    96  
    97 ok(chdir $cwd, "Able to change back to original directory after testing"); 
    98  
    99 $conf->replenish($serialized); 
    100  
    101 ########## not Darwin; --verbose ########## 
    102  
    103 ($args, $step_list_ref) = process_options( { 
    104     argv            => [ q{--verbose} ], 
    105     mode            => q{configure}, 
    106 } ); 
    107 $conf->options->set(%{$args}); 
    108 $step = test_step_constructor_and_description($conf); 
    109 # mock not Darwin 
    110 my $osname = 'foobar'; 
    111 $conf->data->set_p5( 'OSNAME' => $osname ); 
    112 { 
    113     my ($stdout, $stderr); 
    114     my $ret = capture sub { $step->runstep($conf) }, \$stdout, \$stderr; 
    115     ok($ret, "runstep() returned true value"); 
    116     is($step->result(), q{skipped}, "Got expected result for non-Darwin OS"); 
    117     like( 
    118         $stdout, 
    119         qr/^Operating system is $osname; Macports is Darwin only/, 
    120         "Got expected verbose output" 
    121     ); 
    122 } 
    123  
    124 $conf->replenish($serialized); 
    125  
    126 ########## Darwin; --verbose; no Macports ########## 
    127  
    128 ($args, $step_list_ref) = process_options( { 
    129     argv            => [ q{--verbose} ], 
    130     mode            => q{configure}, 
    131 } ); 
    132 $conf->options->set(%{$args}); 
    133 $step = test_step_constructor_and_description($conf); 
    134 # mock no Macports-default directories 
    135 $step->{ports_root} = File::Spec->catdir( qw( / my ridiculous foobar ) ); 
    136 SKIP: { 
    137     skip 'Macports is Darwin only', 3 unless $^O =~ /darwin/; 
    138     my ($stdout, $stderr); 
    139     my $ret = capture sub { $step->runstep($conf) }, \$stdout, \$stderr; 
    140     ok($ret, "runstep() returned true value"); 
    141     is($step->result(), 'no', "Got expected result"); 
    142     like( 
    143         $stdout, 
    144         qr/^Could not locate Macports directories/, 
    145         "Got expected verbose output" 
    146     ); 
    147 } 
    148 $step->{ports_root} = undef; # prepare for next test 
    149  
    150 $conf->replenish($serialized); 
    151  
    152 ########## Darwin; defective Macports ########## 
    153  
    154 ($args, $step_list_ref) = process_options( { 
    155     argv            => [ ], 
    156     mode            => q{configure}, 
    157 } ); 
    158 $conf->options->set(%{$args}); 
    159 $step = test_step_constructor_and_description($conf); 
    160 # mock no Macports root directory 
    161 SKIP: { 
    162     skip 'Macports is Darwin only', 2 unless $^O =~ /darwin/; 
    163     $step->{ports_root} = undef; 
    164     ok($step->runstep($conf), "runstep() returned true value"); 
    165     is($step->result(), 'no', "Got expected result"); 
    166 } 
    167  
    168 $conf->replenish($serialized); 
    169  
    170 ########## Darwin; --verbose; defective Macports ########## 
    171  
    172 ($args, $step_list_ref) = process_options( { 
    173     argv            => [ q{--verbose} ], 
    174     mode            => q{configure}, 
    175 } ); 
    176 $conf->options->set(%{$args}); 
    177 $step = test_step_constructor_and_description($conf); 
    178 # mock no Macports root directory 
    179 $step->{ports_root} = undef; 
    180  
    181 my ($stdout, $stderr); 
    182 my $ret = capture sub { $step->runstep($conf) }, \$stdout, \$stderr; 
    183 ok($ret, "runstep() returned true value"); 
    184 is($step->result(), 'no', "Got expected result"); 
    185 like( 
    186     $stdout, 
    187     qr/^Could not locate Macports root directory/, 
    188     "Got expected verbose output" 
    189 ); 
    190  
    191 pass("Completed all tests in $0"); 
    192  
    193 ################### DOCUMENTATION ################### 
    194  
    195 =head1 NAME 
    196  
    197 auto/macports-01.t - test auto::macports 
    198  
    199 =head1 SYNOPSIS 
    200  
    201     % prove t/steps/auto/macports-01.t 
    202  
    203 =head1 DESCRIPTION 
    204  
    205 The files in this directory test functionality used by F<Configure.pl>. 
    206  
    207 The tests in this file test auto::macports.  Some tests run only on Darwin. 
    208 Others simulate what happens on operating systems other than Darwin. 
    209  
    210 =head1 AUTHOR 
    211  
    212 James E Keenan 
    213  
    214 =head1 SEE ALSO 
    215  
    216 config::auto::macports, F<Configure.pl>. 
    217  
    218 =cut 
    219  
    220 # Local Variables: 
    221 #   mode: cperl 
    222 #   cperl-indent-level: 4 
    223 #   fill-column: 100 
    224 # End: 
    225 # vim: expandtab shiftwidth=4: 
    226  
  • t/steps/auto/macports-02.t

     
    1 #! perl 
    2 # Copyright (C) 2007, Parrot Foundation. 
    3 # $Id$ 
    4 # auto/macports-02.t 
    5  
    6 use strict; 
    7 use warnings; 
    8 use Test::More; 
    9 plan( skip_all => 'Macports is Darwin only' ) unless $^O =~ /darwin/; 
    10 plan( tests => 12 ); 
    11 use Carp; 
    12 use lib qw( lib t/configure/testlib ); 
    13 use_ok('config::init::defaults'); 
    14 $ENV{TEST_MACPORTS} = 'foobar'; 
    15 use_ok('config::auto::macports'); 
    16  
    17 use Parrot::Configure; 
    18 use Parrot::Configure::Options qw( process_options ); 
    19 use Parrot::Configure::Test qw( 
    20     test_step_thru_runstep 
    21     test_step_constructor_and_description 
    22 ); 
    23  
    24 my ($args, $step_list_ref) = process_options( { 
    25     argv            => [], 
    26     mode            => q{configure}, 
    27 } ); 
    28  
    29 my $conf = Parrot::Configure->new(); 
    30  
    31 test_step_thru_runstep($conf, q{init::defaults}, $args); 
    32  
    33 my $pkg = q{auto::macports}; 
    34  
    35 $conf->add_steps($pkg); 
    36 $conf->options->set(%{$args}); 
    37 my $step = test_step_constructor_and_description($conf); 
    38  
    39 # mock no Macports-default directories 
    40 ok($step->runstep($conf), "runstep() returned true value"); 
    41 is($step->result(), 'no', "Got expected result"); 
    42  
    43 pass("Completed all tests in $0"); 
    44  
    45 ################### DOCUMENTATION ################### 
    46  
    47 =head1 NAME 
    48  
    49 auto/macports-02.t - test auto::macports 
    50  
    51 =head1 SYNOPSIS 
    52  
    53     % prove t/steps/auto/macports-02.t 
    54  
    55 =head1 DESCRIPTION 
    56  
    57 The files in this directory test functionality used by F<Configure.pl>. 
    58  
    59 The tests in this file test auto::macports. 
    60  
    61 =head1 AUTHOR 
    62  
    63 James E Keenan 
    64  
    65 =head1 SEE ALSO 
    66  
    67 config::auto::macports, F<Configure.pl>. 
    68  
    69 =cut 
    70  
    71 # Local Variables: 
    72 #   mode: cperl 
    73 #   cperl-indent-level: 4 
    74 #   fill-column: 100 
    75 # End: 
    76 # vim: expandtab shiftwidth=4: 
    77  
  • t/steps/auto/gmp-01.t

     
    55 
    66use strict; 
    77use warnings; 
    8 use Test::More tests =>  61; 
     8use Test::More tests =>  31; 
    99use Carp; 
    1010use Cwd; 
    1111use File::Spec; 
     
    102102   '-lgmp', 
    103103   "_select_lib() returned expected value"); 
    104104 
    105 ########### _handle_darwin_for_fink() ########### 
    106  
    107105my ($flagsbefore, $flagsafter); 
    108 $osname = 'foobar'; 
    109 $flagsbefore = $conf->data->get( 'linkflags' ); 
    110 ok($step->_handle_darwin_for_fink($conf, $osname, 'gmp.h'), 
    111     "handle_darwin_for_fink() returned true value"); 
    112 $flagsafter = $conf->data->get( 'linkflags' ); 
    113 is($flagsbefore, $flagsafter, "No change in linkflags, as expected"); 
    114  
    115106my $cwd = cwd(); 
    116 { 
    117     my $tdir = tempdir( CLEANUP => 1 ); 
    118     ok(chdir $tdir, "Able to change to temporary directory"); 
    119     ok( (mkdir 'lib'), "Able to make lib directory"); 
    120     ok( (mkdir 'include'), "Able to make include directory"); 
    121     my $libdir = File::Spec->catdir( $tdir, 'lib' ); 
    122     my $includedir = File::Spec->catdir( $tdir, 'include' ); 
    123     $conf->data->set('fink_lib_dir' => $libdir); 
    124     $conf->data->set('fink_include_dir' => $includedir); 
    125     $osname = 'darwin'; 
    126     $flagsbefore = $conf->data->get( 'linkflags' ); 
    127     ok($step->_handle_darwin_for_fink($conf, $osname, 'gmp.h'), 
    128         "handle_darwin_for_fink() returned true value"); 
    129     $flagsafter = $conf->data->get( 'linkflags' ); 
    130     is($flagsbefore, $flagsafter, "No change in linkflags, as expected"); 
    131107 
    132     ok(chdir $cwd, "Able to change back to original directory after testing"); 
    133 } 
    134  
    135 { 
    136     my $tdir2 = tempdir( CLEANUP => 1 ); 
    137     ok(chdir $tdir2, "Able to change to temporary directory"); 
    138     ok( (mkdir 'lib'), "Able to make lib directory"); 
    139     ok( (mkdir 'include'), "Able to make include directory"); 
    140     my $libdir = File::Spec->catdir( $tdir2, 'lib' ); 
    141     my $includedir = File::Spec->catdir( $tdir2, 'include' ); 
    142     $conf->data->set('fink_lib_dir' => $libdir); 
    143     $conf->data->set('fink_include_dir' => $includedir); 
    144     my $foo = File::Spec->catfile( $includedir, 'gmp.h' ); 
    145     open my $FH, ">", $foo or croak "Could not open for writing"; 
    146     print $FH "Hello world\n"; 
    147     close $FH or croak "Could not close after writing"; 
    148  
    149     $osname = 'darwin'; 
    150     $flagsbefore = $conf->data->get( 'linkflags' ); 
    151     ok($step->_handle_darwin_for_fink($conf, $osname, 'gmp.h'), 
    152         "handle_darwin_for_fink() returned true value"); 
    153     $flagsafter = $conf->data->get( 'linkflags' ); 
    154     isnt($flagsbefore, $flagsafter, "Change in linkflags, as expected"); 
    155     like($conf->data->get( 'linkflags' ), qr/-L\Q$libdir\E/, 
    156         "'linkflags' modified as expected"); 
    157  
    158     ok(chdir $cwd, "Able to change back to original directory after testing"); 
    159 } 
    160  
    161 $conf->replenish($serialized); 
    162  
    163108########### _evaluate_cc_run() ########### 
    164109 
    165110($args, $step_list_ref) = process_options( { 
     
    210155    $step->set_result(undef); 
    211156} 
    212157 
    213 ########### _handle_darwin_for_fink() ########### 
    214  
    215 ($args, $step_list_ref) = process_options( { 
    216     argv => [ ], 
    217     mode => q{configure}, 
    218 } ); 
    219 $conf->options->set( %{$args} ); 
    220 $step = test_step_constructor_and_description($conf); 
    221 # Mock values for OS 
    222 $osname = 'darwin'; 
    223 $conf->data->set( 'linkflags'  => 'foobar' ); 
    224 $flagsbefore = $conf->data->get( 'linkflags' ); 
    225 $conf->data->set( fink_lib_dir  => undef ); 
    226 $conf->data->set( fink_include_dir  => undef ); 
    227 ok($step->_handle_darwin_for_fink($conf, $osname, 'gmp.h'), 
    228     "handle_darwin_for_fink() returned true value"); 
    229 $flagsafter = $conf->data->get( 'linkflags' ); 
    230 is($flagsbefore, $flagsafter, "No change in linkflags, as expected"); 
    231  
    232 $cwd = cwd(); 
    233 { 
    234     my $tdir = tempdir( CLEANUP => 1 ); 
    235     ok(chdir $tdir, "Able to change to temporary directory"); 
    236     ok( (mkdir 'lib'), "Able to make lib directory"); 
    237 #    ok( (mkdir 'include'), "Able to make include directory"); 
    238     my $libdir = File::Spec->catdir( $tdir, 'lib' ); 
    239     my $includedir = File::Spec->catdir( $tdir, 'include' ); 
    240     $conf->data->set('fink_lib_dir' => $libdir); 
    241     $conf->data->set('fink_include_dir' => $includedir); 
    242     $osname = 'darwin'; 
    243     $conf->data->set( 'linkflags'  => 'foobar' ); 
    244     $flagsbefore = $conf->data->get( 'linkflags' ); 
    245     ok($step->_handle_darwin_for_fink($conf, $osname, 'gmp.h'), 
    246         "handle_darwin_for_fink() returned true value"); 
    247     $flagsafter = $conf->data->get( 'linkflags' ); 
    248     is($flagsbefore, $flagsafter, "No change in linkflags, as expected"); 
    249  
    250     ok(chdir $cwd, "Able to change back to original directory after testing"); 
    251 } 
    252  
    253 { 
    254     my $tdir1 = tempdir( CLEANUP => 1 ); 
    255     ok(chdir $tdir1, "Able to change to temporary directory"); 
    256 #    ok( (mkdir 'lib'), "Able to make lib directory"); 
    257     ok( (mkdir 'include'), "Able to make include directory"); 
    258     my $libdir = File::Spec->catdir( $tdir1, 'lib' ); 
    259     my $includedir = File::Spec->catdir( $tdir1, 'include' ); 
    260     $conf->data->set('fink_lib_dir' => $libdir); 
    261     $conf->data->set('fink_include_dir' => $includedir); 
    262     $osname = 'darwin'; 
    263     $conf->data->set( 'linkflags'  => 'foobar' ); 
    264     $flagsbefore = $conf->data->get( 'linkflags' ); 
    265     ok($step->_handle_darwin_for_fink($conf, $osname, 'gmp.h'), 
    266         "handle_darwin_for_fink() returned true value"); 
    267     $flagsafter = $conf->data->get( 'linkflags' ); 
    268     is($flagsbefore, $flagsafter, "No change in linkflags, as expected"); 
    269  
    270     ok(chdir $cwd, "Able to change back to original directory after testing"); 
    271 } 
    272  
    273158pass("Completed all tests in $0"); 
    274159 
    275160################### DOCUMENTATION ################### 
  • t/steps/auto/readline-01.t

     
    55 
    66use strict; 
    77use warnings; 
    8 use Test::More tests => 69; 
     8use Test::More tests => 14; 
    99use Carp; 
    1010use Cwd; 
    1111use File::Spec; 
     
    9292like($@, qr/_select_lib\(\) takes hashref/, 
    9393    "Bad argument to _select_lib correctly detected"); 
    9494 
    95 ########## _handle_darwin_for_fink() ########## 
    96  
    97 my ($flagsbefore, $flagsafter); 
    98  
    99 $osname = 'foobar'; 
    100 $flagsbefore = $conf->data->get( 'linkflags' ); 
    101 ok($step->_handle_darwin_for_fink($conf, $osname, 'readline/readline.h'), 
    102     "handle_darwin_for_fink() returned true value"); 
    103 $flagsafter = $conf->data->get( 'linkflags' ); 
    104 is($flagsbefore, $flagsafter, "No change in linkflags, as expected"); 
    105  
    106 my $cwd = cwd(); 
    107 { 
    108     my $tdir1 = tempdir( CLEANUP => 1 ); 
    109     ok(chdir $tdir1, "Able to change to temporary directory"); 
    110     ok( (mkdir 'lib'), "Able to make lib directory"); 
    111     ok( (mkdir 'include'), "Able to make include directory"); 
    112     my $libdir = File::Spec->catdir( $tdir1, 'lib' ); 
    113     my $includedir = File::Spec->catdir( $tdir1, 'include' ); 
    114     $conf->data->set('fink_lib_dir' => $libdir); 
    115     $conf->data->set('fink_include_dir' => $includedir); 
    116     $osname = 'darwin'; 
    117     $flagsbefore = $conf->data->get( 'linkflags' ); 
    118     ok($step->_handle_darwin_for_fink($conf, $osname, 'readline/readline.h'), 
    119         "handle_darwin_for_fink() returned true value"); 
    120     $flagsafter = $conf->data->get( 'linkflags' ); 
    121     is($flagsbefore, $flagsafter, 
    122         "No change in linkflags, as expected, where Fink lib and include directories exist but readline/readline.h does not"); 
    123  
    124     ok(chdir $cwd, "Able to change back to original directory after testing"); 
    125 } 
    126  
    127 { 
    128     my $tdir2 = tempdir( CLEANUP => 1 ); 
    129     ok(chdir $tdir2, "Able to change to temporary directory"); 
    130     ok( (mkdir 'lib'), "Able to make lib directory"); 
    131     ok( (mkdir 'include'), "Able to make include directory"); 
    132     ok( (mkdir 'include/readline'), "Able to make include/readline directory"); 
    133     my $libdir = File::Spec->catdir( $tdir2, 'lib' ); 
    134     my $includedir = File::Spec->catdir( $tdir2, 'include' ); 
    135     $conf->data->set('fink_lib_dir' => $libdir); 
    136     $conf->data->set('fink_include_dir' => $includedir); 
    137     my $foo = File::Spec->catfile( $includedir, 'readline', 'readline.h' ); 
    138     open my $FH, ">", $foo or croak "Could not open for writing"; 
    139     print $FH "Hello world\n"; 
    140     close $FH or croak "Could not close after writing"; 
    141  
    142     $osname = 'darwin'; 
    143     $flagsbefore = $conf->data->get( 'linkflags' ); 
    144     ok($step->_handle_darwin_for_fink($conf, $osname, 'readline/readline.h'), 
    145         "handle_darwin_for_fink() returned true value"); 
    146     $flagsafter = $conf->data->get( 'linkflags' ); 
    147     isnt($flagsbefore, $flagsafter, "Change in linkflags, as expected"); 
    148     like($conf->data->get( 'linkflags' ), qr/-L\Q$libdir\E/, 
    149         "'linkflags' modified as expected, in case where Fink lib and include dirs exist and readline/readline.h exists"); 
    150     $conf->data->set( linkflags => $flagsbefore ); #reset for next test 
    151  
    152     ok(chdir $cwd, "Able to change back to original directory after testing"); 
    153 } 
    154  
    155 { 
    156     my $tdir3 = tempdir( CLEANUP => 1 ); 
    157     ok(chdir $tdir3, "Able to change to temporary directory"); 
    158     ok( (mkdir 'lib'), "Able to make lib directory"); 
    159     ok( (mkdir 'include'), "Able to make include directory"); 
    160     ok( (mkdir 'include/readline'), "Able to make include/readline directory"); 
    161     my $libdir = File::Spec->catdir( $tdir3, 'lib' ); 
    162     my $includedir = File::Spec->catdir( $tdir3, 'include' ); 
    163     $conf->data->set('fink_lib_dir' => $libdir); 
    164     $conf->data->set('fink_include_dir' => undef); 
    165  
    166     $osname = 'darwin'; 
    167     $flagsbefore = $conf->data->get( 'linkflags' ); 
    168     ok($step->_handle_darwin_for_fink($conf, $osname, 'readline/readline.h'), 
    169         "handle_darwin_for_fink() returned true value"); 
    170     $flagsafter = $conf->data->get( 'linkflags' ); 
    171     is($flagsbefore, $flagsafter, 
    172         "No change in linkflags, as expected, where Fink include directory does not exist"); 
    173  
    174     ok(chdir $cwd, "Able to change back to original directory after testing"); 
    175 } 
    176  
    177 { 
    178     my $tdir4 = tempdir( CLEANUP => 1 ); 
    179     ok(chdir $tdir4, "Able to change to temporary directory"); 
    180     ok( (mkdir 'lib'), "Able to make lib directory"); 
    181     ok( (mkdir 'include'), "Able to make include directory"); 
    182     ok( (mkdir 'include/readline'), "Able to make include/readline directory"); 
    183     my $libdir = File::Spec->catdir( $tdir4, 'lib' ); 
    184     my $includedir = File::Spec->catdir( $tdir4, 'include' ); 
    185     $conf->data->set('fink_lib_dir' => undef ); 
    186     $conf->data->set('fink_include_dir' => $includedir ); 
    187  
    188     $osname = 'darwin'; 
    189     $flagsbefore = $conf->data->get( 'linkflags' ); 
    190     ok($step->_handle_darwin_for_fink($conf, $osname, 'readline/readline.h'), 
    191         "handle_darwin_for_fink() returned true value"); 
    192     $flagsafter = $conf->data->get( 'linkflags' ); 
    193     is($flagsbefore, $flagsafter, 
    194         "No change in linkflags, as expected, where Fink lib directory does not exist"); 
    195  
    196     ok(chdir $cwd, "Able to change back to original directory after testing"); 
    197 } 
    198  
    199 ########## _handle_darwin_for_macports() ########## 
    200  
    201 $osname = 'foobar'; 
    202 $flagsbefore = $conf->data->get( 'linkflags' ); 
    203 ok($step->_handle_darwin_for_macports($conf, $osname, 'readline/readline.h'), 
    204     "handle_darwin_for_macports() returned true value"); 
    205 $flagsafter = $conf->data->get( 'linkflags' ); 
    206 is($flagsbefore, $flagsafter, "No change in linkflags, as expected"); 
    207 # Get ready for the next test 
    208 $conf->data->set( linkflags => $flagsbefore ); 
    209  
    210 $cwd = cwd(); 
    211 { 
    212     my $xtdir1 = File::Spec->canonpath( tempdir( CLEANUP => 1 ) ); 
    213     ok(chdir $xtdir1, "Able to change to temporary directory"); 
    214     ok( (mkdir 'lib'), "Able to make lib directory"); 
    215     ok( (mkdir 'include'), "Able to make include directory"); 
    216     my $libdir = File::Spec->catdir( $xtdir1, 'lib' ); 
    217     my $includedir = File::Spec->catdir( $xtdir1, 'include' ); 
    218     $conf->data->set( ports_base_dir => $xtdir1 ); 
    219     $conf->data->set( ports_lib_dir => $libdir ); 
    220     $conf->data->set( ports_include_dir => $includedir ); 
    221     ok( (mkdir 'include/readline'), "Able to make include/readline directory"); 
    222     $osname = 'darwin'; 
    223     $flagsbefore = $conf->data->get( 'linkflags' ); 
    224     ok($step->_handle_darwin_for_macports($conf, $osname, 'readline/readline.h'), 
    225         "handle_darwin_for_macports() returned true value"); 
    226     $flagsafter = $conf->data->get( 'linkflags' ); 
    227     is($flagsbefore, $flagsafter, 
    228         "No change in linkflags, as expected, where macports lib and include directories exist but readline/readline.h does not"); 
    229  
    230     chdir $cwd or croak "Unable to change back to original directory"; 
    231 } 
    232  
    233 $cwd = cwd(); 
    234 { 
    235     my $xtdir2 = File::Spec->canonpath( tempdir( CLEANUP => 1 ) ); 
    236     ok(chdir $xtdir2, "Able to change to temporary directory"); 
    237     ok( (mkdir 'lib'), "Able to make lib directory"); 
    238     ok( (mkdir 'include'), "Able to make include directory"); 
    239     my $libdir = File::Spec->catdir( $xtdir2, 'lib' ); 
    240     my $includedir = File::Spec->catdir( $xtdir2, 'include' ); 
    241     $conf->data->set( ports_base_dir => $xtdir2 ); 
    242     $conf->data->set( ports_lib_dir => $libdir ); 
    243     $conf->data->set( ports_include_dir => $includedir ); 
    244     ok( (mkdir 'include/readline'), "Able to make include/readline directory"); 
    245     my $foo = File::Spec->catfile( $includedir, 'readline', 'readline.h' ); 
    246     open my $FH, ">", $foo or croak "Could not open for writing"; 
    247     print $FH "Hello world\n"; 
    248     close $FH or croak "Could not close after writing"; 
    249  
    250     $osname = 'darwin'; 
    251     $flagsbefore = $conf->data->get( 'linkflags' ); 
    252     ok($step->_handle_darwin_for_macports($conf, $osname, 'readline/readline.h'), 
    253         "handle_darwin_for_macports() returned true value"); 
    254     $flagsafter = $conf->data->get( 'linkflags' ); 
    255     isnt($flagsbefore, $flagsafter, "Change in linkflags, as expected"); 
    256     like($conf->data->get( 'linkflags' ), qr/-L\Q$libdir\E/, 
    257         "'linkflags' modified as expected, in case where macports lib and include dirs exist and readline/readline.h exists"); 
    258     $conf->data->set( linkflags => $flagsbefore ); 
    259  
    260     chdir $cwd or croak "Unable to change back to original directory"; 
    261 } 
    262  
    263  
    264 $cwd = cwd(); 
    265 { 
    266     my $xtdir3 = File::Spec->canonpath( tempdir( CLEANUP => 1 ) ); 
    267     ok(chdir $xtdir3, "Able to change to temporary directory"); 
    268     ok( (mkdir 'lib'), "Able to make lib directory"); 
    269     ok( (mkdir 'include'), "Able to make include directory"); 
    270     my $libdir = File::Spec->catdir( $xtdir3, 'lib' ); 
    271     my $includedir = File::Spec->catdir( $xtdir3, 'include' ); 
    272     $conf->data->set( ports_base_dir => $xtdir3 ); 
    273     $conf->data->set( ports_lib_dir => $libdir ); 
    274     $conf->data->set( ports_include_dir => undef ); 
    275  
    276     $osname = 'darwin'; 
    277     $flagsbefore = $conf->data->get( 'linkflags' ); 
    278     ok($step->_handle_darwin_for_macports($conf, $osname, 'readline/readline.h'), 
    279         "handle_darwin_for_macports() returned true value"); 
    280     $flagsafter = $conf->data->get( 'linkflags' ); 
    281     is($flagsbefore, $flagsafter, 
    282         "No change in linkflags, as expected, where Macports include directory does not exist"); 
    283  
    284     chdir $cwd or croak "Unable to change back to original directory"; 
    285 } 
    286  
    287 $cwd = cwd(); 
    288 { 
    289     my $xtdir4 = File::Spec->canonpath( tempdir( CLEANUP => 1 ) ); 
    290     ok(chdir $xtdir4, "Able to change to temporary directory"); 
    291     ok( (mkdir 'lib'), "Able to make lib directory"); 
    292     ok( (mkdir 'include'), "Able to make include directory"); 
    293     my $libdir = File::Spec->catdir( $xtdir4, 'lib' ); 
    294     my $includedir = File::Spec->catdir( $xtdir4, 'include' ); 
    295     $conf->data->set( ports_base_dir => $xtdir4 ); 
    296     $conf->data->set( ports_lib_dir => undef ); 
    297     $conf->data->set( ports_include_dir => $includedir ); 
    298  
    299     $osname = 'darwin'; 
    300     $flagsbefore = $conf->data->get( 'linkflags' ); 
    301     ok($step->_handle_darwin_for_macports($conf, $osname, 'readline/readline.h'), 
    302         "handle_darwin_for_macports() returned true value"); 
    303     $flagsafter = $conf->data->get( 'linkflags' ); 
    304     is($flagsbefore, $flagsafter, 
    305         "No change in linkflags, as expected, where Macports lib directory does not exist"); 
    306  
    307     chdir $cwd or croak "Unable to change back to original directory"; 
    308 } 
    309  
    31095pass("Completed all tests in $0"); 
    31196 
    31297################### DOCUMENTATION ################### 
  • t/steps/auto/gdbm-01.t

     
    55 
    66use strict; 
    77use warnings; 
    8 use Test::More tests =>  47; 
     8use Test::More tests =>  40; 
    99use Carp; 
    1010use Cwd; 
    1111use File::Spec; 
     
    5656 
    5757$conf->replenish($serialized); 
    5858 
    59 ########## --without-gdbm; _handle_darwin_for_fink() ########## 
     59########## --without-gdbm ########## 
    6060 
    6161($args, $step_list_ref) = process_options( { 
    6262    argv => [ q{--without-gdbm} ], 
     
    6969my $osname; 
    7070my ($flagsbefore, $flagsafter); 
    7171$osname = 'foobar'; 
    72 $flagsbefore = $conf->data->get( 'linkflags' ); 
    73 ok($step->_handle_darwin_for_fink($conf, $osname, 'gdbm.h'), 
    74     "handle_darwin_for_fink() returned true value"); 
    75 $flagsafter = $conf->data->get( 'linkflags' ); 
    76 is($flagsbefore, $flagsafter, "No change in linkflags, as expected"); 
    7772my $cwd = cwd(); 
    7873{ 
    7974    my $tdir = tempdir( CLEANUP => 1 ); 
     
    8479    my $includedir = File::Spec->catdir( $tdir, 'include' ); 
    8580    $conf->data->set('fink_lib_dir' => $libdir); 
    8681    $conf->data->set('fink_include_dir' => $includedir); 
    87     $osname = 'darwin'; 
    88     $flagsbefore = $conf->data->get( 'linkflags' ); 
    89     ok($step->_handle_darwin_for_fink($conf, $osname, 'gdbm.h'), 
    90         "handle_darwin_for_fink() returned true value"); 
    91     $flagsafter = $conf->data->get( 'linkflags' ); 
    92     is($flagsbefore, $flagsafter, "No change in linkflags, as expected"); 
    9382 
    9483    ok(chdir $cwd, "Able to change back to original directory after testing"); 
    9584} 
     
    10796    print $FH "Hello world\n"; 
    10897    close $FH or croak "Could not close after writing"; 
    10998 
    110     $osname = 'darwin'; 
    111     $flagsbefore = $conf->data->get( 'linkflags' ); 
    112     ok($step->_handle_darwin_for_fink($conf, $osname, 'gdbm.h'), 
    113         "handle_darwin_for_fink() returned true value"); 
    114     $flagsafter = $conf->data->get( 'linkflags' ); 
    115     isnt($flagsbefore, $flagsafter, "Change in linkflags, as expected"); 
    116     like($conf->data->get( 'linkflags' ), qr/-L\Q$libdir\E/, 
    117         "'linkflags' modified as expected"); 
    118  
    11999    ok(chdir $cwd, "Able to change back to original directory after testing"); 
    120100} 
    121101 
  • config/init/hints/darwin.pm

     
    1 # Copyright (C) 2005, Parrot Foundation. 
     1# Copyright (C) 2005-2009, Parrot Foundation. 
    22# $Id$ 
    33 
    44package init::hints::darwin; 
     
    66use strict; 
    77use warnings; 
    88 
     9use lib qw( lib ); 
     10use File::Spec (); 
     11use base qw(Parrot::Configure::Step); 
     12use Parrot::BuildUtil; 
     13 
    914our %defaults = ( 
    1015    uname           => `uname -r`, 
    1116    sw_vers         => `sw_vers -productVersion`, 
    1217    problem_flags   => [ qw( ccflags ldflags ) ], 
    1318    architectures   => [ qw( i386 ppc64 ppc x86_64 ) ], 
     19    fink_conf       => q{/sw/etc/fink.conf}, 
     20    ports_base_dir  => q{/opt/local}, 
    1421); 
    1522 
    1623sub runstep { 
     
    4047    my $lib_dir = $conf->data->get('build_dir') . "/blib/lib"; 
    4148    $flagsref->{ldflags} .= " -L$lib_dir"; 
    4249    $flagsref->{ccflags} .= " -pipe -fno-common -Wno-long-double "; 
     50    $flagsref->{linkflags} .= " -undefined dynamic_lookup"; 
    4351 
     52    _probe_for_libraries($conf, $flagsref, 'fink'); 
     53    _probe_for_libraries($conf, $flagsref, 'macports'); 
     54 
     55    for my $flag ( keys %$flagsref ) { 
     56        $flagsref->{$flag} =~ s/^\s+//; 
     57    } 
     58 
    4459    $conf->data->set( 
    4560        darwin              => 1, 
    4661        osx_version         => $ENV{'MACOSX_DEPLOYMENT_TARGET'}, 
     
    5166        share_ext           => '.dylib', 
    5267        load_ext            => '.bundle', 
    5368        link                => 'c++', 
    54         linkflags           => '-undefined dynamic_lookup', 
     69        linkflags           => $flagsref->{linkflags}, 
    5570        ld                  => 'c++', 
    5671        ld_share_flags      => '-dynamiclib -undefined dynamic_lookup', 
    5772        ld_load_flags       => '-undefined dynamic_lookup -bundle', 
     
    86101 
    87102sub _strip_arch_flags_engine { 
    88103    my ($arches, $stored, $flagsref, $flag) = @_; 
    89     for my $arch ( @{ $defaults{architectures} } ) { 
     104    for my $arch ( @{ $arches } ) { 
    90105        $stored =~ s/-arch\s+$arch//g; 
    91106        $stored =~ s/\s+/ /g; 
    92107        $flagsref->{$flag} = $stored; 
     
    144159    } 
    145160} 
    146161 
     162sub _probe_for_fink { 
     163    my $conf = shift; 
     164    my $verbose = $conf->options->get( 'verbose' ); 
     165    # Per fink(8), this is location for Fink configuration file, presumably 
     166    # regardless of where Fink itself is installed. 
     167    my $fink_conf    = $defaults{fink_conf}; 
     168    unless (-f $fink_conf) { 
     169        print "Fink configuration file not located\n" if $verbose; 
     170        return; 
     171    } 
     172    my $fink_conf_str = Parrot::BuildUtil::slurp_file($fink_conf); 
     173    my @lines = split /\n/, $fink_conf_str; 
     174    my $fink_base_dir; 
     175    while (defined (my $l = shift @lines) ) { 
     176        chomp $l; 
     177        next unless $l =~ /^Basepath:\s(.*)/; 
     178        $fink_base_dir = $1; 
     179        last; 
     180    } 
     181    unless (defined $fink_base_dir) { 
     182        print "Fink configuration file defective:  no 'Basepath'\n" 
     183            if $verbose; 
     184        return; 
     185    } 
     186    my $fink_lib_dir = qq{$fink_base_dir/lib}; 
     187    my $fink_include_dir = qq{$fink_base_dir/include}; 
     188    my @unlocateables; 
     189    foreach my $dir ($fink_base_dir, $fink_lib_dir, $fink_include_dir) { 
     190        push @unlocateables, $dir unless (-d $dir); 
     191    } 
     192    if (@unlocateables) { 
     193        print "Could not locate Fink directories:  @unlocateables\n" 
     194            if $verbose; 
     195        return; 
     196    } 
     197    else { 
     198        my %addl_flags = ( 
     199            linkflags => "-L$fink_lib_dir", 
     200            ldflags   => "-L$fink_lib_dir", 
     201            ccflags   => "-I$fink_include_dir", 
     202        ); 
     203        return \%addl_flags; 
     204    } 
     205} 
     206 
     207sub _probe_for_macports { 
     208    my $conf = shift; 
     209    my $verbose = $conf->options->get( 'verbose' ); 
     210    my $ports_base_dir = $defaults{ports_base_dir}; 
     211    my $ports_lib_dir = qq{$ports_base_dir/lib}; 
     212    my $ports_include_dir = qq{$ports_base_dir/include}; 
     213    my @unlocateables; 
     214    foreach my $dir ($ports_base_dir, $ports_lib_dir, $ports_include_dir) { 
     215        push @unlocateables, $dir unless (-d $dir); 
     216    } 
     217    if (@unlocateables) { 
     218        print "Could not locate Macports directories:  @unlocateables\n" 
     219            if $verbose; 
     220        return; 
     221    } 
     222    else { 
     223        my %addl_flags = ( 
     224            linkflags => "-L$ports_lib_dir", 
     225            ldflags   => "-L$ports_lib_dir", 
     226            ccflags   => "-I$ports_include_dir", 
     227        ); 
     228        return \%addl_flags; 
     229    } 
     230} 
     231 
     232sub _probe_for_libraries { 
     233    my ($conf, $flagsref, $library) = @_; 
     234    my $no_library_option = "darwin_no_$library"; 
     235    my $title = ucfirst(lc($library)); 
     236    my $verbose = $conf->options->get( 'verbose' ); 
     237    unless ($conf->options->get( $no_library_option ) ) { 
     238        my $addl_flags_ref; 
     239        if ($library eq 'fink') { 
     240            $addl_flags_ref = _probe_for_fink($conf); 
     241        } 
     242        if ($library eq 'macports') { 
     243            $addl_flags_ref = _probe_for_macports($conf); 
     244        } 
     245        my $rv = _add_to_flags( $addl_flags_ref, $flagsref, $title, $verbose ); 
     246        return $rv; 
     247    } 
     248    return; 
     249} 
     250 
     251sub _add_to_flags { 
     252    my ( $addl_flags_ref, $flagsref, $title, $verbose ) = @_; 
     253    if ( defined $addl_flags_ref ) { 
     254        foreach my $addl ( keys %{ $addl_flags_ref } ) { 
     255            my %seen; 
     256            if ( defined $flagsref->{$addl} ) { 
     257                my @elements = split /\s+/, $flagsref->{$addl}; 
     258                %seen = map {$_, 1} @elements; 
     259            } 
     260            $flagsref->{$addl} .= " $addl_flags_ref->{$addl}" 
     261                unless $seen{ $addl_flags_ref->{$addl} }; 
     262        } 
     263        print "Probe for $title successful\n" if $verbose; 
     264    } 
     265    else { 
     266        print "Probe for $title unsuccessful\n" if $verbose; 
     267    } 
     268    return 1; 
     269} 
     270 
    1472711; 
    148272 
     273################### DOCUMENTATION ################### 
     274 
     275=head1 NAME 
     276 
     277init::hints::Darwin - hints for the Darwin compiler 
     278 
     279=head1 DESCRIPTION 
     280 
     281The functionality in this package is run automatically during configuration 
     282step F<init::hints> when run on Darwin. 
     283 
     284Among other things, this step probes for Fink and Macports libraries -- 
     285functionality previously provided by configuration steps F<auto::fink> and 
     286F<auto::macports>, which have now been eliminated. 
     287 
     288Should you not want to search for either of these packages, you may specify 
     289the command-line options C<darwin_no_fink> and/or C<darwin_no_macports>. 
     290 
     291The functionality is tested in F<t/steps/init/hints/darwin-01.t>. 
     292 
     293=cut 
     294 
    149295# Local Variables: 
    150296#   mode: cperl 
    151297#   cperl-indent-level: 4 
  • config/auto/fink.pm

     
    1 # Copyright (C) 2005-2007, Parrot Foundation. 
    2 # $Id$ 
    3  
    4 =head1 NAME 
    5  
    6 config/auto/fink.pm - Determine Fink location on Darwin 
    7  
    8 =head1 DESCRIPTION 
    9  
    10 If the operating system is Darwin, this class determines whether and where 
    11 Fink is installed. 
    12  
    13 =cut 
    14  
    15 package auto::fink; 
    16  
    17 use strict; 
    18 use warnings; 
    19  
    20 use base qw(Parrot::Configure::Step); 
    21  
    22 use Parrot::Configure::Utils ':auto'; 
    23 use Parrot::BuildUtil; 
    24  
    25  
    26 sub _init { 
    27     my $self = shift; 
    28     my %data; 
    29     $data{description} = q{Determine Fink location on Darwin}; 
    30     $data{result}      = q{}; 
    31     # Per fink(8), this is location for Fink configuration file, presumably 
    32     # regardless of where Fink itself is installed. 
    33     $data{fink_conf}    = q{/sw/etc/fink.conf}; 
    34     return \%data; 
    35 } 
    36  
    37 sub runstep { 
    38     my ( $self, $conf ) = ( shift, shift ); 
    39     my $osname = $conf->data->get_p5( 'OSNAME' ); 
    40     my $verbose = $conf->options->get( 'verbose' ); 
    41     unless ($osname =~ /darwin/) { 
    42         print "Operating system is $osname; Fink is Darwin only\n" 
    43             if $verbose; 
    44         $self->set_result('skipped'); 
    45         return 1; 
    46     } 
    47     # Per fink(8), this is location for Fink configuration file, presumably 
    48     # regardless of where Fink itself is installed. 
    49     my $fink_conf = $self->{fink_conf}; 
    50     unless (-f $fink_conf) { 
    51         print "Fink configuration file not located\n" 
    52             if $verbose; 
    53         $self->set_result('Fink not installed'); 
    54         return 1; 
    55     } 
    56     my $fink_conf_str = Parrot::BuildUtil::slurp_file($fink_conf); 
    57     my @lines = split /\n/, $fink_conf_str; 
    58     my $fink_base_dir; 
    59     while (defined (my $l = shift @lines) ) { 
    60         chomp $l; 
    61         next unless $l =~ /^Basepath:\s(.*)/; 
    62         $fink_base_dir = $1; 
    63         last; 
    64     } 
    65     unless (defined $fink_base_dir) { 
    66         print "Fink configuration file defective:  no 'Basepath'\n" 
    67             if $verbose; 
    68         $self->set_result('failed'); 
    69         return; 
    70     } 
    71     my $fink_lib_dir = qq{$fink_base_dir/lib}; 
    72     my $fink_include_dir = qq{$fink_base_dir/include}; 
    73     my @unlocateables; 
    74     foreach my $dir ($fink_base_dir, $fink_lib_dir, $fink_include_dir) { 
    75         push @unlocateables, $dir unless (-d $dir); 
    76     } 
    77     if (@unlocateables) { 
    78         print "Could not locate Fink directories:  @unlocateables\n" 
    79             if $verbose; 
    80         $self->set_result('failed'); 
    81         return; 
    82     } 
    83     else { 
    84         $conf->data->set( 
    85             fink_base_dir       => $fink_base_dir, 
    86             fink_lib_dir        => $fink_lib_dir, 
    87             fink_include_dir    => $fink_include_dir, 
    88         ); 
    89         $self->set_result('Fink located'); 
    90         return 1; 
    91     } 
    92 } 
    93  
    94 1; 
    95  
    96 =head1 AUTHOR 
    97  
    98 James E Keenan 
    99  
    100 =cut 
    101  
    102 # Local Variables: 
    103 #   mode: cperl 
    104 #   cperl-indent-level: 4 
    105 #   fill-column: 100 
    106 # End: 
    107 # vim: expandtab shiftwidth=4: 
  • config/auto/macports.pm

     
    1 # Copyright (C) 2005-2007, Parrot Foundation. 
    2 # $Id$ 
    3  
    4 =head1 NAME 
    5  
    6 config/auto/macports.pm - Determine Macports location on Darwin 
    7  
    8 =head1 DESCRIPTION 
    9  
    10 If the operating system is Darwin, this class determines whether or not 
    11 Macports is installed in the default location. 
    12  
    13 B<Note:>  No provision is yet made for Macports installation in non-default 
    14 locations. 
    15  
    16 B<Note:>  This step is currently Darwin/Macports-specific because it 
    17 consolidates code previously found in multiple configuration step classes. 
    18 With some modification it may be suitable for application to BSD F<ports> 
    19 programs in general, but as there was no BSD-specific code in the 
    20 configuration step classes, that modification has not yet been made. 
    21  
    22 =cut 
    23  
    24 package auto::macports; 
    25  
    26 use strict; 
    27 use warnings; 
    28  
    29 use File::Spec; 
    30 use base qw(Parrot::Configure::Step); 
    31  
    32 use Parrot::Configure::Utils ':auto'; 
    33 use Parrot::BuildUtil; 
    34  
    35 sub _init { 
    36     my $self = shift; 
    37     my %data; 
    38     $data{description} = q{Determine Macports location on Darwin}; 
    39     $data{result}      = q{}; 
    40     my $optlocal = File::Spec->catdir( '/', 'opt', 'local' ); 
    41     $data{ports_root} = (defined $ENV{TEST_MACPORTS}) 
    42         ? $ENV{TEST_MACPORTS} 
    43         : (-d $optlocal) 
    44             ? $optlocal 
    45             : undef; 
    46     return \%data; 
    47 } 
    48  
    49 sub runstep { 
    50     my ( $self, $conf ) = ( shift, shift ); 
    51     my $osname = $conf->data->get_p5( 'OSNAME' ); 
    52     my $verbose = $conf->options->get( 'verbose' ); 
    53     unless ($osname =~ /darwin/) { 
    54         print "Operating system is $osname; Macports is Darwin only\n" 
    55             if $verbose; 
    56         $self->set_result('skipped'); 
    57         return 1; 
    58     } 
    59     if (! defined $self->{ports_root}) { 
    60         print "Could not locate Macports root directory\n" 
    61             if $verbose; 
    62         $self->set_result('no'); 
    63         return 1; 
    64     } 
    65  
    66     my $ports_base_dir = $self->{ports_root}; 
    67     my $ports_lib_dir = qq{$ports_base_dir/lib}; 
    68     my $ports_include_dir = qq{$ports_base_dir/include}; 
    69     my @unlocateables; 
    70     foreach my $dir ($ports_base_dir, $ports_lib_dir, $ports_include_dir) { 
    71         push @unlocateables, $dir unless (-d $dir); 
    72     } 
    73     if (@unlocateables) { 
    74         print "Could not locate Macports directories:  @unlocateables\n" 
    75             if $verbose; 
    76         $self->set_result('no'); 
    77         return 1; 
    78     } 
    79     else { 
    80         $conf->data->set( 
    81             ports_base_dir       => $ports_base_dir, 
    82             ports_lib_dir        => $ports_lib_dir, 
    83             ports_include_dir    => $ports_include_dir, 
    84         ); 
    85         $self->set_result('yes'); 
    86         return 1; 
    87     } 
    88 } 
    89  
    90 1; 
    91  
    92 =head1 AUTHOR 
    93  
    94 James E Keenan, consolidating code written by Alberto SimÃes, Leopold Toetsch 
    95 and others. 
    96  
    97 =cut 
    98  
    99 # Local Variables: 
    100 #   mode: cperl 
    101 #   cperl-indent-level: 4 
    102 #   fill-column: 100 
    103 # End: 
    104 # vim: expandtab shiftwidth=4: 
  • config/auto/gettext.pm

     
    6161        default         => defined $conf->data->get('glibc') ? '' : '-lintl', 
    6262    } ); 
    6363 
    64     # On OS X check the presence of the gettext header in the standard 
    65     # Fink and MacPorts locations. 
    66     $self->_handle_darwin_for_fink($conf, $osname, 'libintl.h'); 
    67     $self->_handle_darwin_for_macports($conf, $osname, 'libintl.h'); 
    68  
    6964    $conf->cc_gen('config/auto/gettext/gettext_c.in'); 
    7065    eval { $conf->cc_build( q{}, $extra_libs ); }; 
    7166    my $has_gettext = 0; 
  • config/auto/opengl.pm

     
    179179            default         => '-lglut -lGLU -lGL', 
    180180    } ); 
    181181 
    182     # On OS X check the presence of the OpenGL headers in the standard 
    183     # Fink/macports locations. 
    184     # Mindlessly morphed from readline ... may need to be fixed 
    185     $self->_handle_darwin_for_fink    ($conf, $osname, 'GL/glut.h'); 
    186     $self->_handle_darwin_for_macports($conf, $osname, 'GL/glut.h'); 
    187  
    188182    $conf->cc_gen('config/auto/opengl/opengl_c.in'); 
    189183    my $has_glut = 0; 
    190184    eval { $conf->cc_build( q{}, $extra_libs ) }; 
  • config/auto/gmp.pm

     
    6666        default         => '-lgmp', 
    6767    } ); 
    6868 
    69     # On OS X check the presence of the gmp header in the standard 
    70     # Fink location. 
    71     $self->_handle_darwin_for_fink($conf, $osname, 'gmp.h'); 
    72     $self->_handle_darwin_for_macports($conf, $osname, 'gmp.h'); 
    73  
    7469    $conf->cc_gen('config/auto/gmp/gmp_c.in'); 
    7570    eval { $conf->cc_build( q{}, $extra_libs); }; 
    7671    my $has_gmp = 0; 
  • config/auto/gdbm.pm

     
    6161        default         => '-lgdbm', 
    6262    } ); 
    6363 
    64     # On OS X check the presence of the gdbm header in the standard 
    65     # Fink location. 
    66     $self->_handle_darwin_for_fink($conf, $osname, 'gdbm.h'); 
    67  
    6864    $conf->cc_gen('config/auto/gdbm/gdbm_c.in'); 
    6965    eval { $conf->cc_build( q{}, $extra_libs ); }; 
    7066    my $has_gdbm = 0; 
  • config/auto/readline.pm

     
    4949        default         => '-lreadline', 
    5050    } ); 
    5151 
    52     # On OS X check the presence of the readline header in the standard 
    53     # Fink/macports locations. 
    54     $self->_handle_darwin_for_fink($conf, $osname, 'readline/readline.h'); 
    55     $self->_handle_darwin_for_macports($conf, $osname, q{readline/readline.h}); 
    56  
    5752    $conf->cc_gen('config/auto/readline/readline_c.in'); 
    5853    my $has_readline = 0; 
    5954    eval { $conf->cc_build( q{}, $extra_libs ) }; 
  • config/auto/pcre.pm

     
    5656        default         => '-lpcre', 
    5757    } ); 
    5858 
    59     # On OS X check the presence of the pcre headers in the standard 
    60     # Fink/macports locations. 
    61     $self->_handle_darwin_for_fink    ($conf, $osname, 'pcre.h'); 
    62     $self->_handle_darwin_for_macports($conf, $osname, 'pcre.h'); 
    63  
    6459    $conf->cc_gen('config/auto/pcre/pcre_c.in'); 
    6560    eval { $conf->cc_build( q{}, $extra_libs ) }; 
    6661    my $has_pcre = 0;