package Cpanel::Easy::PHP5::Curl;

# cpanel - Cpanel/Easy/PHP5/Curl.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

our $easyconfig = {
    'name'         => 'Curl',
    'ensurepkg'    => [ 'libidn', 'libidn-devel' ],
    'url'          => 'http://www.php.net/manual/en/ref.curl.php',
    'perl_modules' => {
        'LWP::UserAgent' => 1,
    },
    'dryrun' => {
        '0' => {
            'name'    => 'Check CurlSSL selection for PHP 5',
            'command' => sub {
                my ($self) = @_;
                $self->{'__'}{'SKIP'} = $self->get_ns_value_from_profile('Cpanel::Easy::PHP5::CurlSSL');
                if ( $self->{'__'}{'SKIP'} ) {
                    return ( 1, 'Skipping Curl for CurlSSL' );
                }
                else {
                    return ( 1, 'Ok' );
                }
            },
        },
    },
    'step' => {
        '0' => {
            'name'    => 'Find Curl path for PHP 5',
            'command' => sub {
                my ($self) = @_;

                local $ENV{'LDFLAGS'} = $ENV{'LDFLAGS'} . ' -L/usr/lib64' if ( $self->{'cpu_bits'} eq '64' );

                my ( $curlpath, @text ) = $self->get_path_installed('Cpanel::Easy::OptLib::curlnossl');
                if ($curlpath) {
                    $self->{'__'}{'CurlPath'} = $curlpath;
                    return ( 1, 'Ok' );
                }
                else {
                    return $curlpath, @text;
                }
            },
        },
        '1' => {
            'name'    => 'to config options',
            'command' => sub {
                my ($self) = @_;
                $self->add_to_configure( { '--with-curl' => $self->{'__'}{'CurlPath'} } );
                return ( 1, 'Ok' );
            },
        },
    },
};

1;
