Author: jkeenan Date: Mon Aug 11 17:35:14 2008 New Revision: 30173 Modified: trunk/MANIFEST trunk/config/init/hints/darwin.pm trunk/config/inter/progs.pm
Log: [configure] Merge darwinfixhints branch into trunk, per http://rt.perl.org/rt3/Ticket/Display.html?id=41508. Removes options handling from config/init/hints/darwin.pm, adds a prompt in config/inter/progs.pm for the flag about which Coke needed,and adds a file of tests for config/init/hints/darwin.pm. Modified: trunk/MANIFEST ============================================================================== --- trunk/MANIFEST (original) +++ trunk/MANIFEST Mon Aug 11 17:35:14 2008 @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Mon Aug 11 05:04:45 2008 UT +# generated by tools/dev/mk_manifest_and_skip.pl Mon Aug 11 22:57:10 2008 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. Modified: trunk/config/init/hints/darwin.pm ============================================================================== --- trunk/config/init/hints/darwin.pm (original) +++ trunk/config/init/hints/darwin.pm Mon Aug 11 17:35:14 2008 @@ -6,77 +6,44 @@ use strict; use warnings; +our %defaults = ( + uname => `uname -r`, + sw_vers => `sw_vers -productVersion`, + problem_flags => [ qw( ccflags ldflags ) ], + architectures => [ qw( i386 ppc64 ppc x86_64 ) ], +); + sub runstep { my ( $self, $conf ) = @_; my $verbose = $conf->options->get('verbose'); - # @flags is the list of options that have -arch flags added to them + # %flags is the list of options that have -arch flags added to them # implicitly through config/init/defaults.pm when using Apple's Perl # 5.8 build to run Configure.pl (it's a multi-architecture build). # This doesn't play nice with getting parrot to build on PPC systems # and causes all sorts of fun issues with lipo and friends. So, it's - # time to remove all -arch flags set in $conf->data that haven't been - # requested by command-line options and force a single, native - # architecture to being the default build. - my @flags = qw(ccflags linkflags ldflags ld_share_flags ld_load_flags); - my @arches = qw(i386 ppc64 ppc x86_64); - - print "\nChecking for -arch flags not explicitly added:\n" if $verbose; - for my $flag (@flags) { - my $set_flags; - if ($flag =~ /^ld/) { - $set_flags = $conf->options->get('ldflags')||''; - } - else { - $set_flags = $conf->options->get($flag)||''; - } - my $stored = $conf->data->get($flag)||''; + # time to remove all -arch flags set in $conf->data and force a single, + # native architecture to being the default build. + + my $flagsref = _strip_arch_flags($conf, $verbose); - print "Checking $flag...\n" if $verbose; - print "User-specified: ".($set_flags||'(nil)')."\n" if $verbose; - print "Pre-check: ".($stored||'(nil)')."\n" if $verbose; - - for my $arch (@arches) { - if (!$set_flags || $set_flags !~ /(?:^|\W)-arch\s+$arch(?:\W|$)/) { - $stored =~ s/-arch\s+$arch//g; - $conf->data->set($flag => $stored); - } - } - print "Post-check: ".($conf->data->get($flag)||'(nil)')."\n" if $verbose; - } # And now, after possibly losing a few undesired compiler and linker # flags, on to the main Darwin config. - my ( $ccflags, $ldflags, $libs ) = $conf->data->get(qw(ccflags ldflags libs)); - - my $OSVers = `uname -r`; - chomp $OSVers; - { - local $^W; - $OSVers =~ /(\d+)/; - if ( $1 >= 7 ) { - $libs =~ s/-ldl//; - } - } + my $libs = _strip_ldl_as_needed( $conf->data->get( 'libs' ) ); - unless (exists $ENV{'MACOSX_DEPLOYMENT_TARGET'}) { - my $OSX_vers = `sw_vers -productVersion`; - chomp $OSX_vers; - # remove minor version - $OSX_vers =join '.', (split /[.]/, $OSX_vers)[0,1]; - $ENV{'MACOSX_DEPLOYMENT_TARGET'} = $OSX_vers; - } + _set_deployment_environment(); my $lib_dir = $conf->data->get('build_dir') . "/blib/lib"; - $ldflags .= " -L$lib_dir"; - $ccflags .= " -pipe -fno-common -Wno-long-double "; + $flagsref->{ldflags} .= " -L$lib_dir"; + $flagsref->{ccflags} .= " -pipe -fno-common -Wno-long-double "; $conf->data->set( darwin => 1, osx_version => $ENV{'MACOSX_DEPLOYMENT_TARGET'}, - ccflags => $ccflags, - ldflags => $ldflags, + ccflags => $flagsref->{ccflags}, + ldflags => $flagsref->{ldflags}, ccwarn => "-Wno-shadow", libs => $libs, share_ext => '.dylib', @@ -89,8 +56,10 @@ memalign => 'some_memalign', has_dynamic_linking => 1, - # RT#43147 when built against a dynamic libparrot installable_parrot records - # the path to the blib version of the library + # RT 43147: When built against a dynamic libparrot, + # installable_parrot records the path to the blib version + # of the library. + parrot_is_shared => 1, libparrot_shared => 'libparrot.$(SOVERSION)$(SHARE_EXT)', libparrot_shared_alias => 'libparrot$(SHARE_EXT)', @@ -103,6 +72,76 @@ ); } +#################### INTERNAL SUBROUTINES #################### + +sub _precheck { + my ($flag, $stored, $verbose) = @_; + if ($verbose) { + print "Checking $flag...\n"; + print "Pre-check: " . ($stored || '(nil)') . "\n"; + } +} + +sub _strip_arch_flags_engine { + my ($arches, $stored, $flagsref, $flag) = @_; + for my $arch ( @{ $defaults{architectures} } ) { + $stored =~ s/-arch\s+$arch//g; + $stored =~ s/\s+/ /g; + $flagsref->{$flag} = $stored; + } + return $flagsref; +} + +sub _postcheck { + my ($flagsref, $flag, $verbose) = @_; + if ($verbose) { + print "Post-check: ", ( $flagsref->{$flag} or '(nil)' ), "\n"; + } +} + +sub _strip_arch_flags { + my ($conf, $verbose) = @_; + my $flagsref = { map { $_ => '' } @{ $defaults{problem_flags} } }; + + print "\nStripping -arch flags due to Apple multi-architecture build problems:\n" if $verbose; + for my $flag ( keys %{ $flagsref } ) { + my $stored = $conf->data->get($flag) || ''; + + _precheck($flag, $stored, $verbose); + + $flagsref = _strip_arch_flags_engine( + $defaults{architectures}, $stored, $flagsref, $flag + ); + + _postcheck($flagsref, $flag, $verbose); + } + return $flagsref; +} + +sub _strip_ldl_as_needed { + my $libs = shift; + my $OSVers = $defaults{uname}; + chomp $OSVers; + { + local $^W; + $OSVers =~ /(\d+)/; + if ( $1 >= 7 ) { + $libs =~ s/-ldl//; + } + } + return $libs; +} + +sub _set_deployment_environment { + unless (defined $ENV{'MACOSX_DEPLOYMENT_TARGET'}) { + my $OSX_vers = $defaults{sw_vers}; + chomp $OSX_vers; + # remove minor version + $OSX_vers =join '.', (split /[.]/, $OSX_vers)[0,1]; + $ENV{'MACOSX_DEPLOYMENT_TARGET'} = $OSX_vers; + } +} + 1; # Local Variables: Modified: trunk/config/inter/progs.pm ============================================================================== --- trunk/config/inter/progs.pm (original) +++ trunk/config/inter/progs.pm Mon Aug 11 17:35:14 2008 @@ -98,7 +98,8 @@ $ld = prompt( "What program do you want to use to build shared libraries?", $ld ) if $ask; $conf->data->set( ld => $ld ); - $ccflags = $conf->data->get('ccflags'); + $ccflags = integrate( $conf->data->get('ccflags'), + $conf->options->get('ccflags') ); # Remove some perl5-isms. $ccflags =~ s/-D((PERL|HAVE)_\w+\s*|USE_PERLIO)//g;
