root/lang/perl/DateTimeX-Lite/trunk/Makefile.PL @ 30361

Revision 30361, 2.8 kB (checked in by tokuhirom, 6 years ago)

custom install the TimeZone/Locale?.

  • Property svn:keywords set to Id
Line 
1use strict;
2use lib 'inc';
3use Cwd;
4use inc::Module::Install;
5use File::Copy;
6use File::Copy::Recursive qw/rcopy/;
7use File::Remove qw/remove/;
8
9my $CLDR_VERSION = $ENV{CLDR_VERSION} || '1.6.1';
10my $AUTHOR_MODE  = $ENV{AUTHOR_MODE}  ||
11    (-d '.svn' || Cwd::cwd() =~ /\bsvk\b/i || -d '.git');
12
13name('DateTimeX-Lite');
14all_from('lib/DateTimeX/Lite.pm');
15
16requires 'SelfLoader';
17requires 'Scalar::Util';
18requires 'Time::Local';
19requires 'List::MoreUtils';
20if ($^O eq 'MSWin32') {
21    requires 'Win32::TieRegistry';
22}
23
24# check if we have /something/ in the timezone/locale directory
25# XXX FIXME
26if ($AUTHOR_MODE) {
27    # XXX FIXME: locale generator should NOT depend on Moose
28
29    if (! -f 'dat/DateTimeX/Lite/Locale/en_US.dat') {
30        my $y_n = prompt("You don't seem to have locale  data generated.\nWould you like to download the cldr database and create them?", "y");
31        if ($y_n =~ /^y(?:es)?$/i) {
32            system($^X, "tools/locale/update-locales.pl", "--version", $CLDR_VERSION);
33        }
34    }
35
36    if (! -f 'dat/DateTimeX/Lite/TimeZone/Asia/Tokyo.dat' ) {
37        my $y_n = prompt("You don't seem to have time zone data generated.\nWould you like to download the olson database and create them? (this requires sudo)", "y");
38        if ($y_n =~ /^y(?:es)?$/i) {
39            system($^X, "tools/timezone/update-timezones.pl");
40        }
41    }
42
43}
44
45{
46    my $y_n = prompt('do you want to install all locale/timezone?', 'y');
47    remove(\'-rf' => 'share') if -d 'share';
48    if ($y_n =~ /^y(?:es)?$/i) {
49        rcopy('dat', 'share') or die $!;
50    } else {
51        my $files = prompt('what do you want?', 'Locale/en_US,Locale/ja_JP,TimeZone/Asia/Tokyo');
52        # FIXME: not so smart...
53        mkdir 'share';
54        mkdir 'share/DateTimeX';
55        mkdir 'share/DateTimeX/Lite';
56        mkdir 'share/DateTimeX/Lite/Locale';
57        mkdir 'share/DateTimeX/Lite/TimeZone';
58        mkdir "share/DateTimeX/Lite/TimeZone/$_" for qw/Africa America Antarctica Asia Atlantic Australia Europe Indian Pacific/;
59        for my $f (split(/,/, $files), 'Locale/Aliases') {
60            copy "dat/DateTimeX/Lite/${f}.dat", "share/DateTimeX/Lite/${f}.dat" or die "$f: $!";
61        }
62    }
63}
64
65my $postamble = <<"EOM";
66CLDR_VERSION=$CLDR_VERSION
67EOM
68
69$postamble .= <<'EOM';
70timezone:
71        $(NOECHO)$(FULLPERLRUN) tools/timezone/update-timezones.pl
72
73locale:
74        $(NOECHO)$(FULLPERLRUN) tools/locale/update-locales.pl --version=$(CLDR_VERSION)
75
76benchmark: pure_all
77        $(NOECHO)$(FULLPERLRUN) -Mblib tools/benchmark/simple_create.pl
78
79profile: pure_all
80        $(NOECHO)$(FULLPERLRUN) -Mblib tools/profile/simple_create.pl
81
82config ::
83        $(NOECHO) $(MOD_INSTALL) "share" $(INST_LIB)
84EOM
85postamble $postamble;
86
87build_requires 'File::Copy::Recursive';
88no_index directory => 'tools';
89tests 't/*.t t/*/*.t';
90#   makemaker_args(
91#       PMLIBDIRS => ['lib', 'dat'],
92#   );
93WriteAll();
94
95# TODO: Ask the user which timezones they want.
Note: See TracBrowser for help on using the browser.