Added libalien-wxwidgets-perl
[pkg-perl] / deb-src / libalien-wxwidgets-perl / libalien-wxwidgets-perl-0.50 / inc / My / Build / MacOSX_wx_config.pm
1 package My::Build::MacOSX_wx_config;
2
3 use strict;
4 use base qw(My::Build::Any_wx_config);
5
6 use Config;
7
8 sub awx_wx_config_data {
9     my $self = shift;
10     return $self->{awx_data} if $self->{awx_data};
11     my %data = ( linkflags => '', %{$self->SUPER::awx_wx_config_data} );
12
13     # MakeMaker does not like some options
14     $data{libs} =~ s{-framework\s+\w+}{}g;
15     $data{libs} =~ s{-isysroot\s+\S+}{}g;
16     $data{libs} =~ s{-L/usr/local/lib\s}{}g;
17
18     $data{libs} =~ s{\s(-arch\s+\w+)}
19                     {$data{linkflags} .= " $1 ";
20                      $data{cxxflags} .= " $1 ";
21                      ' '}eg;
22
23     $data{cxx} =~ s{-isysroot\s+\S+}{}g;
24     $data{ld} = $data{cxx};
25     $data{cxxflags} .= ' -UWX_PRECOMP ';
26
27     $self->{awx_data} = \%data;
28 }
29
30 sub awx_configure {
31     my $self = shift;
32     my %config = $self->SUPER::awx_configure;
33
34     $config{link_flags} .= $self->wx_config( 'linkflags' );
35
36     return %config;
37 }
38
39 sub wxwidgets_configure_extra_flags {
40     my( $self ) = @_;
41     my $extra_flags = '';
42
43     # on Snow Leopard, force wxWidgets 2.8.x builds to be 32-bit;
44     if(    $self->notes( 'build_data' )->{data}{version} =~ /^2.8/
45         && `uname -r` =~ /^10\./
46         && `sysctl hw.cpu64bit_capable` =~ /^hw.cpu64bit_capable: 1/ ) {
47         print "Forcing wxWidgets build to 32 bit\n";
48         $extra_flags = join ' ', map { qq{$_="-arch i386"} }
49                                      qw(CFLAGS CXXFLAGS LDFLAGS
50                                         OBJCFLAGS OBJCXXFLAGS);
51     }
52     # build fix for 2.9.0 on Snow Leopard
53     if(    `uname -r` =~ /^10\./
54         && $self->notes( 'build_data' )->{data}{version} eq '2.9.0' ) {
55         $extra_flags .= ' --with-macosx-version-min=10.5';
56     }
57
58     return $extra_flags;
59 }
60
61 sub awx_build_toolkit {
62     # use Cocoa for OS X wxWidgets builds with 64 bit Perl
63     if(    $Config{osname} =~ /darwin/
64         && $Config{ptrsize} == 8 ) {
65         return 'osx_cocoa';
66     } else {
67         return 'mac';
68     }
69 }
70
71 sub awx_dlext { 'dylib' }
72
73 sub build_wxwidgets {
74     my( $self ) = @_;
75
76     # can't build wxWidgets 2.8.x with 64 bit Perl
77     if(    $Config{ptrsize} == 8
78         && $self->notes( 'build_data' )->{data}{version} =~ /^2.8/ ) {
79         print <<EOT;
80 =======================================================================
81 The 2.8.x wxWidgets for OS X does not support 64-bit. In order to build
82 wxPerl you will need to either recompile Perl as a 32-bit binary or (if
83 using the Apple-provided Perl) force it to run in 32-bit mode (see "man
84 perl").  Alpha 64-bit wx for OS X is in 2.9.x, but untested in wxPerl.
85 =======================================================================
86 EOT
87         exit 1;
88     }
89
90     $self->SUPER::build_wxwidgets;
91 }
92
93 1;