package Cpanel::Easy::PHP5::CurlSSL;

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

our $easyconfig = {
    'name'      => 'CurlSSL',
    'ensurepkg' => [ 'libidn', 'libidn-devel', 'ca_root_nss' ],
    'url'       => 'http://www.php.net/manual/en/ref.curl.php',
    'implies'      => { 'Cpanel::Easy::PHP5::Curl' => 0 },
    'perl_modules' => {
        'LWP::UserAgent' => 1,
    },
    'dryrun' => {
        '0' => {
            'name'    => 'Find Curl SSL path for PHP 5',
            'command' => sub {
                my ($self) = @_;

                if ( -d '/usr/kerberos/include' && $ENV{'CFLAGS'} !~ m{/usr/kerberos/include} ) {
                    $ENV{'CFLAGS'} .= ' -I/usr/kerberos/include';
                }

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

                my ( $curlsslpath, @text ) = $self->get_path_installed('Cpanel::Easy::OptLib::curlssl');
                if ($curlsslpath) {
                    $self->{'__'}{'CurlSSLPath'} = $curlsslpath;
                    return ( 1, 'Ok' );
                }
                else {
                    return $curlsslpath, @text;
                }
            },
        },
    },
    'step' => {
        '0' => {
            'name'    => 'Add Curl SSL to configure.',
            'command' => sub {
                my ($self) = @_;
                $self->add_to_configure( { '--with-curl' => $self->{'__'}{'CurlSSLPath'} } );
                return ( 1, 'Ok' );
            },
        },
    },
};

1;
