Added TTSchema producer.
[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);
2b2601b5 26check_version('Template' => 2.10 => 1);
4b6a6341 27check_version('Test::More' => 0 => 0);
f74c6517 28check_version('Test::Exception' => 0 => 0);
2b2601b5 29check_version('Test::Differences' => 0 => 1);
4b6a6341 30check_version('Text::ParseWords' => 0 => 0);
31check_version('Text::RecordParser' => 0.02 => 0);
32check_version('XML::Writer' => 0 => 1);
f74c6517 33check_version('XML::XPath' => 0 => 1);
4b6a6341 34
35print "\n";
36
37if (@{$missing{'optional'}} + @{$missing{'required'}}) {
38 print "Some components might not work correctly:\n";
39 my $count;
40 if ($missing{'required'}) {
41 $count = scalar(@{$missing{'required'}});
42 printf " You are missing %d required module%s: %s\n",
43 $count,
44 $count == 1 ? '' : 's',
45 join ', ', @{$missing{'required'}};
46 }
47 if ($missing{'optional'}) {
48 $count = scalar(@{$missing{'optional'}});
49 printf " You are missing %d optional module%s: %s\n",
50 $count,
51 $count == 1 ? '' : 's',
52 join ', ', @{$missing{'optional'}};
53 }
54
55 print "\n";
56}
cfaf3de0 57
58WriteMakefile(
59 'NAME' => __PACKAGE__,
d5a20e63 60 'VERSION_FROM' => 'lib/SQL/Translator.pm',
cfaf3de0 61 'EXE_FILES' => [
9c6b150f 62 'bin/sqlt-diagram.pl',
4b6a6341 63 'bin/sqlt-dumper.pl',
9c6b150f 64 'bin/sqlt-graph.pl',
cfaf3de0 65 'bin/sql_translator.pl',
66 ],
4b6a6341 67 'PREREQ_PM' => \%PREREQ_PM,
68 'clean' => {
69 FILES => '$(DISTVNAME).tar$(SUFFIX)',
7a8e1f51 70 },
cfaf3de0 71);
4b6a6341 72
73# ----------------------------------------------------------------------
74# check_version($module, $version, $optional)
75#
76# Takes a module name, optional version number, and a flag indicating
77# whether the module is optional (default is no).
78# ----------------------------------------------------------------------
79sub check_version {
80 my ($module, $version, $optional) = @_;
81 my ($dots, $load);
82
83 if ($version) {
84 $load = "$module $version";
85 }
86 else {
87 $load = $module;
88 }
89
90 $dots = '.' x (36 - length($load));
91
92 eval "use $load;";
93 if ($@) {
94 if ($optional) {
95 push @{$missing{'optional'}}, $module;
96 }
97 else {
98 push @{$missing{'required'}}, $module;
99 }
100 print "$load $dots not found!";
101 if ($optional) {
102 print optional('not found!'), "\n";
103 return;
104 }
105 print required('not found!');
106 print "\n";
107 }
108 else {
109 no strict qw(refs);
110 my $version = ${"$module\::VERSION"};
111 print "$load $dots $version";
112 print $optional ? optional($version) : required($version);
113 print "\n";
114 }
115
116 $PREREQ_PM{$module} = $version;
117}
118
119sub optional { return _message("[optional]", @_) }
120sub required { return _message("", @_) }
121
122sub _message {
123 my ($message, $version) = @_;
124 my $size = 24 - (length "$version");
125 my $fmt = '%' . $size . 's';
126 sprintf $fmt => $message;
127}