Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 1216 lines (946 sloc) 36.555 kb
a4123f8 @abw 2.04b
authored
1 #!/usr/bin/perl -w # -*- perl -*-
2
3 use strict;
4
5 use lib qw( ./lib );
714a8cd @abw * prep for release 2.07a
authored
6 use Config;
7 use File::Spec::Functions qw( catfile );
a4123f8 @abw 2.04b
authored
8 use Template;
9 use ExtUtils::MakeMaker;
c8d76d4 @abw *** empty log message ***
authored
10 use Cwd;
3ebfa07 @abw Initial revision
authored
11
e39913f @abw *** empty log message ***
authored
12 select STDERR;
13 $| = 1;
14 select STDOUT;
15
a4123f8 @abw 2.04b
authored
16 use vars qw( $TT_VERSION $TT_PREFIX $TT_IMAGES $TT_RUN_DBI
ea05afc @abw * applied patch from Axel Gerstmair to add TT_EXTRAS option to Makefile....
authored
17 $TT_BUILD_DOCS $TT_SPLASH_DOCS $TT_EXAMPLES $TT_EXTRAS
a4123f8 @abw 2.04b
authored
18 $TT_LATEX_ENABLE $TT_LATEX_PATH $TT_PDFLATEX_PATH $TT_DVIPS_PATH
9be7d64 @abw approaching 2.04d
authored
19 $TT_XS_ENABLE $TT_XS_DEFAULT
a4123f8 @abw 2.04b
authored
20 $TT_SPLASH_THEME $TT_QUIET $TT_ACCEPT $TT_YES );
21
22 # check O/S to set sensible defaults
9be7d64 @abw approaching 2.04d
authored
23
24 my ($WIN32, $FLAVOUR, $PREFIX, $IMAGES, $MAKE);
dd62af1 @abw * Applied Chris' patch to fix win => MSWin32
authored
25 if ($^O eq 'MSWin32') { # any others also?
a4123f8 @abw 2.04b
authored
26 $WIN32 = 1;
27 $FLAVOUR = 'Win32';
28 $PREFIX = 'C:/Program Files/Template Toolkit 2';
9be7d64 @abw approaching 2.04d
authored
29 $IMAGES = '/tt2/images';
a4123f8 @abw 2.04b
authored
30 $MAKE = 'nmake';
31 }
32 else {
33 $WIN32 = 0;
34 $FLAVOUR = 'Unix';
35 $PREFIX = '/usr/local/tt2';
9be7d64 @abw approaching 2.04d
authored
36 $IMAGES = '/tt2/images';
a4123f8 @abw 2.04b
authored
37 $MAKE = 'make';
38 }
39
9be7d64 @abw approaching 2.04d
authored
40
41 # read command line args putting TT_* into $ttconfig and
42 # everything else (regular Makefile.PL args, e.g. PREFIX)
43 # goes into $config
44
a4123f8 @abw 2.04b
authored
45 my (%config, %ttconfig);
46 while ($_ = shift) {
47 my ($k, $v) = split(/=/);
48 if ($k =~ /^TT/) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
49 $ttconfig{ $k } = $v || 0;
a4123f8 @abw 2.04b
authored
50 }
51 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
52 $config{ $k } = $v || 0;
a4123f8 @abw 2.04b
authored
53 }
54 };
55
9be7d64 @abw approaching 2.04d
authored
56
57 # print help if they asked for it
58
a4123f8 @abw 2.04b
authored
59 if (exists $ttconfig{ TT_HELP }) {
60 print <<EOF;
61 The following options can be specified as command line
62 arguments to 'perl Makefile.PL'. e.g.
63
9be7d64 @abw approaching 2.04d
authored
64 perl Makefile.PL TT_PREFIX=/my/tt2/dir TT_ACCEPT=y
65
66 TT_PREFIX installation prefix ($PREFIX)
67 TT_IMAGES images URL (/tt2/images)
68 TT_DOCS build HTML docs (y)
69 TT_SPLASH use Splash! for docs (y)
70 TT_THEME Splash! theme (default)
71 TT_EXAMPLES build HTML examples (y)
ea05afc @abw * applied patch from Axel Gerstmair to add TT_EXTRAS option to Makefile....
authored
72 TT_EXTRAS install optional extras (y)
9be7d64 @abw approaching 2.04d
authored
73 TT_XS_ENABLE Enable XS Stash (y)
74 TT_XS_DEFAULT Use XS Stash by default (y)
75 TT_DBI run DBI tests (y if DBI installed)
76
77 TT_LATEX install LaTeX filter (y if LaTeX found)
78 TT_LATEX_PATH path to latex (system dependant)
79 TT_PDFLATEX_PATH path to pdflatex ( " " " )
80 TT_DVIPS_PATH path to dvips ( " " " )
a4123f8 @abw 2.04b
authored
81
9be7d64 @abw approaching 2.04d
authored
82 TT_QUIET no messages (n)
83 TT_ACCEPT accept defaults (n)
a4123f8 @abw 2.04b
authored
84
85 By default, the Makefile.PL runs in interactive mode,
86 prompting for confirmation of the various configuration
87 options. Setting the TT_ACCEPT option causes the default
88 value (possibly modified by other command line options)
89 to be accepted. The TT_QUIET option can also be set to
90 suppress the prompt messages.
91
92 EOF
93 exit(0);
94 }
ca4050f @abw prep for 2.02
authored
95
9be7d64 @abw approaching 2.04d
authored
96 # these global package variables are the main flags used
97 # in this script, here defaulted to sensible values
98
a4123f8 @abw 2.04b
authored
99 $TT_VERSION = $Template::VERSION;
100 $TT_PREFIX = $PREFIX;
9be7d64 @abw approaching 2.04d
authored
101 $TT_IMAGES = $IMAGES;
f4df3b6 @abw approach v2.03
authored
102 $TT_RUN_DBI = 'y';
103 $TT_BUILD_DOCS = 'y';
104 $TT_SPLASH_DOCS = 'y';
105 $TT_EXAMPLES = 'y';
ea05afc @abw * applied patch from Axel Gerstmair to add TT_EXTRAS option to Makefile....
authored
106 $TT_EXTRAS = 'y';
f4df3b6 @abw approach v2.03
authored
107 $TT_SPLASH_THEME = 'default';
9be7d64 @abw approaching 2.04d
authored
108 $TT_XS_ENABLE = 'y';
109 $TT_XS_DEFAULT = 'y';
a4123f8 @abw 2.04b
authored
110 $TT_LATEX_ENABLE = 'y';
9be7d64 @abw approaching 2.04d
authored
111 $TT_LATEX_PATH = '';
112 $TT_PDFLATEX_PATH = '';
113 $TT_DVIPS_PATH = '';
a4123f8 @abw 2.04b
authored
114 $TT_QUIET = 'n';
115 $TT_ACCEPT = 'n';
f4df3b6 @abw approach v2.03
authored
116
46e4eb8 @abw * Added new colour theme called 'leon'
authored
117 my $TT_SPLASH_FG = '';
118 my $TT_SPLASH_BG = '';
119 my $TT_SPLASH_FT = '';
120 my $TT_SPLASH_BT = '';
ca4050f @abw prep for 2.02
authored
121
122 my $DEFAULTS_FILE = '.defaults.cfg';
714a8cd @abw * prep for release 2.07a
authored
123 my $DBI_CONFIG_FILE = catfile('t', 'dbi_test.cfg');
124 my $TT_DOCS_CFG = catfile('docs','ttree.cfg');
125 my $TT_EXAMPLE_CFG = catfile('examples','ttree.cfg');
ca4050f @abw prep for 2.02
authored
126 my $DEFAULTS = '';
911a5e3 @abw *** empty log message ***
authored
127
ca4050f @abw prep for 2.02
authored
128 if (-f $DEFAULTS_FILE) {
129 require $DEFAULTS_FILE;
130 $DEFAULTS = " read from '$DEFAULTS_FILE'";
131 }
132
9be7d64 @abw approaching 2.04d
authored
133 $TT_PREFIX = $ttconfig{ TT_PREFIX } if $ttconfig{ TT_PREFIX };
134 $TT_IMAGES = $ttconfig{ TT_IMAGES } if $ttconfig{ TT_IMAGES };
135 $TT_SPLASH_THEME = $ttconfig{ TT_THEME } if $ttconfig{ TT_THEME };
136 $TT_LATEX_PATH = $ttconfig{ TT_LATEX_PATH } if $ttconfig{ TT_LATEX_PATH };
137 $TT_PDFLATEX_PATH = $ttconfig{ TT_PDFLATEX_PATH } if $ttconfig{ TT_PDFLATEX_PATH };
138 $TT_DVIPS_PATH = $ttconfig{ TT_DVIPS_PATH } if $ttconfig{ TT_DVIPS_PATH };
139 $TT_RUN_DBI = $ttconfig{ TT_DBI } if defined $ttconfig{ TT_DBI };
140 $TT_BUILD_DOCS = $ttconfig{ TT_DOCS } if defined $ttconfig{ TT_DOCS };
141 $TT_SPLASH_DOCS = $ttconfig{ TT_SPLASH } if defined $ttconfig{ TT_SPLASH };
142 $TT_EXAMPLES = $ttconfig{ TT_EXAMPLES } if defined $ttconfig{ TT_EXAMPLES };
ea05afc @abw * applied patch from Axel Gerstmair to add TT_EXTRAS option to Makefile....
authored
143 $TT_EXTRAS = $ttconfig{ TT_EXTRAS } if defined $ttconfig{ TT_EXTRAS };
9be7d64 @abw approaching 2.04d
authored
144 $TT_LATEX_ENABLE = $ttconfig{ TT_LATEX } if defined $ttconfig{ TT_LATEX };
145 $TT_XS_ENABLE = $ttconfig{ TT_XS_ENABLE } if defined $ttconfig{ TT_XS_ENABLE };
146 $TT_XS_DEFAULT = $ttconfig{ TT_XS_DEFAULT } if defined $ttconfig{ TT_XS_DEFAULT };
147 $TT_QUIET = $ttconfig{ TT_QUIET } if defined $ttconfig{ TT_QUIET };
148 $TT_ACCEPT = $ttconfig{ TT_ACCEPT } if defined $ttconfig{ TT_ACCEPT };
149
150 foreach ($TT_RUN_DBI, $TT_BUILD_DOCS, $TT_SPLASH_DOCS, $TT_EXAMPLES,
ea05afc @abw * applied patch from Axel Gerstmair to add TT_EXTRAS option to Makefile....
authored
151 $TT_EXTRAS, $TT_LATEX_ENABLE, $TT_XS_ENABLE, $TT_XS_DEFAULT ) {
a4123f8 @abw 2.04b
authored
152 $_ = 'n' if ! $_;
153 }
154 $TT_ACCEPT = 0 if $TT_ACCEPT eq 'n';
155 $TT_QUIET = 0 if $TT_QUIET eq 'n';
156 $TT_QUIET = 0 unless $TT_ACCEPT;
157
ca4050f @abw prep for 2.02
authored
158 my $SPLASH_STYLES = {
159 default => [ 'lilac', 'mauve' ],
160 aqua => [ 'aqua', 'marine' ],
161 grey => [ 'grey75', 'grey50' ],
162 blue => [ 'grey75', 'blue75' ],
163 red => [ 'grey75', 'red75' ],
164 green => [ 'grey75', 'green75' ],
46e4eb8 @abw * Added new colour theme called 'leon'
authored
165 leon => [ 'red75', 'orange', 'white', 'black' ],
ca4050f @abw prep for 2.02
authored
166 };
167
c542301 @abw *** empty log message ***
authored
168
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
169 # define version numbers of required modules
170 my $TT_APPCONFIG_VERSION = '1.55';
171 my $TT_FILE_SPEC_VERSION = '0.8';
172 my $TT_FILE_TEMP_VERSION = '0.12';
173
174
a4123f8 @abw 2.04b
authored
175 #========================================================================
176
177 welcome_message();
178 version_check();
28cc36e @abw prep for 2.06d
authored
179 mandatory_modules();
a4123f8 @abw 2.04b
authored
180 optional_modules();
9be7d64 @abw approaching 2.04d
authored
181 optional_stash_xs();
a4123f8 @abw 2.04b
authored
182 optional_latex();
183 optional_extras();
184 splash_images();
185 html_docs();
186 html_docstyle();
187 html_examples();
188 write_defaults();
189
190 print "\n";
191
192
193 #------------------------------------------------------------------------
194 # build options and write Makefile
195 #------------------------------------------------------------------------
196
197 package MY;
198
199 sub postamble {
200 return '' unless $main::TT_PREFIX;
201 my $amble =<<'EOF';
202 tt2_install ::
203 @$(PERL) bin/tt2inst -v "$(TT_PREFIX)"
204
205 tt2_splash ::
582a703 @abw * Applied a patch from Christian Schaffner which fixes a problem in
authored
206 @$(PERL) -I$(INST_LIB) -I$(INST_ARCHLIB) bin/gifsplash -v -i "$(TT_PREFIX)"
a4123f8 @abw 2.04b
authored
207
208 EOF
209 $amble .=<<EOF if $main::TT_BUILD_DOCS;
210 tt2_html_docs ::
582a703 @abw * Applied a patch from Christian Schaffner which fixes a problem in
authored
211 \@\$(PERL) -I\$(INST_LIB) -I\$(INST_ARCHLIB) bin/ttree -v -f "\$(TT_PREFIX)/$TT_DOCS_CFG"
a4123f8 @abw 2.04b
authored
212
213 EOF
214 $amble .=<<EOF if $main::TT_EXAMPLES;
215 tt2_examples ::
582a703 @abw * Applied a patch from Christian Schaffner which fixes a problem in
authored
216 \@\$(PERL) -I\$(INST_LIB) -I\$(INST_ARCHLIB) bin/ttree -v -f "\$(TT_PREFIX)/$TT_EXAMPLE_CFG"
a4123f8 @abw 2.04b
authored
217
218 EOF
219 return $amble;
220 }
221
222 sub install {
223 my $class = shift;
224 my $basic = $class->SUPER::install(@_);
225 my $add = 'tt2_install tt2_splash';
226 $add .= ' tt2_html_docs' if $main::TT_BUILD_DOCS;
227 $add .= ' tt2_examples' if $main::TT_EXAMPLES;
228 $basic =~ s/^(install\s+::\s+.*)$/$1 $add/m
229 if $main::TT_PREFIX;
230 $basic;
231 }
232
233 sub constants {
234 my $class = shift;
235 my $basic = $class->SUPER::constants(@_);
236 $basic = "TT_PREFIX = $main::TT_PREFIX\n$basic"
237 if $main::TT_PREFIX;
238 $basic;
239 }
240
241 package main;
242
243 my %opts = (
244 %config,
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
245 'NAME' => 'Template',
a4123f8 @abw 2.04b
authored
246 'DISTNAME' => 'Template-Toolkit',
247 'VERSION_FROM' => 'lib/Template.pm',
248 'EXE_FILES' => [ 'bin/tpage', 'bin/ttree' ],
249 'PMLIBDIRS' => [ 'lib' ],
9be7d64 @abw approaching 2.04d
authored
250 'DIR' => [ ],
c7d3d41 @abw * removed mandatory modules check from Makefile.PL to keep CPAN module
authored
251 'PREREQ_PM' => {
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
252 'AppConfig' => $TT_APPCONFIG_VERSION,
253 'File::Spec' => $TT_FILE_SPEC_VERSION,
254 'File::Temp' => $TT_FILE_TEMP_VERSION,
c7d3d41 @abw * removed mandatory modules check from Makefile.PL to keep CPAN module
authored
255 },
a4123f8 @abw 2.04b
authored
256 'dist' => {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
257 'COMPRESS' => 'gzip',
258 'SUFFIX' => 'gz',
a4123f8 @abw 2.04b
authored
259 },
28cc36e @abw prep for 2.06d
authored
260 'clean' => {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
261 'FILES' => join(' ', qw( docs/ttree.cfg
262 examples/ttree.cfg
263 t/dbi_test.cfg
264 t/test/src/baz.ttc
265 t/test/src/complex.org
266 t/test/src/complex.ttc
267 t/test/src/evalperl.ttc
268 t/test/src/foo.ttc )),
28cc36e @abw prep for 2.06d
authored
269 },
a4123f8 @abw 2.04b
authored
270 );
271
9be7d64 @abw approaching 2.04d
authored
272 push @{ $opts{'DIR'} }, 'xs' if $TT_XS_ENABLE;
273
a4123f8 @abw 2.04b
authored
274 if ($ExtUtils::MakeMaker::VERSION >= 5.43) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
275 $opts{ AUTHOR } = 'Andy Wardley <abw@wardley.org>';
276 $opts{ ABSTRACT } = 'comprehensive template processing system',
a4123f8 @abw 2.04b
authored
277 }
278
279
280 WriteMakefile( %opts );
281
282 print <<EOF;
283
284 Configuration complete. You should now run '$MAKE', '$MAKE test' and
285 then '$MAKE install'. See the README file for further information.
286 EOF
287
ea05afc @abw * applied patch from Axel Gerstmair to add TT_EXTRAS option to Makefile....
authored
288 message(<<EOF) if $TT_PREFIX;
a4123f8 @abw 2.04b
authored
289
9be7d64 @abw approaching 2.04d
authored
290
291 Installation Notes
292 ------------------
293
a4123f8 @abw 2.04b
authored
294 Please note that the installation of the optional components and
295 building of the HTML documentation is performed at the "make install"
296 stage as the effective user at that time. This implies that this user
297 must have sufficient permission to install into the specified
298 directory and that all created directories and files will be owned by
299 them.
300
301 EOF
302
303 #========================================================================
304
305
306
307 #------------------------------------------------------------------------
308 # welcome_message()
309 #
310 # Print opening banner.
311 #------------------------------------------------------------------------
312
313 sub welcome_message {
314 print(<<EOF);
315
316 Template Toolkit Version $TT_VERSION
c542301 @abw *** empty log message ***
authored
317 =============================
911a5e3 @abw *** empty log message ***
authored
318
ca4050f @abw prep for 2.02
authored
319 Using $FLAVOUR defaults$DEFAULTS.
9be7d64 @abw approaching 2.04d
authored
320
321 Run 'perl Makefile.PL TT_HELP' for a summary of options.
48634a1 @abw *** empty log message ***
authored
322 EOF
a4123f8 @abw 2.04b
authored
323 print "Messages suppressed (TT_QUIET). " if $TT_QUIET;
324 print "Accepting defaults automatically (TT_ACCEPT)." if $TT_ACCEPT;
325 }
326
327
48634a1 @abw *** empty log message ***
authored
328
329 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
330 # version_check()
331 #
332 # Check for pre-version 2.00 installation and issue warning
48634a1 @abw *** empty log message ***
authored
333 #------------------------------------------------------------------------
334
a4123f8 @abw 2.04b
authored
335 sub version_check {
336 eval "use Template";
337 unless ($@ or $Template::VERSION =~ /^2/) {
338 warn(<<EOF) unless $TT_QUIET;
48634a1 @abw *** empty log message ***
authored
339
c542301 @abw *** empty log message ***
authored
340 IMPORTANT NOTE:
a4123f8 @abw 2.04b
authored
341
48634a1 @abw *** empty log message ***
authored
342 You have version $Template::VERSION of the Template Toolkit installed.
25a8d8e @abw *** empty log message ***
authored
343
82cbea8 @abw version 2.00
authored
344 There are some minor incompatabilities between version 1 and 2
48634a1 @abw *** empty log message ***
authored
345 of the Template Toolkit which you should be aware of. Installing
346 this version will overwrite your version $Template::VERSION files
347 unless you take measures to install one or the other version in a
82cbea8 @abw version 2.00
authored
348 different location (i.e. perl Makefile.PL PREFIX=/other/path).
48634a1 @abw *** empty log message ***
authored
349
350 Please consult the README and Changes file for further details.
351 Most of the changes are in the more obscure features and
352 directives so hopefully you will find the upgrade process fairly
9be7d64 @abw approaching 2.04d
authored
353 painless. If you're feeling brave, then answer 'y', otherwise 'n'.
25a8d8e @abw *** empty log message ***
authored
354
355 EOF
a4123f8 @abw 2.04b
authored
356 exit unless ttprompt("Do you want to continue?", 'y') =~ /y/i;
357 }
48634a1 @abw *** empty log message ***
authored
358 }
359
a4123f8 @abw 2.04b
authored
360
48634a1 @abw *** empty log message ***
authored
361 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
362 # mandatory_modules()
363 #
364 # Detect mandatory module
c8d76d4 @abw *** empty log message ***
authored
365 #------------------------------------------------------------------------
366
a4123f8 @abw 2.04b
authored
367 sub mandatory_modules {
368 eval "use AppConfig";
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
369 if ($@ or $AppConfig::VERSION < $TT_APPCONFIG_VERSION) {
28cc36e @abw prep for 2.06d
authored
370 warn(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
371
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
372 The Template Toolkit requires that the AppConfig module (version $TT_APPCONFIG_VERSION
373 or later) first be installed. This is used by
374 the 'ttree' program for reading command line options and configuration
375 files. It is available from CPAN:
c8d76d4 @abw *** empty log message ***
authored
376
377 http://www.cpan.org/authors/Andy_Wardley/
378
379 EOF
a4123f8 @abw 2.04b
authored
380 }
c8d76d4 @abw *** empty log message ***
authored
381
a4123f8 @abw 2.04b
authored
382 eval "use File::Spec";
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
383 if ($@ or $File::Spec::VERSION < $TT_FILE_SPEC_VERSION) {
28cc36e @abw prep for 2.06d
authored
384 warn(<<EOF);
911a5e3 @abw *** empty log message ***
authored
385
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
386 The Template Toolkit requires that the File::Spec module (version $TT_FILE_SPEC_VERSION
911a5e3 @abw *** empty log message ***
authored
387 or later) first be installed. This is used by the File plugin. It is
388 available from CPAN:
389
390 http://search.cpan.org/search?dist=File-Spec
391
392 EOF
a4123f8 @abw 2.04b
authored
393 }
911a5e3 @abw *** empty log message ***
authored
394
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
395 eval "use File::Temp";
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
396 if ($@ or $File::Temp::VERSION < $TT_FILE_TEMP_VERSION) {
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
397 warn(<<EOF);
398
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
399 The Template Toolkit requires that the File::Temp module (version $TT_FILE_TEMP_VERSION
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
400 or later) first be installed. This is used by the Template::Document
401 class for storing compiled templates. It is available from CPAN:
402
403 http://search.cpan.org/search?dist=File-Temp
404
405 EOF
406 }
407 }
911a5e3 @abw *** empty log message ***
authored
408
a4123f8 @abw 2.04b
authored
409
c8d76d4 @abw *** empty log message ***
authored
410 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
411 # optional_modules()
412 #
413 # Detect additional modules required by plugins (just for fun)
48634a1 @abw *** empty log message ***
authored
414 #------------------------------------------------------------------------
25a8d8e @abw *** empty log message ***
authored
415
a4123f8 @abw 2.04b
authored
416 sub optional_modules {
417 message(<<EOF);
48634a1 @abw *** empty log message ***
authored
418
9be7d64 @abw approaching 2.04d
authored
419 External Modules
420 ----------------
421
82cbea8 @abw version 2.00
authored
422 The Template Toolkit includes a number of plugin modules, some of
423 which interface to external Perl modules available from CPAN. All the
424 plugins will be installed regardless so that they will automatically
425 work as and when you install the relevant modules. The tests will be
426 skipped for plugins that require external modules not currently
427 available on your system.
e39913f @abw *** empty log message ***
authored
428
429 EOF
48634a1 @abw *** empty log message ***
authored
430
a4123f8 @abw 2.04b
authored
431 foreach my $mods ( [ 'Text::Autoformat' => \&check_taf ],
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
432 [ 'GD' => undef ],
433 [ 'GD::Text' => undef ],
434 [ 'GD::Graph' => undef ],
435 [ 'GD::Graph3d' => undef ],
436 [ 'Image::Info' => undef ],
437 [ 'Image::Size' => undef ],
438 [ 'Date::Calc' => undef ],
439 [ 'Pod::POM' => undef ],
440 [ 'Tie::DBI' => undef ],
441 [ 'XML::DOM' => \&check_dom ],
442 [ 'XML::RSS' => \&check_rss ],
443 [ 'XML::XPath' => \&check_xpath ],
444 [ 'DBI' => \&dbi_config ] ) {
445 my ($module, $code) = ref $mods ? @$mods : ($mods, 0);
a4123f8 @abw 2.04b
authored
446
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
447 printf(" %-16s ", $module) unless $TT_QUIET;
448 eval "use $module";
449 if ($@) {
450 nope("module not installed");
451 }
452 elsif ($code) {
453 &$code;
454 }
455 else {
456 no strict qw( refs );
457 my $ver = ${"$module\::VERSION"};
458 yep("version $ver installed");
459 }
82cbea8 @abw version 2.00
authored
460 }
e39913f @abw *** empty log message ***
authored
461 }
462
a4123f8 @abw 2.04b
authored
463
9be7d64 @abw approaching 2.04d
authored
464 #------------------------------------------------------------------------
465 # optional_stash_xs()
466 #
467 # Prompt for installation and default use of XS Stash.
468 #------------------------------------------------------------------------
469
470 sub optional_stash_xs {
471 # return if $TT_ACCEPT && (! $TT_XS_ENABLE || $TT_XS_ENABLE eq 'n');
472
473 message(<<EOF);
474
475
476 XS Stash: TT2 now twice as fast!
477 --------------------------------
478
dd62af1 @abw * Applied Chris' patch to fix win => MSWin32
authored
479 We have a new high speed version of the Template::Stash. It's
9be7d64 @abw approaching 2.04d
authored
480 a Perl XS module which can evaluate templates about twice as fast as
e9d3021 @abw * fixed up bug in XS stash introduced with SCALAR_OPS lookup added to fa...
authored
481 the pure-Perl version. It is stable and reliable but be warned that
482 it doesn't yet support access to tied hashes (e.g. Tie::DBI) so for
483 certain applications you may need to explicitly use the regular stash.
9be7d64 @abw approaching 2.04d
authored
484
46e4eb8 @abw * Added new colour theme called 'leon'
authored
485 You can choose to build the XS stash module and enable it by default
486 so that it is used automatically for all templates. If you build it
487 but don't enable it by default then you can use it something like
488 this:
9be7d64 @abw approaching 2.04d
authored
489
490 use Template;
491 use Template::Stash::XS;
492
493 my \$tt = new Template ({ STASH => new Template::Stash::XS, ... });
494
e9d3021 @abw * fixed up bug in XS stash introduced with SCALAR_OPS lookup added to fa...
authored
495 You can also enable the XS stash (or the regular stash if you opt to
496 use the XS stash by default) by setting the \$STASH package variable
497 in the Template/Config.pm module. See 'perldoc Template::Config' for
498 further details.
9be7d64 @abw approaching 2.04d
authored
499
500 EOF
501
502 $TT_XS_ENABLE = (ttprompt('Do you want to build the XS Stash module?',
503 $TT_XS_ENABLE) =~ /^y/i);
504
505 if ($TT_XS_ENABLE) {
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
506 $TT_XS_DEFAULT =
507 (ttprompt('Do you want to use the XS Stash for all Templates?',
9be7d64 @abw approaching 2.04d
authored
508 $TT_XS_DEFAULT) =~ /^y/i);
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
509 }
510 else {
511 # If the XS stash is disabled, we cannot use it as the default stash.
512 $TT_XS_DEFAULT = 0;
513 }
9be7d64 @abw approaching 2.04d
authored
514
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
515 # Actually, we would have to fix 'Config.pm' only if the XS stash is
516 # disabled. But this way, we are sure the correct module is used.
714a8cd @abw * prep for release 2.07a
authored
517 fix_file(catfile('lib','Template','Config.pm'),
d941238 @abw prep 2.4d
authored
518 '$STASH',
519 $TT_XS_DEFAULT ? 'Template::Stash::XS' : 'Template::Stash');
9be7d64 @abw approaching 2.04d
authored
520 }
521
a4123f8 @abw 2.04b
authored
522
c8d76d4 @abw *** empty log message ***
authored
523 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
524 # optional_latex()
525 #
526 # Prompt for installation of latex filter
f4df3b6 @abw approach v2.03
authored
527 #------------------------------------------------------------------------
528
a4123f8 @abw 2.04b
authored
529 sub optional_latex {
9be7d64 @abw approaching 2.04d
authored
530 # return if $TT_ACCEPT && (! $TT_LATEX_ENABLE || $TT_LATEX_ENABLE eq 'n');
a4123f8 @abw 2.04b
authored
531
9be7d64 @abw approaching 2.04d
authored
532 $TT_LATEX_PATH ||= find_program($ENV{PATH}, "latex") || '';
533 $TT_PDFLATEX_PATH ||= find_program($ENV{PATH}, "pdflatex") || '';
534 $TT_DVIPS_PATH ||= find_program($ENV{PATH}, "dvips") || '';
a4123f8 @abw 2.04b
authored
535
536 message(<<EOF);
f4df3b6 @abw approach v2.03
authored
537
9be7d64 @abw approaching 2.04d
authored
538
539 LaTeX Support
540 -------------
541
f4df3b6 @abw approach v2.03
authored
542 TT2 supports PDF, DVI and PostScript output using the latex filter,
543 implemented with the programs pdflatex, latex and dvips.
544
545 Because the latex filter runs latex and pdflatex, template authors could
546 use this feature to include any arbitrary file in their latex input, or
547 also open an arbitrary output file, independent of the ABSOLUTE or
548 RELATIVE configuration settings. This might create a security concern at
549 your site. If you don't trust your template authors then don't enable
550 the latex filter.
551
552 I found the following locations for pdflatex, latex and dvips:
553 + pdflatex => $TT_PDFLATEX_PATH
554 + latex => $TT_LATEX_PATH
555 + dvips => $TT_DVIPS_PATH
556
557 EOF
558
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
559 if ( $TT_LATEX_PATH eq ""
560 || $TT_PDFLATEX_PATH eq ""
561 || $TT_DVIPS_PATH eq "" ) {
562 $TT_LATEX_ENABLE = 'n';
a4123f8 @abw 2.04b
authored
563 }
564 $TT_LATEX_ENABLE ||= 'y';
565 $TT_LATEX_ENABLE = (
566 ttprompt('Do you want to enable the latex filter?',
567 $TT_LATEX_ENABLE) =~ /^y/i
568 );
569 if ( $TT_LATEX_ENABLE ) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
570 if (ttprompt('Are the pdflatex, latex and dvips paths ok?', 'y') !~ /^y/i) {
571 $TT_PDFLATEX_PATH = ttprompt('pdflatex path', $TT_PDFLATEX_PATH);
572 $TT_LATEX_PATH = ttprompt('latex path', $TT_LATEX_PATH);
573 $TT_DVIPS_PATH = ttprompt('dvips path', $TT_DVIPS_PATH);
574 }
a4123f8 @abw 2.04b
authored
575 } else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
576 #
577 # Empty paths will cause the latex filter to throw an error
578 #
579 $TT_PDFLATEX_PATH = $TT_LATEX_PATH = $TT_DVIPS_PATH = "";
f4df3b6 @abw approach v2.03
authored
580 }
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
581
714a8cd @abw * prep for release 2.07a
authored
582 fix_file(catfile('lib','Template','Config.pm'), '$PDFLATEX_PATH', $TT_PDFLATEX_PATH);
583 fix_file(catfile('lib','Template','Config.pm'), '$LATEX_PATH', $TT_LATEX_PATH);
584 fix_file(catfile('lib','Template','Config.pm'), '$DVIPS_PATH', $TT_DVIPS_PATH);
f4df3b6 @abw approach v2.03
authored
585 }
586
a4123f8 @abw 2.04b
authored
587
f4df3b6 @abw approach v2.03
authored
588 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
589 # optional_extras()
590 #
591 # Prompt for installation of optional libraries and other components
c8d76d4 @abw *** empty log message ***
authored
592 #------------------------------------------------------------------------
593
a4123f8 @abw 2.04b
authored
594 sub optional_extras {
595 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
596
9be7d64 @abw approaching 2.04d
authored
597
598 Optional Extras
599 ---------------
600
c8d76d4 @abw *** empty log message ***
authored
601 In additional to the Perl modules and POD documentation installed in
602 the usual way, the Template Toolkit distribution also contains a
603 number of optional components:
604
605 * Template libaries for basic HTML, Pod -> HTML, and PostScript
606
607 * Splash! - a stylish HTML user interface template library / widget set
608
609 * HTML documentation - distributed in template form for customisation
610
611 * Stylesheet templates to generate docs as vanilla HTML or using Splash!
612
613 * Examples - numerous examples of using the template libraries
614
615 If you want to install these optional components then you'll need to
616 specify a separate directory for them.
617
618 EOF
619
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
620 if ($TT_EXTRAS = (
621 ttprompt('Do you want to install these components?',
622 $TT_EXTRAS) =~ /^y/i)) {
a4123f8 @abw 2.04b
authored
623 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
624
625 You can chose any directory for the installation of the additional
911a5e3 @abw *** empty log message ***
authored
626 Template Toolkit components. The proposed default assumes a $FLAVOUR
627 flavour to your operating system (suggestions for suitable defaults
628 for other platforms welcome).
c8d76d4 @abw *** empty log message ***
authored
629
630 EOF
9be7d64 @abw approaching 2.04d
authored
631 $TT_PREFIX = ttprompt('Installation directory', $TT_PREFIX || $PREFIX);
73afe6d @abw * Applied Axel's patch to remove trailing '/' from installation dir.
authored
632 $TT_PREFIX =~ s[/$][];
a4123f8 @abw 2.04b
authored
633 }
634 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
635 $TT_PREFIX = '';
a4123f8 @abw 2.04b
authored
636 }
637
714a8cd @abw * prep for release 2.07a
authored
638 fix_file(catfile('lib','Template','Config.pm'), '$INSTDIR', $TT_PREFIX);
c8d76d4 @abw *** empty log message ***
authored
639 }
640
641
642
643 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
644 # splash_images()
645 #
646 # Prompt for Splash! image URL
c8d76d4 @abw *** empty log message ***
authored
647 #------------------------------------------------------------------------
648
a4123f8 @abw 2.04b
authored
649 sub splash_images {
650 return unless $TT_PREFIX;
911a5e3 @abw *** empty log message ***
authored
651
a4123f8 @abw 2.04b
authored
652 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
653
9be7d64 @abw approaching 2.04d
authored
654
655 Splash!
656 -------
657
c8d76d4 @abw *** empty log message ***
authored
658 The Splash! template library uses a number of (very) small images to
659 build user interface components. These will be installed into the
660 directory:
661
a4123f8 @abw 2.04b
authored
662 $TT_PREFIX/images
911a5e3 @abw *** empty log message ***
authored
663 EOF
664
665 if ($WIN32) {
666 # default images value for Win32 to browse via file system
a4123f8 @abw 2.04b
authored
667 $TT_IMAGES = "$TT_PREFIX/images";
668
669 message(<<EOF);
670
911a5e3 @abw *** empty log message ***
authored
671 If you want to use the Splash! library then you'll need to make sure
672 you can access these images via your browser. If you want to deliver
673 pages via a web server then you'll need to specify the URL that can be
674 use to access these images. In the general case you can accept the
675 default and access the images via the filesystem.
676
677 EOF
678 }
679 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
680 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
681
682 If you want to use the Splash! library then you'll need to copy these
683 images, define an alias (e.g. in the httpd.conf) or create a symbolic
684 link to them so that your web server can find them. Then you'll need
685 to specify the resulting URL which can be used to retrieve them from
686 the web server.
687
688 Typical values might be '/tt2/images', '/images/tt2', '/~user/tt2/images'
689 or even something like 'http://www.yourhost.org/images/tt2'.
690
691 (NOTE: If this is too much for you to think about right now, then
692 accept the default below and read the Template::Library::Splash
693 manpage at your leisure to find out more).
694
695 EOF
911a5e3 @abw *** empty log message ***
authored
696 }
c8d76d4 @abw *** empty log message ***
authored
697
9be7d64 @abw approaching 2.04d
authored
698 $TT_IMAGES = ttprompt('URL base for TT2 images?', $TT_IMAGES || $IMAGES);
c8d76d4 @abw *** empty log message ***
authored
699 $TT_IMAGES =~ s[/$][]g; # just in case
d941238 @abw prep 2.4d
authored
700
714a8cd @abw * prep for release 2.07a
authored
701 fix_file(catfile('templates','splash','config'), 'images', "$TT_IMAGES/splash");
c8d76d4 @abw *** empty log message ***
authored
702 }
703
704
705
a4123f8 @abw 2.04b
authored
706 #------------------------------------------------------------------------
707 # html_docs()
708 #
709 # Prompt for HTML documentation build
710 #--------------------------------------------------------------------
711
712 sub html_docs {
713 return unless $TT_PREFIX;
714
c8d76d4 @abw *** empty log message ***
authored
715 my $style = 'plain';
716 my $style_cfg = '';
717
a4123f8 @abw 2.04b
authored
718 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
719
9be7d64 @abw approaching 2.04d
authored
720
721 HTML Documentation
722 ------------------
723
c8d76d4 @abw *** empty log message ***
authored
724 The modules comprising the Template Toolkit contain comprehensive POD
725 documentation which can be browsed using 'perldoc' or 'man' (if your
726 system supports it). In additional, the distribution also includes a
727 set of source templates and style elements for generating the same
728 documentation in HTML format. These will be installed in the
729 directory:
730
a4123f8 @abw 2.04b
authored
731 $TT_PREFIX/docs
c8d76d4 @abw *** empty log message ***
authored
732
733 The HTML documentation can be built for you at "make install" time in
734 a plain and simple HTML format or using the Splash! library. You can
735 see examples of these different styles and browse the documentation
736 online at:
737
738 http://www.template-toolkit.org/docs/
739
740 EOF
741
742 $TT_BUILD_DOCS = (
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
743 ttprompt('Do you want to build the HTML documentation?',
744 $TT_BUILD_DOCS) =~ /^y/i
c8d76d4 @abw *** empty log message ***
authored
745 );
746
a4123f8 @abw 2.04b
authored
747 }
748
749
750 #--------------------------------------------------------------------
751 # html_docstyle()
752 #
753 # prompt for docs style: plain or splash
754 #--------------------------------------------------------------------
755
756 sub html_docstyle {
757 return unless $TT_PREFIX && $TT_BUILD_DOCS;
758
759 my $style = 'plain';
760 my $style_cfg = '';
c8d76d4 @abw *** empty log message ***
authored
761
a4123f8 @abw 2.04b
authored
762 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
763
ca4050f @abw prep for 2.02
authored
764 If you want to build the HTML documentation using the Splash! library
765 then you'll need to make sure you correctly defined the URL for the
766 Splash! images above. Otherwise, answer 'n' to the next question to
767 use plain HTML.
c8d76d4 @abw *** empty log message ***
authored
768
769 EOF
a4123f8 @abw 2.04b
authored
770 $TT_SPLASH_DOCS = (
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
771 ttprompt('Do you want to use the Splash! library?', $TT_SPLASH_DOCS) =~ /^y/i
a4123f8 @abw 2.04b
authored
772 );
c8d76d4 @abw *** empty log message ***
authored
773
a4123f8 @abw 2.04b
authored
774 if ($TT_SPLASH_DOCS) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
775 my $splash_style = '';
776 message(<<EOF);
ca4050f @abw prep for 2.02
authored
777
778 Which Splash! colour scheme would you like to use to build the
779 documentation? Acceptable values are:
780
781 EOF
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
782 unless ($TT_QUIET) {
783 print " Name Colours\n -------------------------\n";
784 foreach my $t ('default',
785 grep { ! /^default$/ } sort keys %$SPLASH_STYLES) {
786 my $v = $SPLASH_STYLES->{ $t };
787 local $" = '/';
788 printf(" %-8s @$v\n", $t);
789 }
790 print "\n";
ca4050f @abw prep for 2.02
authored
791
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
792 while (! $splash_style) {
793 $TT_SPLASH_THEME = ttprompt("Enter name of colour scheme: ",
794 $TT_SPLASH_THEME);
795 message("! No such scheme\n"), $TT_SPLASH_THEME = 'default'
796 unless ($splash_style = $SPLASH_STYLES->{ $TT_SPLASH_THEME });
797 }
46e4eb8 @abw * Added new colour theme called 'leon'
authored
798
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
799 ( $TT_SPLASH_BG, $TT_SPLASH_FG, $TT_SPLASH_BT, $TT_SPLASH_FT )
800 = @$splash_style;
46e4eb8 @abw * Added new colour theme called 'leon'
authored
801
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
802 # default background (unselected) text is black, fore is white
803 $TT_SPLASH_BT ||= 'black';
804 $TT_SPLASH_FT ||= 'white';
ca4050f @abw prep for 2.02
authored
805
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
806 $style = 'splash';
807 $style_cfg = <<EOF;
ca4050f @abw prep for 2.02
authored
808
809 pre_process = splash/config
810 define splash_fg = '$TT_SPLASH_FG'
811 define splash_bg = '$TT_SPLASH_BG'
46e4eb8 @abw * Added new colour theme called 'leon'
authored
812 define splash_ft = '$TT_SPLASH_FT'
813 define splash_bt = '$TT_SPLASH_BT'
ca4050f @abw prep for 2.02
authored
814 EOF
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
815 }
c8d76d4 @abw *** empty log message ***
authored
816 }
817
818 #--------------------------------------------------------------------
819 # write ttree config file for building docs
820 #--------------------------------------------------------------------
821
822 open(FP, "> $TT_DOCS_CFG") || die "$TT_DOCS_CFG: $!\n";
823 print FP <<EOF;
824 # This ttree configuration file is automatically generated by
825 # the Makefile.PL installation script. Feel free to edit it
826 # but be warned that re-installing the Template Toolkit will
827 # overwrite your changes.
a4123f8 @abw 2.04b
authored
828 src = $TT_PREFIX/docs/src
829 dest = $TT_PREFIX/docs/html
830 lib = $TT_PREFIX/docs/style/$style
831 lib = $TT_PREFIX/docs/lib
832 lib = $TT_PREFIX/templates
c8d76d4 @abw *** empty log message ***
authored
833 $style_cfg
834 pre_process = config
835 pre_process = header
836 post_process = footer
911a5e3 @abw *** empty log message ***
authored
837 recurse
838 verbose
c8d76d4 @abw *** empty log message ***
authored
839 EOF
840 close(FP);
a4123f8 @abw 2.04b
authored
841 }
c8d76d4 @abw *** empty log message ***
authored
842
843
a4123f8 @abw 2.04b
authored
844
845
846 #--------------------------------------------------------------------
847 # html_examples()
848 #
849 # Prompt for building examples
850 #--------------------------------------------------------------------
851
852 sub html_examples {
853 return unless $TT_PREFIX;
854
855 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
856
9be7d64 @abw approaching 2.04d
authored
857
858 HTML Examples
859 -------------
860
c8d76d4 @abw *** empty log message ***
authored
861 A number of examples showing use of the HTML, Splash! and PostScript
862 libraries will be installed into:
863
a4123f8 @abw 2.04b
authored
864 $TT_PREFIX/examples
c8d76d4 @abw *** empty log message ***
authored
865
866 As with the documentation, the examples are provided in template form
867 and can be automatically built into HTML pages during the "make
868 install". These pages rely on the Splash! library and expect the
869 images URL to be correctly defined for correct viewing.
870
871 EOF
872
873 $TT_EXAMPLES = (
a4123f8 @abw 2.04b
authored
874 ttprompt('Do you want to build the HTML example pages?',
c8d76d4 @abw *** empty log message ***
authored
875 $TT_EXAMPLES) =~ /^y/i
876 );
877
878 #--------------------------------------------------------------------
879 # write ttree config file for building examples
880 #--------------------------------------------------------------------
881
882 open(FP, "> $TT_EXAMPLE_CFG") || die "$TT_EXAMPLE_CFG: $!\n";
883 print FP <<EOF;
884 # This ttree configuration file is automatically generated by
885 # the Makefile.PL installation script. Feel free to edit it
886 # but be warned that re-installing the Template Toolkit will
887 # overwrite your changes.
888
a4123f8 @abw 2.04b
authored
889 src = $TT_PREFIX/examples/src
890 dest = $TT_PREFIX/examples/html
891 lib = $TT_PREFIX/examples/lib
892 lib = $TT_PREFIX/templates
ca4050f @abw prep for 2.02
authored
893 define splash_fg = '$TT_SPLASH_FG'
894 define splash_bg = '$TT_SPLASH_BG'
c8d76d4 @abw *** empty log message ***
authored
895 pre_process = config
911a5e3 @abw *** empty log message ***
authored
896 recurse
897 verbose
c8d76d4 @abw *** empty log message ***
authored
898 EOF
899
900 close(FP);
901 }
a4123f8 @abw 2.04b
authored
902
903
904 #--------------------------------------------------------------------
905 # write_defaults()
906 #
907 # write configuration defaults to file
908 #--------------------------------------------------------------------
909
910 sub write_defaults {
ca4050f @abw prep for 2.02
authored
911 open(FP, "> $DEFAULTS_FILE") || die "$DEFAULTS_FILE: $!\n";
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
912 my ( $ttdbi, $ttdocs, $ttsplash, $ttexamples, $ttextras,
9be7d64 @abw approaching 2.04d
authored
913 $ttlatex, $ttxs_enable, $ttxs_default )
914 = map { $_ ? 'y' : 'n' }
915 ( $TT_RUN_DBI, $TT_BUILD_DOCS, $TT_SPLASH_DOCS, $TT_EXAMPLES,
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
916 $TT_EXTRAS, $TT_LATEX_ENABLE, $TT_XS_ENABLE, $TT_XS_DEFAULT );
ca4050f @abw prep for 2.02
authored
917 print FP <<EOF;
a4123f8 @abw 2.04b
authored
918 \$TT_PREFIX = '$TT_PREFIX';
f4df3b6 @abw approach v2.03
authored
919 \$TT_IMAGES = '$TT_IMAGES';
920 \$TT_RUN_DBI = '$ttdbi';
921 \$TT_BUILD_DOCS = '$ttdocs';
922 \$TT_SPLASH_DOCS = '$ttsplash';
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
923 \$TT_EXAMPLES = '$ttexamples';
924 \$TT_EXTRAS = '$ttextras';
f4df3b6 @abw approach v2.03
authored
925 \$TT_SPLASH_THEME = '$TT_SPLASH_THEME';
926 \$TT_LATEX_ENABLE = '$ttlatex';
927 \$TT_LATEX_PATH = '$TT_LATEX_PATH';
928 \$TT_PDFLATEX_PATH = '$TT_PDFLATEX_PATH';
929 \$TT_DVIPS_PATH = '$TT_DVIPS_PATH';
9be7d64 @abw approaching 2.04d
authored
930 \$TT_XS_ENABLE = '$ttxs_enable';
931 \$TT_XS_DEFAULT = '$ttxs_default';
a4123f8 @abw 2.04b
authored
932 \$TT_ACCEPT = '$TT_ACCEPT';
933 \$TT_QUIET = '$TT_QUIET';
9acc796 @abw post 2.03a
authored
934 1;
ca4050f @abw prep for 2.02
authored
935 EOF
936 close(FP);
c8d76d4 @abw *** empty log message ***
authored
937 }
938
48634a1 @abw *** empty log message ***
authored
939
940 #------------------------------------------------------------------------
941 # build_docs()
942 #
943 # Echo the relevant incantation so that 'make dist' regenerates the
944 # documentation from the template sources.
25a8d8e @abw *** empty log message ***
authored
945 #------------------------------------------------------------------------
eabb19e @abw *** empty log message ***
authored
946
3ebfa07 @abw Initial revision
authored
947 sub build_docs {
948 return <<EOF;
949 echo "Building documentation for version \$(VERSION)" ; \\
28cc36e @abw prep for 2.06d
authored
950 \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) bin/ttree -f ./docs/ttdist.cfg --define version=\$(VERSION) -a; \\
3ebfa07 @abw Initial revision
authored
951 EOF
952 }
953
48634a1 @abw *** empty log message ***
authored
954
82cbea8 @abw version 2.00
authored
955
956 #------------------------------------------------------------------------
867f44f @abw rc2
authored
957 # check_taf()
958 #
959 # There are some problems with Text::Autoformat with version of Perl
960 # prior to 5.6.0 not working properly with locales that use a numerical
961 # separator other than '.' (e.g. Swedish)
962 #------------------------------------------------------------------------
963
964 sub check_taf {
965 use POSIX qw( localeconv );
966 my $loc = localeconv;
967 my $dec = $loc->{ decimal_point };
968
969 yep("version $Text::Autoformat::VERSION installed");
970
971 if ($] <= 5.006 && $dec ne '.') {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
972 print ' ' x 6,
973 "NOTE: tests 23 and 25 may fail under your locale, see TODO file.\n";
867f44f @abw rc2
authored
974 }
975 }
976
977
978 #------------------------------------------------------------------------
acff212 @abw *** empty log message ***
authored
979 # check_dom()
980 #
867f44f @abw rc2
authored
981 # XML::DOM changed from HASH to ARRAY objects somewhere between versions
982 # 1.25 and 1.27, so the latter version is an absolute necessity.
60dfe44 @abw *** empty log message ***
authored
983 #------------------------------------------------------------------------
984
985 sub check_dom {
867f44f @abw rc2
authored
986 if ($XML::DOM::VERSION < 1.27) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
987 nope("requires version 1.27 or later ($XML::DOM::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
988 }
989 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
990 yep("version $XML::DOM::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
991 }
992 }
993
994
acff212 @abw *** empty log message ***
authored
995 #------------------------------------------------------------------------
996 # check_rss()
997 #
998 # Version 0.8 of XML::RSS gave warnings under Perl 5.6.0 so issue an
999 # upgrade recommendation
1000 #------------------------------------------------------------------------
1001
60dfe44 @abw *** empty log message ***
authored
1002 sub check_rss {
82cbea8 @abw version 2.00
authored
1003 if ($] >= 5.006 && $XML::RSS::VERSION < 0.9) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1004 nope("requires version 0.9 or later ($XML::RSS::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
1005 }
1006 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1007 yep("version $XML::RSS::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
1008 }
1009 }
1010
a4123f8 @abw 2.04b
authored
1011
acff212 @abw *** empty log message ***
authored
1012 #------------------------------------------------------------------------
1013 # check_xpath()
1014 #
1015 # Tests fail under some of the earlier versions (e.g. 0.55) so we issue
1016 # an upgrade recommendation.
1017 #------------------------------------------------------------------------
60dfe44 @abw *** empty log message ***
authored
1018
1019 sub check_xpath {
1020 if ($XML::XPath::VERSION < 1.00) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1021 nope("requires version 1.00 or later ($XML::XPath::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
1022 }
1023 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1024 yep("version $XML::XPath::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
1025 }
1026 }
1027
1028
1029 #------------------------------------------------------------------------
48634a1 @abw *** empty log message ***
authored
1030 # dbi_config()
1031 #
1032 # Quiz the user for options related to running the DBI tests.
1033 #------------------------------------------------------------------------
1034
1035 sub dbi_config {
a4123f8 @abw 2.04b
authored
1036 my ($dsn, $user, $pass) = ('') x 3;
48634a1 @abw *** empty log message ***
authored
1037
a4123f8 @abw 2.04b
authored
1038 message("[X] version $DBI::VERSION installed, configuring tests\n\n");
48634a1 @abw *** empty log message ***
authored
1039
a4123f8 @abw 2.04b
authored
1040 if (ttprompt("Do you want to run the DBI tests?\n" .
c8d76d4 @abw *** empty log message ***
authored
1041 "It requires access to an existing test database.",
ca4050f @abw prep for 2.02
authored
1042 $TT_RUN_DBI) =~ /y/i) {
48634a1 @abw *** empty log message ***
authored
1043
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1044 $TT_RUN_DBI = 1;
1045 my ($driver, $dbname);
1046 my @drivers = DBI->available_drivers();
1047 local $" = ', ';
1048
1049 my $default = (grep(/m.?sql/i, @drivers))[0]
1050 || $drivers[0] || '';
1051
1052 message(<<EOF);
48634a1 @abw *** empty log message ***
authored
1053
9be7d64 @abw approaching 2.04d
authored
1054 DBI Test Configuration
1055 ----------------------
1056
c8d76d4 @abw *** empty log message ***
authored
1057 Please enter the driver name for the test database.
1058 The DBD drivers installed on your system are
1059
1060 @drivers
867f44f @abw rc2
authored
1061
1062 EOF
48634a1 @abw *** empty log message ***
authored
1063
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1064 while (! $driver) {
1065 $driver = ttprompt("Enter driver name: ", $default);
1066 message("! No such DBD driver\n"), undef $driver
1067 unless grep(/^$driver$/, @drivers);
1068 }
1069
1070 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
1071
1072 Now enter the data source (DSN) for the test database.
1073 Many DBD drivers require only a database name (e.g. 'test') while
1074 others may require an alternate format or additional parameters
1075 (e.g. 'dbname=test'). Please consult your DBD documentation for
1076 further details.
1077
867f44f @abw rc2
authored
1078 EOF
1079
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1080 my $dbname_eg = $driver eq 'Pg' ? 'dbname=test' : 'test';
1081 while (! $dbname) {
1082 $dbname = ttprompt('Database name: ', $dbname_eg);
1083 }
48634a1 @abw *** empty log message ***
authored
1084
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1085 $dsn = "dbi:$driver:$dbname";
1086 $user = ttprompt('Enter user name : ', '');
1087 $pass = ttprompt('Enter password : ', '');
1088 $user = '' unless defined $user;
1089 $pass = '' unless defined $pass;
48634a1 @abw *** empty log message ***
authored
1090 }
1091 else {
ca4050f @abw prep for 2.02
authored
1092 $TT_RUN_DBI = 0;
48634a1 @abw *** empty log message ***
authored
1093 }
1094
a4123f8 @abw 2.04b
authored
1095 message("\nwriting $DBI_CONFIG_FILE\n");
48634a1 @abw *** empty log message ***
authored
1096 open(CFGFILE, ">$DBI_CONFIG_FILE") || die "$DBI_CONFIG_FILE: $!\n";
1097 print CFGFILE <<EOF;
ca4050f @abw prep for 2.02
authored
1098 \$run = $TT_RUN_DBI;
48634a1 @abw *** empty log message ***
authored
1099 \$dsn = '$dsn';
1100 \$user = '$user';
1101 \$pass = '$pass';
1102 1;
1103 EOF
1104 close(CFGFILE);
1105 }
1106
c8d76d4 @abw *** empty log message ***
authored
1107
1108
1109 #------------------------------------------------------------------------
1110 # fix_file($file, $find, $fix)
1111 #
1112 # Fixes a variable definition in a file. e.g.
d941238 @abw prep 2.4d
authored
1113 # fix_file('templates/splash/config', 'images', '/tt2/splash')
c8d76d4 @abw *** empty log message ***
authored
1114 #------------------------------------------------------------------------
1115
1116 sub fix_file {
1117 my ($file, $find, $fix) = @_;
1118 local *FP;
1119 local $/ = undef;
1120
1121 $find = quotemeta($find);
1122
1123 open(FP, "< $file") || die "$file: $!\n";
1124 my $text = <FP>;
1125 close(FP);
1126
1127 ($text =~ s/^(\s*${find}\s*=\s*)'.*?'/$1'$fix'/m)
1128 || die "$find not found in $file\n";
1129
1130 open(FP, "> $file") || die "$file: $!\n";
1131 print FP $text;
1132 close(FP);
1133 }
1134
a4123f8 @abw 2.04b
authored
1135
1136 #------------------------------------------------------------------------
9be7d64 @abw approaching 2.04d
authored
1137 # find_program($path, $prog)
f4df3b6 @abw approach v2.03
authored
1138 #
1139 # Find a program, $prog, by traversing the given directory path, $path.
1140 # Returns full path if the program is found.
1141 #
1142 # Written by Craig Barratt, Richard Tietjen add fixes for Win32.
9be7d64 @abw approaching 2.04d
authored
1143 #
1144 # abw changed name from studly caps findProgram() to find_program() :-)
a4123f8 @abw 2.04b
authored
1145 #------------------------------------------------------------------------
1146
9be7d64 @abw approaching 2.04d
authored
1147 sub find_program {
f4df3b6 @abw approach v2.03
authored
1148 my($path, $prog) = @_;
714a8cd @abw * prep for release 2.07a
authored
1149 # my $sep = $WIN32 ? qr/;/ : qr/:/;
1150 # foreach my $dir ( split($sep, $path) ) {
1151 foreach my $dir ( split($Config{path_sep}, $path) ) {
f4df3b6 @abw approach v2.03
authored
1152 my $file = File::Spec->catfile($dir, $prog);
1153 if ( !$WIN32 ) {
1154 return $file if ( -x $file );
1155 } else {
1156 # Windows executables end in .xxx, exe precedes .bat and .cmd
1157 foreach my $dx ( qw/exe bat cmd/ ) {
1158 return "$file.$dx" if ( -x "$file.$dx" );
1159 }
1160 }
1161 }
1162 }
a4123f8 @abw 2.04b
authored
1163
1164
1165 #------------------------------------------------------------------------
1166 # message($text)
1167 #
1168 # Print message unless quiet mode.
1169 #------------------------------------------------------------------------
1170
1171 sub message {
1172 return if $TT_QUIET;
1173 print @_;
1174 }
1175
1176
1177 #------------------------------------------------------------------------
1178 # ttprompt($message, $default)
1179 #------------------------------------------------------------------------
1180
1181 sub ttprompt {
1182 my ($msg, $def)=@_;
1183 my $ISA_TTY = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
1184 my $dispdef = defined $def ? "[$def] " : " ";
1185 $def = defined $def ? $def : "";
1186 my $ans = '';
1187 local $|=1;
1188 print "$msg $dispdef" unless $TT_QUIET;
1189 if ($TT_ACCEPT || ! $ISA_TTY) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1190 print "$def\n" unless $TT_QUIET;
a4123f8 @abw 2.04b
authored
1191 }
1192 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
1193 chomp($ans = <STDIN>);
a4123f8 @abw 2.04b
authored
1194 }
1195 return ($ans ne '') ? $ans : $def;
1196 }
1197
1198
1199 #------------------------------------------------------------------------
1200 # yep($text)
1201 #------------------------------------------------------------------------
1202
1203 sub yep {
1204 return if $TT_QUIET;
1205 print '[X] ', shift, "\n";
1206 }
1207
1208
1209 #------------------------------------------------------------------------
1210 # nope($text)
1211 #------------------------------------------------------------------------
1212 sub nope {
1213 return if $TT_QUIET;
1214 print '[ ] ', shift, "\n";
1215 }
Something went wrong with that request. Please try again.