package Cpanel::Easy::OptLib::curlssl;

# cpanel - Cpanel/Easy/OptLib/curlssl.pm          Copyright(c) 2014 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cpanel license. Unauthorized copying is prohibited

my $version = '7.61.1';

sub path_installed {
    my ($easy_obj) = @_;
    my $configure = './configure --prefix=/opt/curlssl/ --without-libssh2 --with-ssl=' . $easy_obj->get_openssl_prefix( { 'skip_mach' => 1 } );
    my ($shortver) = split /\./, $version;

    if ( $easy_obj->get_openssl_prefix( { 'skip_mach' => 1 } ) eq '/opt/openssl' ) {
        my $ldflags = '-L/opt/openssl/lib -Wl,-R/opt/openssl/lib';
        if ( $ENV{'LDFLAGS'} ) {
            $ldflags = $ldflags . ' ' . $ENV{'LDFLAGS'};
        }
        $configure = qq{LDFLAGS="$ldflags" $configure};
    }
    return {
        'name'         => 'Curl w/ SSL',
        'install_path' => '/opt/curlssl/',
        'itis_up2date' => sub {
            `/opt/curlssl/bin/curl -V` =~ m{ curl \s+ \Q$version\E }xms;
        },
        'working_path' => "curl-$shortver",
        'command_list' => [ [qw(patch -N -i ../cppatch_curl-config_libs.patch)], [$configure], ['make'], [qw(make install)], ],
    };
}

1;
