File: Win32_MinGW.pm

package info (click to toggle)
libalien-wxwidgets-perl 0.50%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 576 kB
  • ctags: 368
  • sloc: perl: 5,259; sh: 48; makefile: 13
file content (118 lines) | stat: -rw-r--r-- 3,479 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package My::Build::Win32_MinGW;

use strict;
use base qw(My::Build::Win32);
use My::Build::Utility qw(awx_arch_file awx_install_arch_file
                          awx_install_arch_dir awx_arch_dir);
use Config;
use File::Basename qw();
use File::Glob qw(bsd_glob);

sub _find_make {
    my( @try ) = qw(mingw32-make gmake make);
    push @try, $Config{gmake} if $Config{gmake};

    foreach my $name ( @try ) {
        foreach my $dir ( File::Spec->path ) {
            my $abs = File::Spec->catfile( $dir, "$name.exe" );
            return $name if -x $abs;
        }
    }

    return 'make';
}

sub awx_configure {
    my $self = shift;
    my %config = $self->SUPER::awx_configure;

    $config{c_flags} .= " -fvtable-thunks ";

    if( $self->awx_debug ) {
        $config{c_flags} .= ' -g ';
    } else {
        $config{link_flags} .= ' -s ';
    }

    my $cccflags = $self->wx_config( 'cxxflags' );
    my $libs = $self->wx_config( 'libs' );
    my $incdir = $self->awx_wx_config_data->{wxinc};
    my $cincdir = $self->awx_wx_config_data->{wxcontrinc};
    my $iincdir = awx_install_arch_dir( $self, 'rEpLaCe/include' );

    foreach ( split /\s+/, $cccflags ) {
        m(^-DSTRICT) && next;
        m(^\.d$) && next; # broken makefile
        m(^-W.*) && next; # under Win32 -Wall gives you TONS of warnings
        m(^-I) && do {
            next if m{(?:regex|zlib|jpeg|png|tiff)$};
            if( $self->notes( 'build_wx' ) ) {
                $_ =~ s{\Q$cincdir\E}{$iincdir};
                $_ =~ s{\Q$incdir\E}{$iincdir};
            }
            if( $_ =~ /-I\Q$self->{awx_setup_dir}\E/ ) {
                $config{include_path} .=
                  '-I' . awx_install_arch_file( $self, 'rEpLaCe/lib' ) . ' ';
            } else {
                $config{include_path} .= "$_ ";
            }
            next;
        };
        m(^-D) && do { $config{defines} .= "$_ "; next; };
        $config{c_flags} .= "$_ ";
    }

    foreach ( split /\s+/, $libs ) {
        m(wx|unicows)i || next;
        next if m{(?:wx(?:zlib|regexu?|expat|png|jpeg|tiff)[ud]{0,2})$};
        $config{link_libraries} .= "$_ ";
    }

    my $dlls = $self->awx_wx_config_data->{dlls};
    $config{_libraries} = {};

    while( my( $key, $value ) = each %$dlls ) {
        $config{_libraries}{$key} =
          { map { $_ => File::Basename::basename( $value->{$_} ) }
                keys %$value };
        if( $value->{link} ) {
            $config{_libraries}{$key}{link} = $value->{link};
        } elsif( $value->{lib} ) {
            my $lib = $config{_libraries}{$key}{lib};
            $lib =~ s/^lib(.*?)(?:\.dll)?\.a$/$1/;
            $config{_libraries}{$key}{link} = '-l' . $lib;
        }
    }

    return %config;
}

sub awx_compiler_kind { 'gcc' }

sub files_to_install {
    my $self = shift;
    my( @try ) = qw(mingwm10.dll libgcc_*.dll);
    my( $dll, $dll_from );

    foreach my $d ( @try ) {
        $dll_from = $self->awx_path_search( $d );
        if( defined $dll_from ) {
            $dll = File::Basename::basename( $dll_from );
            last;
        }
    }

    return ( $self->SUPER::files_to_install(),
             ( $dll_from => awx_arch_file( "rEpLaCe/lib/$dll" ) ) );
}

sub awx_strip_dlls {
    my( $self ) = @_;
    my( $dir ) = grep !/Config/, bsd_glob( awx_arch_dir( '*' ) );

    $self->_system( "attrib -r $dir\\lib\\*.dll" );
    $self->_system( "strip $dir\\lib\\*.dll" );
    $self->_system( "attrib +r $dir\\lib\\*.dll" );
}

1;