1 package My::Build::Win32_MinGW;
4 use base qw(My::Build::Win32);
5 use My::Build::Utility qw(awx_arch_file awx_install_arch_file
6 awx_install_arch_dir awx_arch_dir);
8 use File::Basename qw();
9 use File::Glob qw(bsd_glob);
12 my( @try ) = qw(mingw32-make gmake make);
13 push @try, $Config{gmake} if $Config{gmake};
15 foreach my $name ( @try ) {
16 foreach my $dir ( File::Spec->path ) {
17 my $abs = File::Spec->catfile( $dir, "$name.exe" );
18 return $name if -x $abs;
27 my %config = $self->SUPER::awx_configure;
29 $config{c_flags} .= " -fvtable-thunks ";
31 if( $self->awx_debug ) {
32 $config{c_flags} .= ' -g ';
34 $config{link_flags} .= ' -s ';
37 my $cccflags = $self->wx_config( 'cxxflags' );
38 my $libs = $self->wx_config( 'libs' );
39 my $incdir = $self->awx_wx_config_data->{wxinc};
40 my $cincdir = $self->awx_wx_config_data->{wxcontrinc};
41 my $iincdir = awx_install_arch_dir( $self, 'rEpLaCe/include' );
43 foreach ( split /\s+/, $cccflags ) {
45 m(^\.d$) && next; # broken makefile
46 m(^-W.*) && next; # under Win32 -Wall gives you TONS of warnings
48 next if m{(?:regex|zlib|jpeg|png|tiff)$};
49 if( $self->notes( 'build_wx' ) ) {
50 $_ =~ s{\Q$cincdir\E}{$iincdir};
51 $_ =~ s{\Q$incdir\E}{$iincdir};
53 if( $_ =~ /-I\Q$self->{awx_setup_dir}\E/ ) {
54 $config{include_path} .=
55 '-I' . awx_install_arch_file( $self, 'rEpLaCe/lib' ) . ' ';
57 $config{include_path} .= "$_ ";
61 m(^-D) && do { $config{defines} .= "$_ "; next; };
62 $config{c_flags} .= "$_ ";
65 foreach ( split /\s+/, $libs ) {
66 m(wx|unicows)i || next;
67 next if m{(?:wx(?:zlib|regexu?|expat|png|jpeg|tiff)[ud]{0,2})$};
68 $config{link_libraries} .= "$_ ";
71 my $dlls = $self->awx_wx_config_data->{dlls};
72 $config{_libraries} = {};
74 while( my( $key, $value ) = each %$dlls ) {
75 $config{_libraries}{$key} =
76 { map { $_ => File::Basename::basename( $value->{$_} ) }
78 if( $value->{link} ) {
79 $config{_libraries}{$key}{link} = $value->{link};
80 } elsif( $value->{lib} ) {
81 my $lib = $config{_libraries}{$key}{lib};
82 $lib =~ s/^lib(.*?)(?:\.dll)?\.a$/$1/;
83 $config{_libraries}{$key}{link} = '-l' . $lib;
90 sub awx_compiler_kind { 'gcc' }
92 sub files_to_install {
94 my( @try ) = qw(mingwm10.dll libgcc_*.dll);
95 my( $dll, $dll_from );
97 foreach my $d ( @try ) {
98 $dll_from = $self->awx_path_search( $d );
99 if( defined $dll_from ) {
100 $dll = File::Basename::basename( $dll_from );
105 return ( $self->SUPER::files_to_install(),
106 ( $dll_from => awx_arch_file( "rEpLaCe/lib/$dll" ) ) );
111 my( $dir ) = grep !/Config/, bsd_glob( awx_arch_dir( '*' ) );
113 $self->_system( "attrib -r $dir\\lib\\*.dll" );
114 $self->_system( "strip $dir\\lib\\*.dll" );
115 $self->_system( "attrib +r $dir\\lib\\*.dll" );