Added dependencies from new XML modules.
[dbsrgits/SQL-Translator.git] / Makefile.PL
CommitLineData
cfaf3de0 1package SQL::Translator;
2
3use strict;
4use ExtUtils::MakeMaker;
4b6a6341 5$|++;
6
7my %PREREQ_PM;
8my %missing = (
9 optional => [ ],
10 required => [ ],
11);
12
13print "Checking for required and recommended modules.\n";
14# Module Name Version Optional?
15check_version('Class::Base' => 0 => 0);
16check_version('File::Basename' => 0 => 0);
17check_version('File::Spec' => 0 => 0);
18check_version('GD' => 0 => 1);
19check_version('GraphViz' => 0 => 1);
20check_version('IO::Dir' => 0 => 0);
21check_version('IO::File' => 0 => 0);
22check_version('IO::Scalar' => 0 => 0);
23check_version('Parse::RecDescent' => 1.94 => 0);
24check_version('Pod::Usage' => 0 => 0);
25check_version('Spreadsheet::ParseExcel' => 0 => 1);
26check_version('Test::More' => 0 => 0);
f74c6517 27check_version('Test::Exception' => 0 => 0);
4b6a6341 28check_version('Text::ParseWords' => 0 => 0);
29check_version('Text::RecordParser' => 0.02 => 0);
30check_version('XML::Writer' => 0 => 1);
f74c6517 31check_version('XML::XPath' => 0 => 1);
4b6a6341 32
33print "\n";
34
35if (@{$missing{'optional'}} + @{$missing{'required'}}) {
36 print "Some components might not work correctly:\n";
37 my $count;
38 if ($missing{'required'}) {
39 $count = scalar(@{$missing{'required'}});
40 printf " You are missing %d required module%s: %s\n",
41 $count,
42 $count == 1 ? '' : 's',
43 join ', ', @{$missing{'required'}};
44 }
45 if ($missing{'optional'}) {
46 $count = scalar(@{$missing{'optional'}});
47 printf " You are missing %d optional module%s: %s\n",
48 $count,
49 $count == 1 ? '' : 's',
50 join ', ', @{$missing{'optional'}};
51 }
52
53 print "\n";
54}
cfaf3de0 55
56WriteMakefile(
57 'NAME' => __PACKAGE__,
d5a20e63 58 'VERSION_FROM' => 'lib/SQL/Translator.pm',
cfaf3de0 59 'EXE_FILES' => [
9c6b150f 60 'bin/sqlt-diagram.pl',
4b6a6341 61 'bin/sqlt-dumper.pl',
9c6b150f 62 'bin/sqlt-graph.pl',
cfaf3de0 63 'bin/sql_translator.pl',
64 ],
4b6a6341 65 'PREREQ_PM' => \%PREREQ_PM,
66 'clean' => {
67 FILES => '$(DISTVNAME).tar$(SUFFIX)',
7a8e1f51 68 },
cfaf3de0 69);
4b6a6341 70
71# ----------------------------------------------------------------------
72# check_version($module, $version, $optional)
73#
74# Takes a module name, optional version number, and a flag indicating
75# whether the module is optional (default is no).
76# ----------------------------------------------------------------------
77sub check_version {
78 my ($module, $version, $optional) = @_;
79 my ($dots, $load);
80
81 if ($version) {
82 $load = "$module $version";
83 }
84 else {
85 $load = $module;
86 }
87
88 $dots = '.' x (36 - length($load));
89
90 eval "use $load;";
91 if ($@) {
92 if ($optional) {
93 push @{$missing{'optional'}}, $module;
94 }
95 else {
96 push @{$missing{'required'}}, $module;
97 }
98 print "$load $dots not found!";
99 if ($optional) {
100 print optional('not found!'), "\n";
101 return;
102 }
103 print required('not found!');
104 print "\n";
105 }
106 else {
107 no strict qw(refs);
108 my $version = ${"$module\::VERSION"};
109 print "$load $dots $version";
110 print $optional ? optional($version) : required($version);
111 print "\n";
112 }
113
114 $PREREQ_PM{$module} = $version;
115}
116
117sub optional { return _message("[optional]", @_) }
118sub required { return _message("", @_) }
119
120sub _message {
121 my ($message, $version) = @_;
122 my $size = 24 - (length "$version");
123 my $fmt = '%' . $size . 's';
124 sprintf $fmt => $message;
125}