Alien-MeCab
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
#!perl
use strict;
use Cwd ();
use inc::Devel::CheckLib;
use ExtUtils::MakeMaker;
use File::Spec;
my $CURDIR = Cwd::cwd();
# Here's the file that we're going to use to extract some data
my $SPEC_FILE = 'lib/Alien/MeCab.pm';
# Check for hellish-ness
my $RUNNING_IN_HELL = $^O eq 'MSWin32';
# Get the version
my $DIST_VERSION = do {
require ExtUtils::MM_Unix;
ExtUtils::MM_Unix->parse_version($SPEC_FILE);
};
# Actual mecab version. This is the number up to the second fractional digit
# of the dist version
my $MECAB_VERSION = substr($DIST_VERSION, 0, 4);
# Filenames
my $MECAB_SOURCE_DIR = File::Spec->catfile("src", "mecab-$MECAB_VERSION");
my $MECAB_BASENAME = "mecab-$MECAB_VERSION.tar.gz";
my $MECAB_SOURCE = File::Spec->catfile("src", $MECAB_BASENAME);
my $MECAB_EXE = File::Spec->catfile("src", "mecab-$MECAB_VERSION.exe");
# Absolut-ize all paths
$MECAB_SOURCE_DIR = File::Spec->rel2abs($MECAB_SOURCE_DIR);
$MECAB_SOURCE = File::Spec->rel2abs($MECAB_SOURCE);
$MECAB_EXE = File::Spec->rel2abs($MECAB_EXE);
my %REQUIRES;
# Construct the necessary flags
my $CCFLAGS = $ENV{CCFLAGS};
my $LDFLAGS = $ENV{LDFLAGS};
if (! $RUNNING_IN_HELL) {
$CCFLAGS ||= '-I/usr/local/include';
$LDFLAGS ||= '-L/usr/local/lib';
}
if (! $RUNNING_IN_HELL) {
eval {
Devel::CheckLib::assert_lib(lib => "iconv", LIBS => $LDFLAGS);
};
if ($@) {
print <<EOM;
*** Whoa! libiconv was not detected! ***
MeCab requires libiconv to work properly. You can either
(1) install it yourself by hand, or
(2) install it via Alien::Iconv
EOM
my $yn = prompt("Would you like to add Alien::Iconv to prerequisite modules?", "y");
if ($yn !~ /^y(?:es)?$/) {
print <<EOM;
You chose not to install libiconv. Please install it manually and
re-run perl Makefile.PL for Alien::MeCab.
EOM
exit 0;
}
$REQUIRES{ 'Alien::MeCab' } = '1.12001';
}
}
eval {
Devel::CheckLib::assert_lib(lib => "mecab", LIBS => $LDFLAGS )
};
if (! $@) {
print <<EOM;
*** Whoa! We've detected a previous installtion of libmecab ***
Because Alien::MeCab may have been called to be installed from a dependency
of another module, we want to make sure that you *really* want to install
this version of Alien::MeCab (and therefore libmecab).
If you answer "y", then We're going to install
libmecab: $MECAB_VERSION
This operation may OVERWRITE your previous installation
EOM
my $yn = prompt("Really install?", "n");
if ($yn !~ /^y(?:es)?$/) {
exit 0;
}
}
# Ask if we want to download the source.
( run in 0.817 second using v1.01-cache-2.11-cpan-0068ddc7af1 )