Changeset 8875 for lang/perl/Alien-MeCab
- Timestamp:
- 04/04/08 17:41:34 (8 months ago)
- Location:
- lang/perl/Alien-MeCab/trunk
- Files:
-
- 3 modified
-
Makefile.PL (modified) (4 diffs)
-
lib/Alien/MeCab.pm (modified) (1 diff)
-
src/fetchsrc.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Alien-MeCab/trunk/Makefile.PL
r8712 r8875 21 21 my $MECAB_BASENAME = "mecab-$MECAB_VERSION.tar.gz"; 22 22 my $MECAB_SOURCE = File::Spec->catfile("src", $MECAB_BASENAME); 23 my $MECAB_EXE = File::Spec->catfile("src", "mecab-$MECAB_VERSION.exe") if $^O eq 'MSWin32'; 23 24 24 25 eval { … … 46 47 47 48 # 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"); 49 my $sourcefile; 50 my $test; 51 $sourcefile = ($^O eq 'MSWin32') ? $MECAB_EXE 52 : $MECAB_SOURCE; 53 $test = ($^O eq 'MSWin32') ? "win\n" 54 : "other\n"; 55 if (! -f $sourcefile) { 56 my $yn = prompt("mecab source file $sourcefile does not exist. Download it now?", "y"); 50 57 if ($yn =~ /^y(?:es)?$/i) { 51 58 my @cmd = ($^X, File::Spec->catfile("src", "fetchsrc.pl"), "--version", $MECAB_VERSION); … … 55 62 56 63 # 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; 64 if ($^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 ); 67 105 } 68 106 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 ); 71 111 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"; 83 114 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"; 112 120 configure $configure_args failed: $! 113 121 Something went wrong with the MeCab configuration. 114 122 You should correct it and re-run Makefile.PL. 115 123 END 124 chdir $CURDIR; 125 exit 0; 126 } 116 127 chdir $CURDIR; 117 exit 0;118 128 } 119 chdir $CURDIR;120 129 } 121 130 } … … 151 160 152 161 sub postamble { 153 return <<'MAKE_FRAG' 162 my $make_str; 163 164 if ($^O eq 'MSWin32') { 165 $make_str = <<MAKE_FRAG; 166 libmecab: 167 $MECAB_EXE 168 169 MAKE_FRAG 170 } else { 171 $make_str = <<'MAKE_FRAG'; 154 172 libmecab: 155 173 cd $(MECAB_SRC) && $(MAKE) all 156 174 175 MAKE_FRAG 176 } 177 178 $make_str .= <<'MAKE_FRAG'; 157 179 fetchsrc: 158 180 $(PERL) fetchsrc.pl 159 181 160 182 MAKE_FRAG 183 184 return $make_str; 161 185 } 162 186 -
lang/perl/Alien-MeCab/trunk/lib/Alien/MeCab.pm
r8712 r8875 14 14 15 15 Alien::MeCab - Wrapper For Installing MeCab 16 17 =head1 DESCRIPTION 18 19 Alien::MeCab is a wrapper to install MeCab library. Modules that depend on 20 MeCab can depend on Alien::MeCab and use the CPAN shell to install it for you 21 22 Currently does not work on Win32 23 24 =cut -
lang/perl/Alien-MeCab/trunk/src/fetchsrc.pl
r8712 r8875 2 2 use strict; 3 3 use warnings; 4 use File::Spec; 4 5 use Getopt::Long; 5 6 use LWP::UserAgent; … … 32 33 } 33 34 34 35 35 if( ! GetOptions(\%config, "version=s") ) { 36 36 exit 1; … … 38 38 39 39 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 } 42 51 43 52 my $ua = LWP::UserAgent->new(
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)