package Cpanel::Easy::OptLib::mono;

# cpanel - Cpanel/Easy/OptLib/mono.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

sub path_installed {
    my ($easy_obj) = @_;

    # need to tell this where glib2 is this way:
    # # -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
    # local $ENV{'CFLAGS'} =  '-I/opt/glib2/include/glib-2.0 -I/opt/glib2/lib/glib-2.0/include ' . $ENV{'CFLAGS'};
    # return $self->get_path_installed('Cpanel::Easy::OptLib::mono');

    my $configure = './configure --prefix=/opt/mono --with-sigaltstack=no --with-mcs-docs=no';

    my $command_list = [ [qw(patch -p1 -i ../mono_mcs_net_2_1.patch)], [$configure] ];

    push @{$command_list}, ['make LANG=C EXTERNAL_MCS=false EXTERNAL_RUNTIME=false'], [ 'make', 'install' ];

    return {
        'name'         => 'mono',
        'install_path' => '/opt/mono/',
        'itis_up2date' => sub {
            if ( `/opt/mono/bin/mono --version` =~ m{ 2 [.] 6 [.] 7 }xms ) {
                my $glib2_mtime = ( stat('/opt/glib2/bin/glib-genmarchal') )[9];
                my $mono_mtime  = ( stat('/opt/mono/bin/mono') )[9];
                return $mono_mtime > $glib2_mtime;
            }
            return 0;
        },
        'working_path' => 'mono-2.6.7',
        'command_list' => $command_list,
    };
}

1;
