tagged release 0.6.4
[parrot.git] / config / init / hints / darwin.pm
bloba1a00dc2ab62d8f03ea848e0525973ede9bc2abd
1 # Copyright (C) 2005, The Perl Foundation.
2 # $Id$
4 package init::hints::darwin;
6 use strict;
7 use warnings;
9 sub runstep {
10 my ( $self, $conf ) = @_;
12 my $verbose = $conf->options->get('verbose');
14 # @flags is the list of options that have -arch flags added to them
15 # implicitly through config/init/defaults.pm when using Apple's Perl
16 # 5.8 build to run Configure.pl (it's a multi-architecture build).
17 # This doesn't play nice with getting parrot to build on PPC systems
18 # and causes all sorts of fun issues with lipo and friends. So, it's
19 # time to remove all -arch flags set in $conf->data that haven't been
20 # requested by command-line options and force a single, native
21 # architecture to being the default build.
22 my @flags = qw(ccflags linkflags ldflags ld_share_flags ld_load_flags);
23 my @arches = qw(i386 ppc ppc64 x86_64);
25 print "\nChecking for -arch flags not explicitly added:\n" if $verbose;
26 for my $flag (@flags) {
27 my $set_flags;
28 if ($flag =~ /^ld/) {
29 $set_flags = $conf->options->get('ldflags')||'';
31 else {
32 $set_flags = $conf->options->get($flag)||'';
34 my $stored = $conf->data->get($flag)||'';
36 print "Checking $flag...\n" if $verbose;
37 print "User-specified: ".($set_flags||'(nil)')."\n" if $verbose;
38 print "Pre-check: ".($stored||'(nil)')."\n" if $verbose;
40 for my $arch (@arches) {
41 if (!$set_flags || $set_flags !~ /(?:^|\W)-arch\s+$arch(?:\W|$)/) {
42 $stored =~ s/-arch\s+$arch//g;
43 $conf->data->set($flag => $stored);
46 print "Post-check: ".($conf->data->get($flag)||'(nil)')."\n" if $verbose;
48 # And now, after possibly losing a few undesired compiler and linker
49 # flags, on to the main Darwin config.
51 my ( $ccflags, $ldflags, $libs ) = $conf->data->get(qw(ccflags ldflags libs));
53 my $OSVers = `uname -r`;
54 chomp $OSVers;
56 local $^W;
57 $OSVers =~ /(\d+)/;
58 if ( $1 >= 7 ) {
59 $libs =~ s/-ldl//;
63 unless (exists $ENV{'MACOSX_DEPLOYMENT_TARGET'}) {
64 my $OSX_vers = `sw_vers -productVersion`;
65 chomp $OSX_vers;
66 # remove minor version
67 $OSX_vers =join '.', (split /[.]/, $OSX_vers)[0,1];
68 $ENV{'MACOSX_DEPLOYMENT_TARGET'} = $OSX_vers;
71 my $lib_dir = $conf->data->get('build_dir') . "/blib/lib";
72 $ldflags .= " -L$lib_dir";
73 $ccflags .= " -pipe -fno-common -Wno-long-double ";
75 $conf->data->set(
76 darwin => 1,
77 osx_version => $ENV{'MACOSX_DEPLOYMENT_TARGET'},
78 ccflags => $ccflags,
79 ldflags => $ldflags,
80 ccwarn => "-Wno-shadow",
81 libs => $libs,
82 share_ext => '.dylib',
83 load_ext => '.bundle',
84 link => 'c++',
85 linkflags => '-undefined dynamic_lookup',
86 ld => 'c++',
87 ld_share_flags => '-dynamiclib -undefined dynamic_lookup',
88 ld_load_flags => '-undefined dynamic_lookup -bundle',
89 memalign => 'some_memalign',
90 has_dynamic_linking => 1,
92 # RT#43147 when built against a dynamic libparrot installable_parrot records
93 # the path to the blib version of the library
94 parrot_is_shared => 1,
95 libparrot_shared => 'libparrot.$(SOVERSION)$(SHARE_EXT)',
96 libparrot_shared_alias => 'libparrot$(SHARE_EXT)',
97 rpath => "-L",
98 libparrot_soname => "-install_name "
99 . $lib_dir
100 . $conf->data->get('slash')
101 . "libparrot"
102 . $conf->data->get('share_ext')
108 # Local Variables:
109 # mode: cperl
110 # cperl-indent-level: 4
111 # fill-column: 100
112 # End:
113 # vim: expandtab shiftwidth=4: