package Cpanel::Easy::OptLib::pcre;

# cpanel - Cpanel/Easy/OptLib/pcre.pm             Copyright(c) 2016 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 = '8.41';

sub path_installed {
    my ( $easy_obj, $prefix ) = @_;
    $prefix ||= '/opt/pcre';

    my @command_list = ();

    return {
        'name'         => 'pcre',
        'install_path' => $prefix,
        'itis_up2date' => sub {
            if (   `$prefix/bin/pcre-config --version` =~ m{ \Q$version\E }xms
                && -e $prefix . '/has_unicode_support'
                && -e $prefix . '/has_lookbehind_fix' ) {
                return 1;
            }
            else {
                return;
            }
        },
        'working_path' => "pcre-8",    # this must remain pcre-8 for historical cpanelsync related reasons
        'command_list' => [
            [ './configure', "--prefix=$prefix", '--enable-utf8', '--enable-unicode-properties', '--disable-cpp' ],
            ['make'],
            [ 'make',  'install' ],
            [ 'touch', $prefix . '/has_unicode_support' ],
            [ 'touch', $prefix . '/has_lookbehind_fix' ],
        ],
    };
}

1;
