Changeset 8875 for lang/perl/Alien-MeCab

Show
Ignore:
Timestamp:
04/04/08 17:41:34 (8 months ago)
Author:
daisuke
Message:

lang/perl/Alien-MeCab?; apply patch from osawa -- should work on windows. *should* work

Location:
lang/perl/Alien-MeCab/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Alien-MeCab/trunk/Makefile.PL

    r8712 r8875  
    2121my $MECAB_BASENAME   = "mecab-$MECAB_VERSION.tar.gz"; 
    2222my $MECAB_SOURCE     = File::Spec->catfile("src", $MECAB_BASENAME); 
     23my $MECAB_EXE        = File::Spec->catfile("src", "mecab-$MECAB_VERSION.exe") if $^O eq 'MSWin32'; 
    2324 
    2425eval { 
     
    4647 
    4748# Ask if we want to download the source. 
    48 if (! -f $MECAB_SOURCE) { 
    49     my $yn = prompt("mecab source file $MECAB_SOURCE does not exist. Download it now?", "y"); 
     49my $sourcefile; 
     50my $test; 
     51$sourcefile = ($^O eq 'MSWin32') ? $MECAB_EXE 
     52                                 : $MECAB_SOURCE; 
     53$test = ($^O eq 'MSWin32') ? "win\n" 
     54                           : "other\n"; 
     55if (! -f $sourcefile) { 
     56    my $yn = prompt("mecab source file $sourcefile does not exist. Download it now?", "y"); 
    5057    if ($yn =~ /^y(?:es)?$/i) { 
    5158        my @cmd = ($^X, File::Spec->catfile("src", "fetchsrc.pl"), "--version", $MECAB_VERSION); 
     
    5562 
    5663# If the source hasn't been expanded, then unpack it 
    57 if (! -d $MECAB_SOURCE_DIR) { 
    58     my $yn = prompt("Mecab source directory has not been unpacked yet. Unpack it now?", "y"); 
    59     if ($yn =~ /^y(?:es)?$/i) { 
    60         eval { 
    61             require Archive::Tar; 
    62             Archive::Tar->can_handle_compressed_files or die "No compression support :("; 
    63         }; 
    64         if ($@) { 
    65             print STDERR "Archive extraction requires Archive::Tar (with IO::Zlib)\n"; 
    66             exit 0; 
     64if ($^O ne 'MSWin32') { 
     65    if (! -d $MECAB_SOURCE_DIR) { 
     66        my $yn = prompt("Mecab source directory has not been unpacked yet. Unpack it now?", "y"); 
     67        if ($yn =~ /^y(?:es)?$/i) { 
     68            eval { 
     69                require Archive::Tar; 
     70                Archive::Tar->can_handle_compressed_files or die "No compression support :("; 
     71            }; 
     72            if ($@) { 
     73                print STDERR "Archive extraction requires Archive::Tar (with IO::Zlib)\n"; 
     74                exit 0; 
     75            } 
     76 
     77            eval { 
     78                chdir File::Spec->catfile($CURDIR, 'src'); 
     79 
     80                print "Unpacking... (please be patient)\n"; 
     81                Archive::Tar->extract_archive( $MECAB_BASENAME, 1 ); 
     82            }; 
     83            if ($@) { 
     84                print STDERR "Failed to gunzip file $MECAB_SOURCE $IO::Compress::Gunzip::GunzipError\n"; 
     85                chdir $CURDIR; 
     86                exit 0; 
     87            } 
     88            chdir $CURDIR; 
     89        } 
     90    } 
     91 
     92    { 
     93        print "\n"; 
     94        my $run_configure; 
     95        if( -e File::Spec->catfile($MECAB_SOURCE_DIR, 'config.status')) { 
     96            $run_configure = prompt( 
     97                "Looks like MeCab has already been configured.\n". 
     98                "Do you want to re-run configure?", 
     99                "n" 
     100            ); 
     101        } else { 
     102            $run_configure = prompt( 
     103                "No config.status found. Run MeCab's configure now?", 'y' 
     104            ); 
    67105        } 
    68106 
    69         eval { 
    70             chdir File::Spec->catfile($CURDIR, 'src'); 
     107        if( $run_configure =~ /^y/i ) { 
     108            my $configure_args = prompt( 
     109                "\nWould you like to pass any arguments to configure?",  
     110            ); 
    71111 
    72             print "Unpacking... (please be patient)\n"; 
    73             Archive::Tar->extract_archive( $MECAB_BASENAME, 1 ); 
    74         }; 
    75         if ($@) { 
    76             print STDERR "Failed to gunzip file $MECAB_SOURCE $IO::Compress::Gunzip::GunzipError\n"; 
    77             chdir $CURDIR; 
    78             exit 0; 
    79         } 
    80         chdir $CURDIR; 
    81     } 
    82 } 
     112            print "\nMeCab will be configured with the following arguments:\n", 
     113                "  $configure_args\n"; 
    83114 
    84 { 
    85     print "\n"; 
    86     my $run_configure; 
    87     if( -e File::Spec->catfile($MECAB_SOURCE_DIR, 'config.status')) { 
    88         $run_configure = prompt( 
    89             "Looks like MeCab has already been configured.\n". 
    90             "Do you want to re-run configure?", 
    91             "n" 
    92         ); 
    93     } else { 
    94         $run_configure = prompt( 
    95             "No config.status found. Run MeCab's configure now?", 'y' 
    96         ); 
    97     } 
    98  
    99     if( $run_configure =~ /^y/i ) { 
    100         my $configure_args = prompt( 
    101             "\nWould you like to pass any arguments to configure?",  
    102         ); 
    103  
    104         print "\nMeCab will be configured with the following arguments:\n", 
    105             "  $configure_args\n"; 
    106  
    107         chdir $MECAB_SOURCE_DIR; 
    108         my @cmd = (File::Spec->catfile($MECAB_SOURCE_DIR, "configure"), 
    109             split(/\s+/, $configure_args)); 
    110         if (system(@cmd) != 0) { 
    111             print <<"END"; 
     115            chdir $MECAB_SOURCE_DIR; 
     116            my @cmd = (File::Spec->catfile($MECAB_SOURCE_DIR, "configure"), 
     117                split(/\s+/, $configure_args)); 
     118            if (system(@cmd) != 0) { 
     119                print <<"END"; 
    112120configure $configure_args failed: $! 
    113121    Something went wrong with the MeCab configuration. 
    114122    You should correct it and re-run Makefile.PL. 
    115123END 
     124                chdir $CURDIR; 
     125                exit 0; 
     126            } 
    116127            chdir $CURDIR; 
    117             exit 0; 
    118128        } 
    119         chdir $CURDIR; 
    120129    } 
    121130} 
     
    151160 
    152161sub postamble { 
    153     return <<'MAKE_FRAG' 
     162    my $make_str; 
     163 
     164        if ($^O eq 'MSWin32') { 
     165        $make_str = <<MAKE_FRAG; 
     166libmecab: 
     167        $MECAB_EXE 
     168 
     169MAKE_FRAG 
     170    } else { 
     171        $make_str = <<'MAKE_FRAG'; 
    154172libmecab: 
    155173        cd $(MECAB_SRC) && $(MAKE) all 
    156174 
     175MAKE_FRAG 
     176    } 
     177 
     178    $make_str .= <<'MAKE_FRAG'; 
    157179fetchsrc: 
    158180        $(PERL) fetchsrc.pl 
    159181 
    160182MAKE_FRAG 
     183 
     184    return $make_str; 
    161185} 
    162186 
  • lang/perl/Alien-MeCab/trunk/lib/Alien/MeCab.pm

    r8712 r8875  
    1414 
    1515Alien::MeCab - Wrapper For Installing MeCab 
     16 
     17=head1 DESCRIPTION 
     18 
     19Alien::MeCab is a wrapper to install MeCab library. Modules that depend on 
     20MeCab can depend on Alien::MeCab and use the CPAN shell to install it for you 
     21 
     22Currently does not work on Win32 
     23 
     24=cut 
  • lang/perl/Alien-MeCab/trunk/src/fetchsrc.pl

    r8712 r8875  
    22use strict; 
    33use warnings; 
     4use File::Spec; 
    45use Getopt::Long; 
    56use LWP::UserAgent; 
     
    3233    } 
    3334 
    34  
    3535    if( ! GetOptions(\%config, "version=s") ) { 
    3636        exit 1; 
     
    3838 
    3939    my $tgz   = "mecab-$config{version}.tar.gz"; 
    40     my $local = "src/$tgz"; 
    41     my $url   = "$download_base_url/mecab/$tgz"; 
     40    my $exe   = "mecab-$config{version}.exe"; 
     41     
     42    my ($local, $url); 
     43    if ($^O eq 'MSWin32') { 
     44        $local = File::Spec->catfile('src', $exe); 
     45        $url   = "$download_base_url/mecab/$exe"; 
     46    } 
     47    else { 
     48        $local = File::Spec->catfile('src', $tgz); 
     49        $url   = "$download_base_url/mecab/$tgz"; 
     50    } 
    4251 
    4352    my $ua = LWP::UserAgent->new(