Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/JSON/JSON-2.58/Makefile.PL

Issue 15736030: Add JSON.pm to third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Check SHA-1 hash Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 require 5.00503;
2 use strict;
3 use ExtUtils::MakeMaker;
4
5 use lib qw( ./lib );
6
7 $| = 1;
8
9 eval q| require JSON |;
10
11 # B module can't install? I'm not careful for such a problem.
12 # Leave us alone today?
13 if ($@) {
14 print "We try to look up lib/JSON.pm, but in vain. B module can't install?\n ";
15 print "Set the environmental variable 'PERL_DL_NONLAZY' with 0.\n";
16 print "And see to ExtUtils::MM_Unix.\n";
17 print "perl says : $@";
18 print "We do not make Makefile by requiring Perl version 7.0.\n";
19 require 7.0000;
20 }
21
22
23 my $version = JSON->VERSION;
24 my $req_xs_ver = JSON->require_xs_version;
25 my $has_xs = 0;
26 my $xs_ver_is_ok;
27 my $message;
28 my $pp_only = $ENV{ PUREPERL_ONLY } || $ENV{ PERL_ONLY } || $ENV{ NO_XS };
29
30 eval q| require JSON::XS |;
31
32 $has_xs = 1 unless ($@);
33
34
35 if ($has_xs) {
36 my $xs_version = JSON::XS->VERSION;
37 if ($xs_version >= $req_xs_ver) {
38 $message = "You have JSON::XS (v.$xs_version), so JSON can work very fas t!!";
39 $xs_ver_is_ok++;
40 }
41 else {
42 $message = "Your JSON::XS version is $xs_version, but if you install v.$ req_xs_ver,\n"
43 . "JSON will work faster.";
44 }
45 }
46 else {
47 $message = "If you install JSON::XS v.$req_xs_ver, it makes JSON faster.";
48 }
49
50 print <<EOF;
51 Welcome to JSON (v.$version)
52 =============================
53 $message
54
55 ************************** CAUTION **************************
56 * This is 'JSON version 2' and there are many differences *
57 * to version 1.xx *
58 * Please check your applications useing old version. *
59 * See to 'INCOMPATIBLE CHANGES TO OLD VERSION' and 'TIPS' *
60 *************************************************************
61
62
63 EOF
64
65 my @prereq_pm;
66
67 if ( not $pp_only and can_auto_xs_install() and not $xs_ver_is_ok ) {
68
69 my $prompt = prompt("Do you want to install JSON::XS?(Y/n)", 'Y');
70
71 if ( $prompt =~ /^[yY]/ ) {
72 @prereq_pm = ( 'JSON::XS' => $req_xs_ver );
73 }
74
75 }
76
77
78 WriteMakefile(
79 'NAME' => 'JSON',
80 'VERSION_FROM' => 'lib/JSON.pm', # finds $VERSION
81 'PREREQ_PM' => {
82 'Test::More' => 0,
83 @prereq_pm,
84 },
85 ($] >= 5.005 ? ## Add these new keywords supported since 5.005
86 (ABSTRACT_FROM => 'lib/JSON.pm', # retrieve abstract from module
87 AUTHOR => 'Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>') : ()),
88 ( $ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE' => 'perl', ) : () ),
89
90 ( $ExtUtils::MakeMaker::VERSION >= 6.46 ? (
91 'META_MERGE' => {
92 resources => {
93 repository => 'https://github.com/makamaka/JSON',
94 },
95 } ) : ()
96 ),
97 );
98
99
100 if ($] < 5.006) { # I saw to http://d.hatena.ne.jp/asakusabashi/20051231/p1
101 open(IN, "Makefile");
102 open(OUT,">Makefile.tmp") || die;
103 while(<IN>) {
104 s/PERL_DL_NONLAZY=1//g;
105 print OUT;
106 }
107 close(OUT);
108 close(IN);
109 rename("Makefile.tmp" => "Makefile");
110 }
111
112
113
114
115 sub can_auto_xs_install {
116 return 0 if $] < 5.008002; # JSON::XS requires
117 return 0 unless ( $ENV{PERL5_CPAN_IS_RUNNING} or $ENV{PERL5_CPANM_IS_RUNNING } ); # not cpan/cpanm running
118 return 0 if $] > 5.017; # JSON::XS test fails.
119 return can_cc();
120 }
121
122
123 # copied from http://cpansearch.perl.org/src/GBARR/Scalar-List-Utils-1.23/Makefi le.PL
124
125 use Config;
126
127
128 sub can_cc {
129
130 require File::Spec;
131
132 foreach my $cmd (split(/ /, $Config::Config{cc})) {
133 my $_cmd = $cmd;
134
135 return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
136
137 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
138 my $abs = File::Spec->catfile($dir, $_[1]);
139 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
140 }
141 }
142
143 return;
144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698