Alien-curl

 view release on metacpan or  search on metacpan

alienfile  view on Meta::CPAN

    );
  }

  plugin Download => (
    url     => 'https://curl.haxx.se/download/',
    version => qr/^curl-([0-9\.]+)\.tar\.gz$/,
  );
  plugin Extract => 'tar.gz';

  # make sure that curl uses the linker flags
  # from our Alien SSL
  if($alien_ssl)
  {
    meta->around_hook( $_ => sub {
      my $orig = shift;
      my $build = shift;
      local $ENV{LDFLAGS}  = $ENV{LDFLAGS};
      unshift @LDFLAGS,  grep /^-L/, shellwords( $alien_ssl->libs   );
      log "using LDFLAGS = $ENV{LDFLAGS}";
      $orig->($build, @_);
    }) for qw( build build_ffi );
  }

  plugin 'Build::Autoconf' => ();

  build [
    "%{configure} --disable-shared --enable-static @acflags",
    '%{make}',
    '%{make} install',
  ];

  after gather => sub {
    my $build = shift;
    return unless $alien_ssl;
    $build->install_prop->{libs_static} = join(' ',
      $build->install_prop->{libs_static},
      grep /^-L/,
      shellwords( $alien_ssl->libs ),
    );
  };

  requires 'Path::Tiny';

  my $ffi_target = '%{.install.autoconf_prefix}/dynamic';
  ffi {

    my $patch_makefile = sub {
      my ($build) = @_;
  
      #  should also check curl version as change is not needed from 7.88
      return if $^O ne 'MSWin32';
  
      my $target_file = "src/Makefile";
      $build->log ("Patching $target_file for share build");
      
      my $target_text
        = quotemeta '$(LIBTOOL) --tag=RC --mode=compile $(RC) -I$(top_srcdir)/include';
      my $new_text
        = '$(RC) -I$(top_srcdir)/include';
  
      Path::Tiny->new($target_file)->edit_raw(sub {s/^(\s+)$target_text/$1$new_text/ms});
  
      return;
    };

    build [
      "%{configure} --enable-shared --disable-static --bindir=$ffi_target --libdir=$ffi_target @acflags",
      $patch_makefile,
      '%{make}',
      '%{make} install',
      sub {
        my $build = shift;
        return unless $^O eq 'MSWin32';
        my $root = Path::Tiny->new($ENV{DESTDIR})->child($build->install_prop->{autoconf_prefix});
        log "re-routing DLLs in $root";
        foreach my $from (grep /\.dll$/i, $root->child('bin')->children)
        {
          my $to = $root->child('dynamic', $from->basename);
          log "move $from => $to";
          $from->move($to);
        }
      },
    ];
  };

};



( run in 0.599 second using v1.01-cache-2.11-cpan-0068ddc7af1 )