| 1 | #!perl |
|---|
| 2 | # $Id$ |
|---|
| 3 | # |
|---|
| 4 | # Copyright (c) 2006-2008 Daisuke Maki <daisuke@endeworks.jp> |
|---|
| 5 | # All rights reserved. |
|---|
| 6 | |
|---|
| 7 | use strict; |
|---|
| 8 | use ExtUtils::MakeMaker; |
|---|
| 9 | |
|---|
| 10 | my $debugging = 0; |
|---|
| 11 | for(my $i = 0; $i < @ARGV; $i++) { |
|---|
| 12 | if ($ARGV[$i] =~ /^--debugging$/) { |
|---|
| 13 | splice(@ARGV, $i, 1); |
|---|
| 14 | $debugging = 1; |
|---|
| 15 | $i--; |
|---|
| 16 | } |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | my $result = do 'tools/probe_mecab.pl'; |
|---|
| 21 | die if $@; |
|---|
| 22 | |
|---|
| 23 | print |
|---|
| 24 | "Detected the following mecab information:\n", |
|---|
| 25 | " version: $result->{version}\n", |
|---|
| 26 | " cflags: $result->{cflags}\n", |
|---|
| 27 | " libs: $result->{libs}\n" |
|---|
| 28 | ; |
|---|
| 29 | |
|---|
| 30 | # XXX - I want to include this in future releases, but I don't know if |
|---|
| 31 | # it works with Win32 properly (i.e., untested) |
|---|
| 32 | # use Devel::CheckLib; |
|---|
| 33 | # check_lib_or_exit( |
|---|
| 34 | # lib => 'mecab', |
|---|
| 35 | # LIBS => join(' ', split(/\s+/, $result->{libs})), |
|---|
| 36 | # ); |
|---|
| 37 | |
|---|
| 38 | $result->{cflags} ||= ''; |
|---|
| 39 | $result->{cflags} .= ' -I src'; |
|---|
| 40 | |
|---|
| 41 | # Hack. I don't like the layout where .xs files are on the top level. |
|---|
| 42 | link("lib/Text/MeCab.xs", "MeCab.xs"); |
|---|
| 43 | |
|---|
| 44 | my @define = ( |
|---|
| 45 | "-DTEXT_MECAB_ENCODING='\"$result->{encoding}\"'", |
|---|
| 46 | "-DTEXT_MECAB_CONFIG='\"$result->{config}\"'", |
|---|
| 47 | ); |
|---|
| 48 | if ($debugging) { |
|---|
| 49 | push @define, "-DTEXT_MECAB_DEBUG=1"; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | my %INFO = ( |
|---|
| 53 | ABSTRACT => 'Alternative Interface To libmecab', |
|---|
| 54 | AUTHOR => 'Daisuke Maki <daisuke@endeworks.jp>', |
|---|
| 55 | CCFLAGS => $result->{cflags}, |
|---|
| 56 | DEFINE => join( " ", @define ), |
|---|
| 57 | DISTNAME => 'Text-MeCab', |
|---|
| 58 | INSTALLDIRS => 'site', |
|---|
| 59 | LIBS => [ split(/\s+/, $result->{libs}) ], |
|---|
| 60 | NAME => 'Text::MeCab', |
|---|
| 61 | OBJECT => '$(O_FILES)', |
|---|
| 62 | PREREQ_PM => { |
|---|
| 63 | # 'Devel::CheckLib' => 0, |
|---|
| 64 | 'Encode' => 0, |
|---|
| 65 | 'Exporter' => 0, |
|---|
| 66 | 'File::Spec' => 0, |
|---|
| 67 | 'Test::More' => 0, |
|---|
| 68 | }, |
|---|
| 69 | VERSION_FROM => 'lib/Text/MeCab.pm', |
|---|
| 70 | clean => { |
|---|
| 71 | FILES => 'lib/typemap MeCab.xs' |
|---|
| 72 | }, |
|---|
| 73 | test => { |
|---|
| 74 | TESTS => 't/*.t t/*/*.t' |
|---|
| 75 | } |
|---|
| 76 | ); |
|---|
| 77 | $INFO{OPTIMIZE} = '-g' if $debugging; |
|---|
| 78 | |
|---|
| 79 | WriteMakefile(%INFO); |
|---|