Alien-IUP

 view release on metacpan or  search on metacpan

inc/My/Builder/Windows.pm  view on Meta::CPAN

package My::Builder::Windows;

use strict;
use warnings;
use base 'My::Builder';

use File::Spec::Functions qw(catdir catfile rel2abs);
use File::Glob qw(bsd_glob);
use Config;

sub build_binaries {
  my ($self, $build_out, $srcdir) = @_;
  my $prefixdir = rel2abs($build_out);
  my $perl = $^X;
  my @imtargets;
  my @cdtargets;
  my @iuptargets;
  
  my ($v1, $v2) = ($Config{cc} =~ /gcc/ ? $Config{gccversion} : $Config{ccversion}) =~ /^(\d+)\.(\d+)/; # compiler version
  #MSVC++ 11.0 _MSC_VER==1700 $v1.$v2==17.0  (Visual Studio 2012)
  #MSVC++ 10.0 _MSC_VER==1600 $v1.$v2==16.0  (Visual Studio 2010)
  #MSVC++ 9.0  _MSC_VER==1500 $v1.$v2==15.0  (Visual Studio 2008)
  #MSVC++ 8.0  _MSC_VER==1400 $v1.$v2==14.0  (Visual Studio 2005)
  #MSVC++ 7.1  _MSC_VER==1310 $v1.$v2==13.10 (Visual Studio 2003)
  #MSVC++ 7.0  _MSC_VER==1300 $v1.$v2==13.0 
  #MSVC++ 6.0  _MSC_VER==1200 $v1.$v2==12.0 
  #MSVC++ 5.0  _MSC_VER==1100 $v1.$v2==11.0 

  #possible targets:  im im_process im_jp2 im_fftw im_capture im_avi im_wmv
  #possible targets:  cd_zlib cd_freetype cd_ftgl cd cd_pdflib cdpdf cdgl cdcontextplus cdcairo
  #possible targets:  iup iupcd iupcontrols iup_pplot iup_mglplot iupgl iupim iupimglib iupole iupweb iuptuio
  
  if ($self->notes('is_devel_cvs_version')) {
    ### DEVEL BUILD ###
    @imtargets  = qw[im im_process im_jp2 im_fftw]; #xxx im_capture removed
    @cdtargets  = qw[cd cd_pdflib cdpdf cdgl cdcontextplus];
    @iuptargets = qw[iup iupcd iupcontrols iupmatrixex iup_plot iup_mglplot iupgl iupglcontrols iup_scintilla iupim iupimglib iupole iupweb iuptuio];
  }
  else {
    @imtargets  = qw[im];
    @cdtargets  = qw[cd cdgl cdcontextplus];
    @iuptargets = qw[iup iupcd iupcontrols iupmatrixex iup_plot iup_mglplot iupgl iupglcontrols iup_scintilla iupim iupimglib iupole];
    #if ($Config{cc} =~ /cl/ && $v1<14) {
    #  warn "###WARN### skipping cd_ftgl+iuptuio on VC6";
    #  @cdtargets  = grep { $_ !~ /^(cd_ftgl)$/ } @cdtargets;     # disable just when compiling via VC6
    #  @iuptargets = grep { $_ !~ /^(iuptuio)$/ } @iuptargets;    # disable just when compiling via VC6
    #}
  }
  
  #xxx TODO add cdcontextplus + iupweb support to makefiles
  @cdtargets  = grep { $_ !~ /^(cdcontextplus)$/ } @cdtargets if $Config{cc} =~ /gcc/ && ( $v1<4 || $v2<7 ); # XXX-HACK assume that gcc-4.7+ has gdiplus headers
  @iuptargets = grep { $_ !~ /^(iupweb)$/ } @iuptargets;       # xxx TODO: makefiles not ready yet; does not compile on mingw/gcc
  
  # not able to compile iup_mglplot by older MSVC
  if ($Config{make} =~ /nmake/ && $Config{cc} =~ /cl/ && $v1<15) {
    warn "###WARN### skipping iup_mglplot, iup_scintilla on MSVC < 15.0 (fails to compile)";
    @iuptargets = grep { $_ !~ /^(iup_mglplot|iup_scintilla)$/ } @iuptargets;
  }
  
  # old gcc fails to compile iup_mglplot
  if ($Config{cc} =~ /gcc/ && $v1<4) {
    warn "###WARN### skipping iup_mglplot on GCC 3.x (fails to compile)";
    @iuptargets = grep { $_ !~ /^(iup_mglplot)$/ } @iuptargets;
  }

  # gcc <4.8 fails to compile iup_scintilla
  if ($Config{cc} =~ /gcc/ && ($v1<4 || ($v1==4 && $v2<8))) {
    warn "###WARN### skipping iup_scintilla on GCC < 4.8 (fails to compile)";
    @iuptargets = grep { $_ !~ /^(iup_scintilla)$/ } @iuptargets;
  }

  #store debug info into ConfigData
  $self->config_data('info_imtargets', \@imtargets);
  $self->config_data('info_cdtargets', \@cdtargets);
  $self->config_data('info_iuptargets', \@iuptargets);
  $self->config_data('info_gui_driver', 'Win32/native');

  my (@cmd_im, @cmd_cd, @cmd_iup);
  my (@cmd_zl, @cmd_ft, @cmd_ftgl);
  if($Config{make} =~ /nmake/ && $Config{cc} =~ /cl/) { # MSVC compiler
    @cmd_im  = ( $Config{make}, '-f', rel2abs('patches\Makefile_im.nmake'),       "PERL=perl", "PREFIX=$prefixdir" );
    @cmd_cd  = ( $Config{make}, '-f', rel2abs('patches\Makefile_cd.nmake'),       "PERL=perl", "PREFIX=$prefixdir" );
    @cmd_iup = ( $Config{make}, '-f', rel2abs('patches\Makefile_iup.nmake'),      "PERL=perl", "PREFIX=$prefixdir" );
    @cmd_zl  = ( $Config{make}, '-f', rel2abs('patches\Makefile_zlib.nmake'),     "PERL=perl", "PREFIX=$prefixdir" );
    @cmd_ft  = ( $Config{make}, '-f', rel2abs('patches\Makefile_freetype.nmake'), "PERL=perl", "PREFIX=$prefixdir" );
    @cmd_ftgl= ( $Config{make}, '-f', rel2abs('patches\Makefile_ftgl.nmake'),     "PERL=perl", "PREFIX=$prefixdir" );
    if ($Config{archname} =~ /x64/) { #64bit
      push(@cmd_im,  'CFG=Win64');
      push(@cmd_cd,  'CFG=Win64');
      push(@cmd_iup, 'CFG=Win64');
      push(@cmd_zl,  'CFG=Win64');
      push(@cmd_ft,  'CFG=Win64');
      push(@cmd_ftgl,'CFG=Win64');
    }    
  }



( run in 0.473 second using v1.01-cache-2.11-cpan-2398b32b56e )