Bump M::I dep to a version not abusing FindBin
[dbsrgits/SQL-Translator.git] / Makefile.PL
1 use inc::Module::Install 1.00;
2 use strict;
3 use warnings;
4
5 # to deal wuth x.y.z versions properly
6 configure_requires 'ExtUtils::MakeMaker' => 6.54;
7
8 my $deps = {
9   requires => {
10     'Class::Base'              => 0,
11     'Class::Data::Inheritable' => 0.02,
12     'Class::MakeMethods'       => 0,
13     'Digest::SHA1'             => 2.00,
14     'Carp::Clan'               => 0,
15     'IO::Dir'                  => 0,
16     'IO::Scalar'               => 2.110,
17     'Parse::RecDescent'        => 1.962002,
18     'Pod::Usage'               => 0,
19     'Class::Accessor::Fast'    => 0,
20     'DBI'                      => 0,
21     'File::ShareDir'           => 1.0,
22     'File::Spec'               => 0,
23     'Scalar::Util'             => 0,
24     'XML::Writer'              => 0.500,
25   },
26   recommends => {
27     'Template'                 => 2.20,
28     'GD'                       => 0,
29     'GraphViz'                 => 0,
30     'Graph::Directed'          => 0,
31     'Spreadsheet::ParseExcel'  => 0.41,
32     'Text::ParseWords'         => 0,
33     'Text::RecordParser'       => 0.02,
34     'XML::LibXML'              => 1.69,
35   },
36   test_requires => {
37     'YAML'                     => 0.66,
38     'File::Basename'           => 0,
39     'Test::More'               => 0.6,
40     'Test::Differences'        => 0,
41     'Test::Exception'          => 0,
42   },
43 };
44
45 perl_version '5.005';
46
47 name        'SQL-Translator';
48 author      'Ken Youens-Clark <kclark@cpan.org>';
49 abstract    'SQL DDL transformations and more';
50 license     'gpl';
51 repository  'https://sqlfairy.svn.sourceforge.net/svnroot/sqlfairy';
52 bugtracker  'http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
53
54 resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
55
56 all_from    'lib/SQL/Translator.pm';
57
58
59 for my $type (qw/requires recommends test_requires/) {
60   no strict qw/refs/;
61   my $f = \&$type;
62   for my $mod (keys %{$deps->{$type} || {} }) {
63     $f->($mod, $deps->{$type}{$mod});
64   }
65 }
66
67 tests_recursive ();
68
69 install_script (qw|
70   script/sqlt-diagram
71   script/sqlt-diff
72   script/sqlt-diff-old
73   script/sqlt-dumper
74   script/sqlt-graph
75   script/sqlt
76 |);
77
78 install_share();
79
80 auto_provides();
81
82 auto_install();
83
84 if ($Module::Install::AUTHOR) {
85   _recompile_grammars();
86   _recreate_rt_source();
87 }
88
89 WriteAll();
90
91
92 sub _recompile_grammars {
93   # placeholder, will be used to recompile P::RD parsers before shipping
94   # will also allow to lose dependency on P::RD
95 }
96
97 sub _recreate_rt_source {
98   my $base_xml = "t/data/roundtrip.xml";
99   my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
100
101   print "Updating $autogen_yaml\n";
102
103   unlink $autogen_yaml;
104
105   eval {
106
107     use lib 'lib';
108
109     require SQL::Translator;
110     require SQL::Translator::Parser::XML;
111
112     open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
113
114     my $tr = SQL::Translator->new;
115     my $yaml = $tr->translate (
116       parser => 'XML',
117       file => $base_xml,
118       producer => 'YAML',
119     ) or  die sprintf ("Unable to translate %s to YAML: %s\n",
120               $base_xml,
121               $tr->error || 'error unknown'
122           );
123
124     print $fh $yaml;
125     close $fh;
126   };
127
128   if ($@) {
129     print <<EOE;
130
131 =========================================================================
132 ===============              FATAL ERROR                =================
133 =========================================================================
134
135 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
136 Aborting Makefile generation.
137
138 $@
139
140 EOE
141     exit 1;
142   }
143 }