Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 931 lines (714 sloc) 27.048 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
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
16 use vars qw( $TT_VERSION $TT_PREFIX $TT_IMAGES
17 $TT_BUILD_DOCS $TT_SPLASH_DOCS $TT_EXAMPLES $TT_EXTRAS
18 $TT_XS_ENABLE $TT_XS_DEFAULT
19 $TT_SPLASH_THEME $TT_QUIET $TT_ACCEPT $TT_YES );
a4123f8 @abw 2.04b
authored
20
21 # check O/S to set sensible defaults
9be7d64 @abw approaching 2.04d
authored
22
23 my ($WIN32, $FLAVOUR, $PREFIX, $IMAGES, $MAKE);
dd62af1 @abw * Applied Chris' patch to fix win => MSWin32
authored
24 if ($^O eq 'MSWin32') { # any others also?
a4123f8 @abw 2.04b
authored
25 $WIN32 = 1;
26 $FLAVOUR = 'Win32';
27 $PREFIX = 'C:/Program Files/Template Toolkit 2';
9be7d64 @abw approaching 2.04d
authored
28 $IMAGES = '/tt2/images';
a4123f8 @abw 2.04b
authored
29 $MAKE = 'nmake';
30 }
31 else {
32 $WIN32 = 0;
33 $FLAVOUR = 'Unix';
34 $PREFIX = '/usr/local/tt2';
9be7d64 @abw approaching 2.04d
authored
35 $IMAGES = '/tt2/images';
a4123f8 @abw 2.04b
authored
36 $MAKE = 'make';
37 }
38
9be7d64 @abw approaching 2.04d
authored
39
40 # read command line args putting TT_* into $ttconfig and
41 # everything else (regular Makefile.PL args, e.g. PREFIX)
42 # goes into $config
43
a4123f8 @abw 2.04b
authored
44 my (%config, %ttconfig);
45 while ($_ = shift) {
46 my ($k, $v) = split(/=/);
47 if ($k =~ /^TT/) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
48 $ttconfig{ $k } = $v || 0;
a4123f8 @abw 2.04b
authored
49 }
50 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
51 $config{ $k } = $v || 0;
a4123f8 @abw 2.04b
authored
52 }
53 };
54
9be7d64 @abw approaching 2.04d
authored
55
56 # print help if they asked for it
57
a4123f8 @abw 2.04b
authored
58 if (exists $ttconfig{ TT_HELP }) {
59 print <<EOF;
60 The following options can be specified as command line
61 arguments to 'perl Makefile.PL'. e.g.
62
9be7d64 @abw approaching 2.04d
authored
63 perl Makefile.PL TT_PREFIX=/my/tt2/dir TT_ACCEPT=y
64
65 TT_PREFIX installation prefix ($PREFIX)
66 TT_IMAGES images URL (/tt2/images)
67 TT_DOCS build HTML docs (y)
68 TT_SPLASH use Splash! for docs (y)
69 TT_THEME Splash! theme (default)
70 TT_EXAMPLES build HTML examples (y)
ea05afc @abw * applied patch from Axel Gerstmair to add TT_EXTRAS option to Makefile....
authored
71 TT_EXTRAS install optional extras (y)
9be7d64 @abw approaching 2.04d
authored
72 TT_XS_ENABLE Enable XS Stash (y)
73 TT_XS_DEFAULT Use XS Stash by default (y)
74 TT_QUIET no messages (n)
75 TT_ACCEPT accept defaults (n)
a4123f8 @abw 2.04b
authored
76
77 By default, the Makefile.PL runs in interactive mode,
78 prompting for confirmation of the various configuration
79 options. Setting the TT_ACCEPT option causes the default
80 value (possibly modified by other command line options)
81 to be accepted. The TT_QUIET option can also be set to
82 suppress the prompt messages.
83
84 EOF
85 exit(0);
86 }
ca4050f @abw prep for 2.02
authored
87
9be7d64 @abw approaching 2.04d
authored
88 # these global package variables are the main flags used
89 # in this script, here defaulted to sensible values
90
a4123f8 @abw 2.04b
authored
91 $TT_VERSION = $Template::VERSION;
92 $TT_PREFIX = $PREFIX;
9be7d64 @abw approaching 2.04d
authored
93 $TT_IMAGES = $IMAGES;
f4df3b6 @abw approach v2.03
authored
94 $TT_BUILD_DOCS = 'y';
95 $TT_SPLASH_DOCS = 'y';
96 $TT_EXAMPLES = 'y';
ea05afc @abw * applied patch from Axel Gerstmair to add TT_EXTRAS option to Makefile....
authored
97 $TT_EXTRAS = 'y';
f4df3b6 @abw approach v2.03
authored
98 $TT_SPLASH_THEME = 'default';
9be7d64 @abw approaching 2.04d
authored
99 $TT_XS_ENABLE = 'y';
100 $TT_XS_DEFAULT = 'y';
a4123f8 @abw 2.04b
authored
101 $TT_QUIET = 'n';
102 $TT_ACCEPT = 'n';
f4df3b6 @abw approach v2.03
authored
103
46e4eb8 @abw * Added new colour theme called 'leon'
authored
104 my $TT_SPLASH_FG = '';
105 my $TT_SPLASH_BG = '';
106 my $TT_SPLASH_FT = '';
107 my $TT_SPLASH_BT = '';
ca4050f @abw prep for 2.02
authored
108
109 my $DEFAULTS_FILE = '.defaults.cfg';
714a8cd @abw * prep for release 2.07a
authored
110 my $TT_DOCS_CFG = catfile('docs','ttree.cfg');
111 my $TT_EXAMPLE_CFG = catfile('examples','ttree.cfg');
ca4050f @abw prep for 2.02
authored
112 my $DEFAULTS = '';
911a5e3 @abw *** empty log message ***
authored
113
ca4050f @abw prep for 2.02
authored
114 if (-f $DEFAULTS_FILE) {
115 require $DEFAULTS_FILE;
116 $DEFAULTS = " read from '$DEFAULTS_FILE'";
117 }
118
9be7d64 @abw approaching 2.04d
authored
119 $TT_PREFIX = $ttconfig{ TT_PREFIX } if $ttconfig{ TT_PREFIX };
120 $TT_IMAGES = $ttconfig{ TT_IMAGES } if $ttconfig{ TT_IMAGES };
121 $TT_SPLASH_THEME = $ttconfig{ TT_THEME } if $ttconfig{ TT_THEME };
122 $TT_BUILD_DOCS = $ttconfig{ TT_DOCS } if defined $ttconfig{ TT_DOCS };
123 $TT_SPLASH_DOCS = $ttconfig{ TT_SPLASH } if defined $ttconfig{ TT_SPLASH };
124 $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
125 $TT_EXTRAS = $ttconfig{ TT_EXTRAS } if defined $ttconfig{ TT_EXTRAS };
9be7d64 @abw approaching 2.04d
authored
126 $TT_XS_ENABLE = $ttconfig{ TT_XS_ENABLE } if defined $ttconfig{ TT_XS_ENABLE };
127 $TT_XS_DEFAULT = $ttconfig{ TT_XS_DEFAULT } if defined $ttconfig{ TT_XS_DEFAULT };
128 $TT_QUIET = $ttconfig{ TT_QUIET } if defined $ttconfig{ TT_QUIET };
129
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
130 if (defined $ttconfig{ TT_ACCEPT }) {
131 $TT_ACCEPT = $ttconfig{ TT_ACCEPT };
132 }
133 else {
134 # standard behaviour for MakeMaker to indicate accept all defaults
135 $TT_ACCEPT = $ENV{PERL_MM_USE_DEFAULT} ? 'y' : 'n';
136 }
137
138 foreach ($TT_BUILD_DOCS, $TT_SPLASH_DOCS, $TT_EXAMPLES,
139 $TT_EXTRAS, $TT_XS_ENABLE, $TT_XS_DEFAULT ) {
a4123f8 @abw 2.04b
authored
140 $_ = 'n' if ! $_;
141 }
142 $TT_ACCEPT = 0 if $TT_ACCEPT eq 'n';
143 $TT_QUIET = 0 if $TT_QUIET eq 'n';
144 $TT_QUIET = 0 unless $TT_ACCEPT;
145
ca4050f @abw prep for 2.02
authored
146 my $SPLASH_STYLES = {
147 default => [ 'lilac', 'mauve' ],
148 aqua => [ 'aqua', 'marine' ],
149 grey => [ 'grey75', 'grey50' ],
150 blue => [ 'grey75', 'blue75' ],
151 red => [ 'grey75', 'red75' ],
152 green => [ 'grey75', 'green75' ],
46e4eb8 @abw * Added new colour theme called 'leon'
authored
153 leon => [ 'red75', 'orange', 'white', 'black' ],
ca4050f @abw prep for 2.02
authored
154 };
155
c542301 @abw *** empty log message ***
authored
156
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
157 # define version numbers of required modules
158 my $TT_APPCONFIG_VERSION = '1.55';
159 my $TT_FILE_SPEC_VERSION = '0.8';
160 my $TT_FILE_TEMP_VERSION = '0.12';
161
162
a4123f8 @abw 2.04b
authored
163 #========================================================================
164
165 welcome_message();
166 version_check();
28cc36e @abw prep for 2.06d
authored
167 mandatory_modules();
9be7d64 @abw approaching 2.04d
authored
168 optional_stash_xs();
a4123f8 @abw 2.04b
authored
169 optional_extras();
170 splash_images();
171 html_docs();
172 html_docstyle();
173 html_examples();
174 write_defaults();
175
176 print "\n";
177
178
179 #------------------------------------------------------------------------
180 # build options and write Makefile
181 #------------------------------------------------------------------------
182
183 package MY;
184
185 sub postamble {
186 return '' unless $main::TT_PREFIX;
187 my $amble =<<'EOF';
188 tt2_install ::
189 @$(PERL) bin/tt2inst -v "$(TT_PREFIX)"
190
191 tt2_splash ::
582a703 @abw * Applied a patch from Christian Schaffner which fixes a problem in
authored
192 @$(PERL) -I$(INST_LIB) -I$(INST_ARCHLIB) bin/gifsplash -v -i "$(TT_PREFIX)"
a4123f8 @abw 2.04b
authored
193
194 EOF
195 $amble .=<<EOF if $main::TT_BUILD_DOCS;
196 tt2_html_docs ::
582a703 @abw * Applied a patch from Christian Schaffner which fixes a problem in
authored
197 \@\$(PERL) -I\$(INST_LIB) -I\$(INST_ARCHLIB) bin/ttree -v -f "\$(TT_PREFIX)/$TT_DOCS_CFG"
a4123f8 @abw 2.04b
authored
198
199 EOF
200 $amble .=<<EOF if $main::TT_EXAMPLES;
201 tt2_examples ::
582a703 @abw * Applied a patch from Christian Schaffner which fixes a problem in
authored
202 \@\$(PERL) -I\$(INST_LIB) -I\$(INST_ARCHLIB) bin/ttree -v -f "\$(TT_PREFIX)/$TT_EXAMPLE_CFG"
a4123f8 @abw 2.04b
authored
203
204 EOF
205 return $amble;
206 }
207
208 sub install {
209 my $class = shift;
210 my $basic = $class->SUPER::install(@_);
211 my $add = 'tt2_install tt2_splash';
212 $add .= ' tt2_html_docs' if $main::TT_BUILD_DOCS;
213 $add .= ' tt2_examples' if $main::TT_EXAMPLES;
214 $basic =~ s/^(install\s+::\s+.*)$/$1 $add/m
215 if $main::TT_PREFIX;
216 $basic;
217 }
218
219 sub constants {
220 my $class = shift;
221 my $basic = $class->SUPER::constants(@_);
222 $basic = "TT_PREFIX = $main::TT_PREFIX\n$basic"
223 if $main::TT_PREFIX;
224 $basic;
225 }
226
227 package main;
228
229 my %opts = (
230 %config,
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
231 'NAME' => 'Template',
a4123f8 @abw 2.04b
authored
232 'DISTNAME' => 'Template-Toolkit',
233 'VERSION_FROM' => 'lib/Template.pm',
234 'EXE_FILES' => [ 'bin/tpage', 'bin/ttree' ],
235 'PMLIBDIRS' => [ 'lib' ],
9be7d64 @abw approaching 2.04d
authored
236 'DIR' => [ ],
c7d3d41 @abw * removed mandatory modules check from Makefile.PL to keep CPAN module
authored
237 'PREREQ_PM' => {
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
238 'AppConfig' => $TT_APPCONFIG_VERSION,
239 'File::Spec' => $TT_FILE_SPEC_VERSION,
240 'File::Temp' => $TT_FILE_TEMP_VERSION,
c7d3d41 @abw * removed mandatory modules check from Makefile.PL to keep CPAN module
authored
241 },
a4123f8 @abw 2.04b
authored
242 'dist' => {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
243 'COMPRESS' => 'gzip',
244 'SUFFIX' => 'gz',
a4123f8 @abw 2.04b
authored
245 },
28cc36e @abw prep for 2.06d
authored
246 'clean' => {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
247 'FILES' => join(' ', qw( docs/ttree.cfg
248 examples/ttree.cfg
249 t/dbi_test.cfg
250 t/test/src/baz.ttc
251 t/test/src/complex.org
252 t/test/src/complex.ttc
253 t/test/src/evalperl.ttc
254 t/test/src/foo.ttc )),
28cc36e @abw prep for 2.06d
authored
255 },
a4123f8 @abw 2.04b
authored
256 );
257
9be7d64 @abw approaching 2.04d
authored
258 push @{ $opts{'DIR'} }, 'xs' if $TT_XS_ENABLE;
259
a4123f8 @abw 2.04b
authored
260 if ($ExtUtils::MakeMaker::VERSION >= 5.43) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
261 $opts{ AUTHOR } = 'Andy Wardley <abw@wardley.org>';
262 $opts{ ABSTRACT } = 'comprehensive template processing system',
a4123f8 @abw 2.04b
authored
263 }
264
265
266 WriteMakefile( %opts );
267
268 print <<EOF;
269
270 Configuration complete. You should now run '$MAKE', '$MAKE test' and
271 then '$MAKE install'. See the README file for further information.
272 EOF
273
ea05afc @abw * applied patch from Axel Gerstmair to add TT_EXTRAS option to Makefile....
authored
274 message(<<EOF) if $TT_PREFIX;
a4123f8 @abw 2.04b
authored
275
9be7d64 @abw approaching 2.04d
authored
276
277 Installation Notes
278 ------------------
279
a4123f8 @abw 2.04b
authored
280 Please note that the installation of the optional components and
281 building of the HTML documentation is performed at the "make install"
282 stage as the effective user at that time. This implies that this user
283 must have sufficient permission to install into the specified
284 directory and that all created directories and files will be owned by
285 them.
286
287 EOF
288
289 #========================================================================
290
291
292
293 #------------------------------------------------------------------------
294 # welcome_message()
295 #
296 # Print opening banner.
297 #------------------------------------------------------------------------
298
299 sub welcome_message {
300 print(<<EOF);
301
302 Template Toolkit Version $TT_VERSION
c542301 @abw *** empty log message ***
authored
303 =============================
911a5e3 @abw *** empty log message ***
authored
304
ca4050f @abw prep for 2.02
authored
305 Using $FLAVOUR defaults$DEFAULTS.
9be7d64 @abw approaching 2.04d
authored
306 Run 'perl Makefile.PL TT_HELP' for a summary of options.
48634a1 @abw *** empty log message ***
authored
307 EOF
a4123f8 @abw 2.04b
authored
308 print "Messages suppressed (TT_QUIET). " if $TT_QUIET;
309 print "Accepting defaults automatically (TT_ACCEPT)." if $TT_ACCEPT;
310 }
311
312
48634a1 @abw *** empty log message ***
authored
313
314 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
315 # version_check()
316 #
317 # Check for pre-version 2.00 installation and issue warning
48634a1 @abw *** empty log message ***
authored
318 #------------------------------------------------------------------------
319
a4123f8 @abw 2.04b
authored
320 sub version_check {
321 eval "use Template";
322 unless ($@ or $Template::VERSION =~ /^2/) {
323 warn(<<EOF) unless $TT_QUIET;
48634a1 @abw *** empty log message ***
authored
324
c542301 @abw *** empty log message ***
authored
325 IMPORTANT NOTE:
a4123f8 @abw 2.04b
authored
326
48634a1 @abw *** empty log message ***
authored
327 You have version $Template::VERSION of the Template Toolkit installed.
25a8d8e @abw *** empty log message ***
authored
328
82cbea8 @abw version 2.00
authored
329 There are some minor incompatabilities between version 1 and 2
48634a1 @abw *** empty log message ***
authored
330 of the Template Toolkit which you should be aware of. Installing
331 this version will overwrite your version $Template::VERSION files
332 unless you take measures to install one or the other version in a
82cbea8 @abw version 2.00
authored
333 different location (i.e. perl Makefile.PL PREFIX=/other/path).
48634a1 @abw *** empty log message ***
authored
334
335 Please consult the README and Changes file for further details.
336 Most of the changes are in the more obscure features and
337 directives so hopefully you will find the upgrade process fairly
9be7d64 @abw approaching 2.04d
authored
338 painless. If you're feeling brave, then answer 'y', otherwise 'n'.
25a8d8e @abw *** empty log message ***
authored
339
340 EOF
a4123f8 @abw 2.04b
authored
341 exit unless ttprompt("Do you want to continue?", 'y') =~ /y/i;
342 }
48634a1 @abw *** empty log message ***
authored
343 }
344
a4123f8 @abw 2.04b
authored
345
48634a1 @abw *** empty log message ***
authored
346 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
347 # mandatory_modules()
348 #
349 # Detect mandatory module
c8d76d4 @abw *** empty log message ***
authored
350 #------------------------------------------------------------------------
351
a4123f8 @abw 2.04b
authored
352 sub mandatory_modules {
353 eval "use AppConfig";
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
354 if ($@ or $AppConfig::VERSION < $TT_APPCONFIG_VERSION) {
28cc36e @abw prep for 2.06d
authored
355 warn(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
356
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
357 The Template Toolkit requires that the AppConfig module (version $TT_APPCONFIG_VERSION
358 or later) first be installed. This is used by
359 the 'ttree' program for reading command line options and configuration
360 files. It is available from CPAN:
c8d76d4 @abw *** empty log message ***
authored
361
362 http://www.cpan.org/authors/Andy_Wardley/
363
364 EOF
a4123f8 @abw 2.04b
authored
365 }
c8d76d4 @abw *** empty log message ***
authored
366
a4123f8 @abw 2.04b
authored
367 eval "use File::Spec";
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
368 if ($@ or $File::Spec::VERSION < $TT_FILE_SPEC_VERSION) {
28cc36e @abw prep for 2.06d
authored
369 warn(<<EOF);
911a5e3 @abw *** empty log message ***
authored
370
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
371 The Template Toolkit requires that the File::Spec module (version $TT_FILE_SPEC_VERSION
911a5e3 @abw *** empty log message ***
authored
372 or later) first be installed. This is used by the File plugin. It is
373 available from CPAN:
374
375 http://search.cpan.org/search?dist=File-Spec
376
377 EOF
a4123f8 @abw 2.04b
authored
378 }
911a5e3 @abw *** empty log message ***
authored
379
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
380 eval "use File::Temp";
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
381 if ($@ or $File::Temp::VERSION < $TT_FILE_TEMP_VERSION) {
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
382 warn(<<EOF);
383
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
384 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
385 or later) first be installed. This is used by the Template::Document
386 class for storing compiled templates. It is available from CPAN:
387
388 http://search.cpan.org/search?dist=File-Temp
389
390 EOF
391 }
392 }
911a5e3 @abw *** empty log message ***
authored
393
a4123f8 @abw 2.04b
authored
394
c8d76d4 @abw *** empty log message ***
authored
395 #------------------------------------------------------------------------
9be7d64 @abw approaching 2.04d
authored
396 # optional_stash_xs()
397 #
398 # Prompt for installation and default use of XS Stash.
399 #------------------------------------------------------------------------
400
401 sub optional_stash_xs {
402 # return if $TT_ACCEPT && (! $TT_XS_ENABLE || $TT_XS_ENABLE eq 'n');
403
404 message(<<EOF);
405
406
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
407 Template::Stash::XS
408 -------------------
409
410 The Template::Stash module is a core part of the Template Toolkit,
411 implementing the magic for accessing data using the dot notation.
9be7d64 @abw approaching 2.04d
authored
412
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
413 There is a high speed version, Template::Stash::XS, written in C.
414 This makes the Template Toolkit run about twice as fast as when using
415 the regular Template::Stash written in Perl. If you've got a C
416 compiler on your system then you can elect to have the XS Stash built.
417 You can also specify that you want to use the XS Stash by default.
9be7d64 @abw approaching 2.04d
authored
418
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
419 Please note that the XS Stash doesn't support access to tied hashes or
420 tied lists (e.g. Tie::DBI). If you're using tied objects then you'll
421 need to explicitly tell the Template Toolkit that you want to use the
422 Perl version. You can specify which stash module you want by setting
423 the \$Template::Config::STASH package variable.
9be7d64 @abw approaching 2.04d
authored
424
425 use Template;
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
426 use Template::Config;
9be7d64 @abw approaching 2.04d
authored
427
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
428 \$Template::Config::STASH = 'Template::Stash';
429 \$tt = Template->new(); # uses Perl stash
9be7d64 @abw approaching 2.04d
authored
430
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
431 \$Template::Config::STASH = 'Template::Stash::XS';
432 \$tt = Template->new(); # uses XS stash
433
434 See 'perldoc Template::Config' for further details.
9be7d64 @abw approaching 2.04d
authored
435
436 EOF
437
438 $TT_XS_ENABLE = (ttprompt('Do you want to build the XS Stash module?',
439 $TT_XS_ENABLE) =~ /^y/i);
440
441 if ($TT_XS_ENABLE) {
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
442 $TT_XS_DEFAULT =
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
443 (ttprompt('Do you want to use the XS Stash by default?',
444 $TT_XS_DEFAULT) =~ /^y/i);
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
445 }
446 else {
447 # If the XS stash is disabled, we cannot use it as the default stash.
448 $TT_XS_DEFAULT = 0;
449 }
9be7d64 @abw approaching 2.04d
authored
450
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
451 # Actually, we would have to fix 'Config.pm' only if the XS stash is
452 # disabled. But this way, we are sure the correct module is used.
714a8cd @abw * prep for release 2.07a
authored
453 fix_file(catfile('lib','Template','Config.pm'),
d941238 @abw prep 2.4d
authored
454 '$STASH',
455 $TT_XS_DEFAULT ? 'Template::Stash::XS' : 'Template::Stash');
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
456 }
f4df3b6 @abw approach v2.03
authored
457
458
459
a4123f8 @abw 2.04b
authored
460
f4df3b6 @abw approach v2.03
authored
461 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
462 # optional_extras()
463 #
464 # Prompt for installation of optional libraries and other components
c8d76d4 @abw *** empty log message ***
authored
465 #------------------------------------------------------------------------
466
a4123f8 @abw 2.04b
authored
467 sub optional_extras {
468 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
469
9be7d64 @abw approaching 2.04d
authored
470
471 Optional Extras
472 ---------------
473
c8d76d4 @abw *** empty log message ***
authored
474 In additional to the Perl modules and POD documentation installed in
475 the usual way, the Template Toolkit distribution also contains a
476 number of optional components:
477
478 * Template libaries for basic HTML, Pod -> HTML, and PostScript
479
480 * Splash! - a stylish HTML user interface template library / widget set
481
482 * HTML documentation - distributed in template form for customisation
483
484 * Stylesheet templates to generate docs as vanilla HTML or using Splash!
485
486 * Examples - numerous examples of using the template libraries
487
488 If you want to install these optional components then you'll need to
489 specify a separate directory for them.
490
491 EOF
492
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
493 if ($TT_EXTRAS = (
494 ttprompt('Do you want to install these components?',
495 $TT_EXTRAS) =~ /^y/i)) {
a4123f8 @abw 2.04b
authored
496 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
497
498 You can chose any directory for the installation of the additional
911a5e3 @abw *** empty log message ***
authored
499 Template Toolkit components. The proposed default assumes a $FLAVOUR
500 flavour to your operating system (suggestions for suitable defaults
501 for other platforms welcome).
c8d76d4 @abw *** empty log message ***
authored
502
503 EOF
9be7d64 @abw approaching 2.04d
authored
504 $TT_PREFIX = ttprompt('Installation directory', $TT_PREFIX || $PREFIX);
73afe6d @abw * Applied Axel's patch to remove trailing '/' from installation dir.
authored
505 $TT_PREFIX =~ s[/$][];
a4123f8 @abw 2.04b
authored
506 }
507 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
508 $TT_PREFIX = '';
a4123f8 @abw 2.04b
authored
509 }
510
714a8cd @abw * prep for release 2.07a
authored
511 fix_file(catfile('lib','Template','Config.pm'), '$INSTDIR', $TT_PREFIX);
c8d76d4 @abw *** empty log message ***
authored
512 }
513
514
515
516 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
517 # splash_images()
518 #
519 # Prompt for Splash! image URL
c8d76d4 @abw *** empty log message ***
authored
520 #------------------------------------------------------------------------
521
a4123f8 @abw 2.04b
authored
522 sub splash_images {
523 return unless $TT_PREFIX;
911a5e3 @abw *** empty log message ***
authored
524
a4123f8 @abw 2.04b
authored
525 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
526
9be7d64 @abw approaching 2.04d
authored
527
528 Splash!
529 -------
530
c8d76d4 @abw *** empty log message ***
authored
531 The Splash! template library uses a number of (very) small images to
532 build user interface components. These will be installed into the
533 directory:
534
a4123f8 @abw 2.04b
authored
535 $TT_PREFIX/images
911a5e3 @abw *** empty log message ***
authored
536 EOF
537
538 if ($WIN32) {
539 # default images value for Win32 to browse via file system
a4123f8 @abw 2.04b
authored
540 $TT_IMAGES = "$TT_PREFIX/images";
541
542 message(<<EOF);
543
911a5e3 @abw *** empty log message ***
authored
544 If you want to use the Splash! library then you'll need to make sure
545 you can access these images via your browser. If you want to deliver
546 pages via a web server then you'll need to specify the URL that can be
547 use to access these images. In the general case you can accept the
548 default and access the images via the filesystem.
549
550 EOF
551 }
552 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
553 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
554
555 If you want to use the Splash! library then you'll need to copy these
556 images, define an alias (e.g. in the httpd.conf) or create a symbolic
557 link to them so that your web server can find them. Then you'll need
558 to specify the resulting URL which can be used to retrieve them from
559 the web server.
560
561 Typical values might be '/tt2/images', '/images/tt2', '/~user/tt2/images'
562 or even something like 'http://www.yourhost.org/images/tt2'.
563
564 (NOTE: If this is too much for you to think about right now, then
565 accept the default below and read the Template::Library::Splash
566 manpage at your leisure to find out more).
567
568 EOF
911a5e3 @abw *** empty log message ***
authored
569 }
c8d76d4 @abw *** empty log message ***
authored
570
9be7d64 @abw approaching 2.04d
authored
571 $TT_IMAGES = ttprompt('URL base for TT2 images?', $TT_IMAGES || $IMAGES);
c8d76d4 @abw *** empty log message ***
authored
572 $TT_IMAGES =~ s[/$][]g; # just in case
d941238 @abw prep 2.4d
authored
573
714a8cd @abw * prep for release 2.07a
authored
574 fix_file(catfile('templates','splash','config'), 'images', "$TT_IMAGES/splash");
c8d76d4 @abw *** empty log message ***
authored
575 }
576
577
578
a4123f8 @abw 2.04b
authored
579 #------------------------------------------------------------------------
580 # html_docs()
581 #
582 # Prompt for HTML documentation build
583 #--------------------------------------------------------------------
584
585 sub html_docs {
586 return unless $TT_PREFIX;
587
c8d76d4 @abw *** empty log message ***
authored
588 my $style = 'plain';
589 my $style_cfg = '';
590
a4123f8 @abw 2.04b
authored
591 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
592
9be7d64 @abw approaching 2.04d
authored
593
594 HTML Documentation
595 ------------------
596
c8d76d4 @abw *** empty log message ***
authored
597 The modules comprising the Template Toolkit contain comprehensive POD
598 documentation which can be browsed using 'perldoc' or 'man' (if your
599 system supports it). In additional, the distribution also includes a
600 set of source templates and style elements for generating the same
601 documentation in HTML format. These will be installed in the
602 directory:
603
a4123f8 @abw 2.04b
authored
604 $TT_PREFIX/docs
c8d76d4 @abw *** empty log message ***
authored
605
606 The HTML documentation can be built for you at "make install" time in
607 a plain and simple HTML format or using the Splash! library. You can
608 see examples of these different styles and browse the documentation
609 online at:
610
611 http://www.template-toolkit.org/docs/
612
613 EOF
614
615 $TT_BUILD_DOCS = (
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
616 ttprompt('Do you want to build the HTML documentation?',
617 $TT_BUILD_DOCS) =~ /^y/i
c8d76d4 @abw *** empty log message ***
authored
618 );
619
a4123f8 @abw 2.04b
authored
620 }
621
622
623 #--------------------------------------------------------------------
624 # html_docstyle()
625 #
626 # prompt for docs style: plain or splash
627 #--------------------------------------------------------------------
628
629 sub html_docstyle {
630 return unless $TT_PREFIX && $TT_BUILD_DOCS;
631
632 my $style = 'plain';
633 my $style_cfg = '';
c8d76d4 @abw *** empty log message ***
authored
634
a4123f8 @abw 2.04b
authored
635 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
636
ca4050f @abw prep for 2.02
authored
637 If you want to build the HTML documentation using the Splash! library
638 then you'll need to make sure you correctly defined the URL for the
639 Splash! images above. Otherwise, answer 'n' to the next question to
640 use plain HTML.
c8d76d4 @abw *** empty log message ***
authored
641
642 EOF
a4123f8 @abw 2.04b
authored
643 $TT_SPLASH_DOCS = (
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
644 ttprompt('Do you want to use the Splash! library?', $TT_SPLASH_DOCS) =~ /^y/i
a4123f8 @abw 2.04b
authored
645 );
c8d76d4 @abw *** empty log message ***
authored
646
a4123f8 @abw 2.04b
authored
647 if ($TT_SPLASH_DOCS) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
648 my $splash_style = '';
649 message(<<EOF);
ca4050f @abw prep for 2.02
authored
650
651 Which Splash! colour scheme would you like to use to build the
652 documentation? Acceptable values are:
653
654 EOF
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
655 unless ($TT_QUIET) {
656 print " Name Colours\n -------------------------\n";
657 foreach my $t ('default',
658 grep { ! /^default$/ } sort keys %$SPLASH_STYLES) {
659 my $v = $SPLASH_STYLES->{ $t };
660 local $" = '/';
661 printf(" %-8s @$v\n", $t);
662 }
663 print "\n";
ca4050f @abw prep for 2.02
authored
664
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
665 while (! $splash_style) {
666 $TT_SPLASH_THEME = ttprompt("Enter name of colour scheme: ",
667 $TT_SPLASH_THEME);
668 message("! No such scheme\n"), $TT_SPLASH_THEME = 'default'
669 unless ($splash_style = $SPLASH_STYLES->{ $TT_SPLASH_THEME });
670 }
46e4eb8 @abw * Added new colour theme called 'leon'
authored
671
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
672 ( $TT_SPLASH_BG, $TT_SPLASH_FG, $TT_SPLASH_BT, $TT_SPLASH_FT )
673 = @$splash_style;
46e4eb8 @abw * Added new colour theme called 'leon'
authored
674
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
675 # default background (unselected) text is black, fore is white
676 $TT_SPLASH_BT ||= 'black';
677 $TT_SPLASH_FT ||= 'white';
ca4050f @abw prep for 2.02
authored
678
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
679 $style = 'splash';
680 $style_cfg = <<EOF;
ca4050f @abw prep for 2.02
authored
681
682 pre_process = splash/config
683 define splash_fg = '$TT_SPLASH_FG'
684 define splash_bg = '$TT_SPLASH_BG'
46e4eb8 @abw * Added new colour theme called 'leon'
authored
685 define splash_ft = '$TT_SPLASH_FT'
686 define splash_bt = '$TT_SPLASH_BT'
ca4050f @abw prep for 2.02
authored
687 EOF
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
688 }
c8d76d4 @abw *** empty log message ***
authored
689 }
690
691 #--------------------------------------------------------------------
692 # write ttree config file for building docs
693 #--------------------------------------------------------------------
694
695 open(FP, "> $TT_DOCS_CFG") || die "$TT_DOCS_CFG: $!\n";
696 print FP <<EOF;
697 # This ttree configuration file is automatically generated by
698 # the Makefile.PL installation script. Feel free to edit it
699 # but be warned that re-installing the Template Toolkit will
700 # overwrite your changes.
a4123f8 @abw 2.04b
authored
701 src = $TT_PREFIX/docs/src
702 dest = $TT_PREFIX/docs/html
703 lib = $TT_PREFIX/docs/style/$style
704 lib = $TT_PREFIX/docs/lib
705 lib = $TT_PREFIX/templates
c8d76d4 @abw *** empty log message ***
authored
706 $style_cfg
707 pre_process = config
708 pre_process = header
709 post_process = footer
911a5e3 @abw *** empty log message ***
authored
710 recurse
711 verbose
c8d76d4 @abw *** empty log message ***
authored
712 EOF
713 close(FP);
a4123f8 @abw 2.04b
authored
714 }
c8d76d4 @abw *** empty log message ***
authored
715
716
a4123f8 @abw 2.04b
authored
717
718
719 #--------------------------------------------------------------------
720 # html_examples()
721 #
722 # Prompt for building examples
723 #--------------------------------------------------------------------
724
725 sub html_examples {
726 return unless $TT_PREFIX;
727
728 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
729
9be7d64 @abw approaching 2.04d
authored
730
731 HTML Examples
732 -------------
733
c8d76d4 @abw *** empty log message ***
authored
734 A number of examples showing use of the HTML, Splash! and PostScript
735 libraries will be installed into:
736
a4123f8 @abw 2.04b
authored
737 $TT_PREFIX/examples
c8d76d4 @abw *** empty log message ***
authored
738
739 As with the documentation, the examples are provided in template form
740 and can be automatically built into HTML pages during the "make
741 install". These pages rely on the Splash! library and expect the
742 images URL to be correctly defined for correct viewing.
743
744 EOF
745
746 $TT_EXAMPLES = (
a4123f8 @abw 2.04b
authored
747 ttprompt('Do you want to build the HTML example pages?',
c8d76d4 @abw *** empty log message ***
authored
748 $TT_EXAMPLES) =~ /^y/i
749 );
750
751 #--------------------------------------------------------------------
752 # write ttree config file for building examples
753 #--------------------------------------------------------------------
754
755 open(FP, "> $TT_EXAMPLE_CFG") || die "$TT_EXAMPLE_CFG: $!\n";
756 print FP <<EOF;
757 # This ttree configuration file is automatically generated by
758 # the Makefile.PL installation script. Feel free to edit it
759 # but be warned that re-installing the Template Toolkit will
760 # overwrite your changes.
761
a4123f8 @abw 2.04b
authored
762 src = $TT_PREFIX/examples/src
763 dest = $TT_PREFIX/examples/html
764 lib = $TT_PREFIX/examples/lib
765 lib = $TT_PREFIX/templates
ca4050f @abw prep for 2.02
authored
766 define splash_fg = '$TT_SPLASH_FG'
767 define splash_bg = '$TT_SPLASH_BG'
c8d76d4 @abw *** empty log message ***
authored
768 pre_process = config
911a5e3 @abw *** empty log message ***
authored
769 recurse
770 verbose
c8d76d4 @abw *** empty log message ***
authored
771 EOF
772
773 close(FP);
774 }
a4123f8 @abw 2.04b
authored
775
776
777 #--------------------------------------------------------------------
778 # write_defaults()
779 #
780 # write configuration defaults to file
781 #--------------------------------------------------------------------
782
783 sub write_defaults {
ca4050f @abw prep for 2.02
authored
784 open(FP, "> $DEFAULTS_FILE") || die "$DEFAULTS_FILE: $!\n";
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
785 my ( $ttdocs, $ttsplash, $ttexamples,
786 $ttextras, $ttxs_enable, $ttxs_default )
9be7d64 @abw approaching 2.04d
authored
787 = map { $_ ? 'y' : 'n' }
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
788 ( $TT_BUILD_DOCS, $TT_SPLASH_DOCS, $TT_EXAMPLES,
789 $TT_EXTRAS, $TT_XS_ENABLE, $TT_XS_DEFAULT );
ca4050f @abw prep for 2.02
authored
790 print FP <<EOF;
a4123f8 @abw 2.04b
authored
791 \$TT_PREFIX = '$TT_PREFIX';
f4df3b6 @abw approach v2.03
authored
792 \$TT_IMAGES = '$TT_IMAGES';
793 \$TT_BUILD_DOCS = '$ttdocs';
794 \$TT_SPLASH_DOCS = '$ttsplash';
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
795 \$TT_EXAMPLES = '$ttexamples';
796 \$TT_EXTRAS = '$ttextras';
f4df3b6 @abw approach v2.03
authored
797 \$TT_SPLASH_THEME = '$TT_SPLASH_THEME';
9be7d64 @abw approaching 2.04d
authored
798 \$TT_XS_ENABLE = '$ttxs_enable';
799 \$TT_XS_DEFAULT = '$ttxs_default';
a4123f8 @abw 2.04b
authored
800 \$TT_ACCEPT = '$TT_ACCEPT';
801 \$TT_QUIET = '$TT_QUIET';
9acc796 @abw post 2.03a
authored
802 1;
ca4050f @abw prep for 2.02
authored
803 EOF
804 close(FP);
c8d76d4 @abw *** empty log message ***
authored
805 }
806
48634a1 @abw *** empty log message ***
authored
807
808 #------------------------------------------------------------------------
809 # build_docs()
810 #
811 # Echo the relevant incantation so that 'make dist' regenerates the
812 # documentation from the template sources.
25a8d8e @abw *** empty log message ***
authored
813 #------------------------------------------------------------------------
eabb19e @abw *** empty log message ***
authored
814
3ebfa07 @abw Initial revision
authored
815 sub build_docs {
816 return <<EOF;
817 echo "Building documentation for version \$(VERSION)" ; \\
28cc36e @abw prep for 2.06d
authored
818 \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) bin/ttree -f ./docs/ttdist.cfg --define version=\$(VERSION) -a; \\
3ebfa07 @abw Initial revision
authored
819 EOF
820 }
821
48634a1 @abw *** empty log message ***
authored
822
82cbea8 @abw version 2.00
authored
823
824 #------------------------------------------------------------------------
c8d76d4 @abw *** empty log message ***
authored
825 # fix_file($file, $find, $fix)
826 #
827 # Fixes a variable definition in a file. e.g.
d941238 @abw prep 2.4d
authored
828 # fix_file('templates/splash/config', 'images', '/tt2/splash')
c8d76d4 @abw *** empty log message ***
authored
829 #------------------------------------------------------------------------
830
831 sub fix_file {
832 my ($file, $find, $fix) = @_;
833 local *FP;
834 local $/ = undef;
835
836 $find = quotemeta($find);
837
838 open(FP, "< $file") || die "$file: $!\n";
839 my $text = <FP>;
840 close(FP);
841
842 ($text =~ s/^(\s*${find}\s*=\s*)'.*?'/$1'$fix'/m)
843 || die "$find not found in $file\n";
844
845 open(FP, "> $file") || die "$file: $!\n";
846 print FP $text;
847 close(FP);
848 }
849
a4123f8 @abw 2.04b
authored
850
851 #------------------------------------------------------------------------
9be7d64 @abw approaching 2.04d
authored
852 # find_program($path, $prog)
f4df3b6 @abw approach v2.03
authored
853 #
854 # Find a program, $prog, by traversing the given directory path, $path.
855 # Returns full path if the program is found.
856 #
857 # Written by Craig Barratt, Richard Tietjen add fixes for Win32.
9be7d64 @abw approaching 2.04d
authored
858 #
859 # abw changed name from studly caps findProgram() to find_program() :-)
a4123f8 @abw 2.04b
authored
860 #------------------------------------------------------------------------
861
9be7d64 @abw approaching 2.04d
authored
862 sub find_program {
f4df3b6 @abw approach v2.03
authored
863 my($path, $prog) = @_;
714a8cd @abw * prep for release 2.07a
authored
864 # my $sep = $WIN32 ? qr/;/ : qr/:/;
865 # foreach my $dir ( split($sep, $path) ) {
866 foreach my $dir ( split($Config{path_sep}, $path) ) {
f4df3b6 @abw approach v2.03
authored
867 my $file = File::Spec->catfile($dir, $prog);
868 if ( !$WIN32 ) {
869 return $file if ( -x $file );
870 } else {
871 # Windows executables end in .xxx, exe precedes .bat and .cmd
872 foreach my $dx ( qw/exe bat cmd/ ) {
873 return "$file.$dx" if ( -x "$file.$dx" );
874 }
875 }
876 }
877 }
a4123f8 @abw 2.04b
authored
878
879
880 #------------------------------------------------------------------------
881 # message($text)
882 #
883 # Print message unless quiet mode.
884 #------------------------------------------------------------------------
885
886 sub message {
887 return if $TT_QUIET;
888 print @_;
889 }
890
891
892 #------------------------------------------------------------------------
893 # ttprompt($message, $default)
894 #------------------------------------------------------------------------
895
896 sub ttprompt {
897 my ($msg, $def)=@_;
898 my $ISA_TTY = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
899 my $dispdef = defined $def ? "[$def] " : " ";
900 $def = defined $def ? $def : "";
901 my $ans = '';
902 local $|=1;
903 print "$msg $dispdef" unless $TT_QUIET;
904 if ($TT_ACCEPT || ! $ISA_TTY) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
905 print "$def\n" unless $TT_QUIET;
a4123f8 @abw 2.04b
authored
906 }
907 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
908 chomp($ans = <STDIN>);
a4123f8 @abw 2.04b
authored
909 }
910 return ($ans ne '') ? $ans : $def;
911 }
912
913
914 #------------------------------------------------------------------------
915 # yep($text)
916 #------------------------------------------------------------------------
917
918 sub yep {
919 return if $TT_QUIET;
920 print '[X] ', shift, "\n";
921 }
922
923
924 #------------------------------------------------------------------------
925 # nope($text)
926 #------------------------------------------------------------------------
927 sub nope {
928 return if $TT_QUIET;
929 print '[ ] ', shift, "\n";
930 }
Something went wrong with that request. Please try again.