| 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 | |
|---|
| 49 | if ($^O eq 'MSWin32') { # save us, the Win32 puppies |
|---|
| 50 | @define = ( |
|---|
| 51 | qq(-DTEXT_MECAB_ENCODING=\\"$result->{encoding}\\"), |
|---|
| 52 | qq(-DTEXT_MECAB_CONFIG=\\"$result->{config}\\"), |
|---|
| 53 | ); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | if ($debugging) { |
|---|
| 57 | push @define, "-DTEXT_MECAB_DEBUG=1"; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | my %INFO = ( |
|---|
| 61 | ABSTRACT => 'Alternative Interface To libmecab', |
|---|
| 62 | AUTHOR => 'Daisuke Maki <daisuke@endeworks.jp>', |
|---|
| 63 | CCFLAGS => $result->{cflags}, |
|---|
| 64 | DEFINE => join( " ", @define ), |
|---|
| 65 | DISTNAME => 'Text-MeCab', |
|---|
| 66 | INSTALLDIRS => 'site', |
|---|
| 67 | LIBS => [ split(/\s+/, $result->{libs}) ], |
|---|
| 68 | NAME => 'Text::MeCab', |
|---|
| 69 | OBJECT => '$(O_FILES)', |
|---|
| 70 | PREREQ_PM => { |
|---|
| 71 | # 'Devel::CheckLib' => 0, |
|---|
| 72 | 'Class::Accessor::Fast' => 0, |
|---|
| 73 | 'Encode' => 0, |
|---|
| 74 | 'Exporter' => 0, |
|---|
| 75 | 'File::Spec' => 0, |
|---|
| 76 | 'Test::More' => 0, |
|---|
| 77 | 'Path::Class' => 0, |
|---|
| 78 | }, |
|---|
| 79 | VERSION_FROM => 'lib/Text/MeCab.pm', |
|---|
| 80 | clean => { |
|---|
| 81 | FILES => 'lib/typemap MeCab.xs' |
|---|
| 82 | }, |
|---|
| 83 | test => { |
|---|
| 84 | TESTS => 't/*.t t/*/*.t' |
|---|
| 85 | } |
|---|
| 86 | ); |
|---|
| 87 | $INFO{OPTIMIZE} = '-g' if $debugging; |
|---|
| 88 | |
|---|
| 89 | WriteMakefile(%INFO); |
|---|