Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 919 lines (705 sloc) 26.561 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
d56b9a8 @abw commit for 2.14a
authored
158 my $TT_APPCONFIG_VERSION = '1.56';
8d30d52 @abw * applied patch from Axel to use variables for dependent module version ...
authored
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
d56b9a8 @abw commit for 2.14a
authored
419 Note that as of version 2.15 the XS Stash now supports access to tied
420 hashes and arrays.
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
421
422 See 'perldoc Template::Config' for further details.
9be7d64 @abw approaching 2.04d
authored
423
424 EOF
425
426 $TT_XS_ENABLE = (ttprompt('Do you want to build the XS Stash module?',
427 $TT_XS_ENABLE) =~ /^y/i);
428
429 if ($TT_XS_ENABLE) {
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
430 $TT_XS_DEFAULT =
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
431 (ttprompt('Do you want to use the XS Stash by default?',
432 $TT_XS_DEFAULT) =~ /^y/i);
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
433 }
434 else {
435 # If the XS stash is disabled, we cannot use it as the default stash.
436 $TT_XS_DEFAULT = 0;
437 }
9be7d64 @abw approaching 2.04d
authored
438
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
439 # Actually, we would have to fix 'Config.pm' only if the XS stash is
440 # disabled. But this way, we are sure the correct module is used.
714a8cd @abw * prep for release 2.07a
authored
441 fix_file(catfile('lib','Template','Config.pm'),
d941238 @abw prep 2.4d
authored
442 '$STASH',
443 $TT_XS_DEFAULT ? 'Template::Stash::XS' : 'Template::Stash');
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
444 }
f4df3b6 @abw approach v2.03
authored
445
446
447
a4123f8 @abw 2.04b
authored
448
f4df3b6 @abw approach v2.03
authored
449 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
450 # optional_extras()
451 #
452 # Prompt for installation of optional libraries and other components
c8d76d4 @abw *** empty log message ***
authored
453 #------------------------------------------------------------------------
454
a4123f8 @abw 2.04b
authored
455 sub optional_extras {
456 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
457
9be7d64 @abw approaching 2.04d
authored
458
459 Optional Extras
460 ---------------
461
c8d76d4 @abw *** empty log message ***
authored
462 In additional to the Perl modules and POD documentation installed in
463 the usual way, the Template Toolkit distribution also contains a
464 number of optional components:
465
466 * Template libaries for basic HTML, Pod -> HTML, and PostScript
467
468 * Splash! - a stylish HTML user interface template library / widget set
469
470 * HTML documentation - distributed in template form for customisation
471
472 * Stylesheet templates to generate docs as vanilla HTML or using Splash!
473
474 * Examples - numerous examples of using the template libraries
475
476 If you want to install these optional components then you'll need to
477 specify a separate directory for them.
478
479 EOF
480
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
481 if ($TT_EXTRAS = (
482 ttprompt('Do you want to install these components?',
483 $TT_EXTRAS) =~ /^y/i)) {
a4123f8 @abw 2.04b
authored
484 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
485
486 You can chose any directory for the installation of the additional
911a5e3 @abw *** empty log message ***
authored
487 Template Toolkit components. The proposed default assumes a $FLAVOUR
488 flavour to your operating system (suggestions for suitable defaults
489 for other platforms welcome).
c8d76d4 @abw *** empty log message ***
authored
490
491 EOF
9be7d64 @abw approaching 2.04d
authored
492 $TT_PREFIX = ttprompt('Installation directory', $TT_PREFIX || $PREFIX);
73afe6d @abw * Applied Axel's patch to remove trailing '/' from installation dir.
authored
493 $TT_PREFIX =~ s[/$][];
a4123f8 @abw 2.04b
authored
494 }
495 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
496 $TT_PREFIX = '';
a4123f8 @abw 2.04b
authored
497 }
498
714a8cd @abw * prep for release 2.07a
authored
499 fix_file(catfile('lib','Template','Config.pm'), '$INSTDIR', $TT_PREFIX);
c8d76d4 @abw *** empty log message ***
authored
500 }
501
502
503
504 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
505 # splash_images()
506 #
507 # Prompt for Splash! image URL
c8d76d4 @abw *** empty log message ***
authored
508 #------------------------------------------------------------------------
509
a4123f8 @abw 2.04b
authored
510 sub splash_images {
511 return unless $TT_PREFIX;
911a5e3 @abw *** empty log message ***
authored
512
a4123f8 @abw 2.04b
authored
513 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
514
9be7d64 @abw approaching 2.04d
authored
515
516 Splash!
517 -------
518
c8d76d4 @abw *** empty log message ***
authored
519 The Splash! template library uses a number of (very) small images to
520 build user interface components. These will be installed into the
521 directory:
522
a4123f8 @abw 2.04b
authored
523 $TT_PREFIX/images
911a5e3 @abw *** empty log message ***
authored
524 EOF
525
526 if ($WIN32) {
527 # default images value for Win32 to browse via file system
a4123f8 @abw 2.04b
authored
528 $TT_IMAGES = "$TT_PREFIX/images";
529
530 message(<<EOF);
531
911a5e3 @abw *** empty log message ***
authored
532 If you want to use the Splash! library then you'll need to make sure
533 you can access these images via your browser. If you want to deliver
534 pages via a web server then you'll need to specify the URL that can be
535 use to access these images. In the general case you can accept the
536 default and access the images via the filesystem.
537
538 EOF
539 }
540 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
541 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
542
543 If you want to use the Splash! library then you'll need to copy these
544 images, define an alias (e.g. in the httpd.conf) or create a symbolic
545 link to them so that your web server can find them. Then you'll need
546 to specify the resulting URL which can be used to retrieve them from
547 the web server.
548
549 Typical values might be '/tt2/images', '/images/tt2', '/~user/tt2/images'
550 or even something like 'http://www.yourhost.org/images/tt2'.
551
552 (NOTE: If this is too much for you to think about right now, then
553 accept the default below and read the Template::Library::Splash
554 manpage at your leisure to find out more).
555
556 EOF
911a5e3 @abw *** empty log message ***
authored
557 }
c8d76d4 @abw *** empty log message ***
authored
558
9be7d64 @abw approaching 2.04d
authored
559 $TT_IMAGES = ttprompt('URL base for TT2 images?', $TT_IMAGES || $IMAGES);
c8d76d4 @abw *** empty log message ***
authored
560 $TT_IMAGES =~ s[/$][]g; # just in case
d941238 @abw prep 2.4d
authored
561
714a8cd @abw * prep for release 2.07a
authored
562 fix_file(catfile('templates','splash','config'), 'images', "$TT_IMAGES/splash");
c8d76d4 @abw *** empty log message ***
authored
563 }
564
565
566
a4123f8 @abw 2.04b
authored
567 #------------------------------------------------------------------------
568 # html_docs()
569 #
570 # Prompt for HTML documentation build
571 #--------------------------------------------------------------------
572
573 sub html_docs {
574 return unless $TT_PREFIX;
575
c8d76d4 @abw *** empty log message ***
authored
576 my $style = 'plain';
577 my $style_cfg = '';
578
a4123f8 @abw 2.04b
authored
579 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
580
9be7d64 @abw approaching 2.04d
authored
581
582 HTML Documentation
583 ------------------
584
c8d76d4 @abw *** empty log message ***
authored
585 The modules comprising the Template Toolkit contain comprehensive POD
586 documentation which can be browsed using 'perldoc' or 'man' (if your
587 system supports it). In additional, the distribution also includes a
588 set of source templates and style elements for generating the same
589 documentation in HTML format. These will be installed in the
590 directory:
591
a4123f8 @abw 2.04b
authored
592 $TT_PREFIX/docs
c8d76d4 @abw *** empty log message ***
authored
593
594 The HTML documentation can be built for you at "make install" time in
595 a plain and simple HTML format or using the Splash! library. You can
596 see examples of these different styles and browse the documentation
597 online at:
598
599 http://www.template-toolkit.org/docs/
600
601 EOF
602
603 $TT_BUILD_DOCS = (
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
604 ttprompt('Do you want to build the HTML documentation?',
605 $TT_BUILD_DOCS) =~ /^y/i
c8d76d4 @abw *** empty log message ***
authored
606 );
607
a4123f8 @abw 2.04b
authored
608 }
609
610
611 #--------------------------------------------------------------------
612 # html_docstyle()
613 #
614 # prompt for docs style: plain or splash
615 #--------------------------------------------------------------------
616
617 sub html_docstyle {
618 return unless $TT_PREFIX && $TT_BUILD_DOCS;
619
620 my $style = 'plain';
621 my $style_cfg = '';
c8d76d4 @abw *** empty log message ***
authored
622
a4123f8 @abw 2.04b
authored
623 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
624
ca4050f @abw prep for 2.02
authored
625 If you want to build the HTML documentation using the Splash! library
626 then you'll need to make sure you correctly defined the URL for the
627 Splash! images above. Otherwise, answer 'n' to the next question to
628 use plain HTML.
c8d76d4 @abw *** empty log message ***
authored
629
630 EOF
a4123f8 @abw 2.04b
authored
631 $TT_SPLASH_DOCS = (
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
632 ttprompt('Do you want to use the Splash! library?', $TT_SPLASH_DOCS) =~ /^y/i
a4123f8 @abw 2.04b
authored
633 );
c8d76d4 @abw *** empty log message ***
authored
634
a4123f8 @abw 2.04b
authored
635 if ($TT_SPLASH_DOCS) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
636 my $splash_style = '';
637 message(<<EOF);
ca4050f @abw prep for 2.02
authored
638
639 Which Splash! colour scheme would you like to use to build the
640 documentation? Acceptable values are:
641
642 EOF
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
643 unless ($TT_QUIET) {
644 print " Name Colours\n -------------------------\n";
645 foreach my $t ('default',
646 grep { ! /^default$/ } sort keys %$SPLASH_STYLES) {
647 my $v = $SPLASH_STYLES->{ $t };
648 local $" = '/';
649 printf(" %-8s @$v\n", $t);
650 }
651 print "\n";
ca4050f @abw prep for 2.02
authored
652
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
653 while (! $splash_style) {
654 $TT_SPLASH_THEME = ttprompt("Enter name of colour scheme: ",
655 $TT_SPLASH_THEME);
656 message("! No such scheme\n"), $TT_SPLASH_THEME = 'default'
657 unless ($splash_style = $SPLASH_STYLES->{ $TT_SPLASH_THEME });
658 }
46e4eb8 @abw * Added new colour theme called 'leon'
authored
659
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
660 ( $TT_SPLASH_BG, $TT_SPLASH_FG, $TT_SPLASH_BT, $TT_SPLASH_FT )
661 = @$splash_style;
46e4eb8 @abw * Added new colour theme called 'leon'
authored
662
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
663 # default background (unselected) text is black, fore is white
664 $TT_SPLASH_BT ||= 'black';
665 $TT_SPLASH_FT ||= 'white';
ca4050f @abw prep for 2.02
authored
666
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
667 $style = 'splash';
668 $style_cfg = <<EOF;
ca4050f @abw prep for 2.02
authored
669
670 pre_process = splash/config
671 define splash_fg = '$TT_SPLASH_FG'
672 define splash_bg = '$TT_SPLASH_BG'
46e4eb8 @abw * Added new colour theme called 'leon'
authored
673 define splash_ft = '$TT_SPLASH_FT'
674 define splash_bt = '$TT_SPLASH_BT'
ca4050f @abw prep for 2.02
authored
675 EOF
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
676 }
c8d76d4 @abw *** empty log message ***
authored
677 }
678
679 #--------------------------------------------------------------------
680 # write ttree config file for building docs
681 #--------------------------------------------------------------------
682
683 open(FP, "> $TT_DOCS_CFG") || die "$TT_DOCS_CFG: $!\n";
684 print FP <<EOF;
685 # This ttree configuration file is automatically generated by
686 # the Makefile.PL installation script. Feel free to edit it
687 # but be warned that re-installing the Template Toolkit will
688 # overwrite your changes.
a4123f8 @abw 2.04b
authored
689 src = $TT_PREFIX/docs/src
690 dest = $TT_PREFIX/docs/html
691 lib = $TT_PREFIX/docs/style/$style
692 lib = $TT_PREFIX/docs/lib
693 lib = $TT_PREFIX/templates
c8d76d4 @abw *** empty log message ***
authored
694 $style_cfg
695 pre_process = config
696 pre_process = header
697 post_process = footer
911a5e3 @abw *** empty log message ***
authored
698 recurse
699 verbose
c8d76d4 @abw *** empty log message ***
authored
700 EOF
701 close(FP);
a4123f8 @abw 2.04b
authored
702 }
c8d76d4 @abw *** empty log message ***
authored
703
704
a4123f8 @abw 2.04b
authored
705
706
707 #--------------------------------------------------------------------
708 # html_examples()
709 #
710 # Prompt for building examples
711 #--------------------------------------------------------------------
712
713 sub html_examples {
714 return unless $TT_PREFIX;
715
716 message(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
717
9be7d64 @abw approaching 2.04d
authored
718
719 HTML Examples
720 -------------
721
c8d76d4 @abw *** empty log message ***
authored
722 A number of examples showing use of the HTML, Splash! and PostScript
723 libraries will be installed into:
724
a4123f8 @abw 2.04b
authored
725 $TT_PREFIX/examples
c8d76d4 @abw *** empty log message ***
authored
726
727 As with the documentation, the examples are provided in template form
728 and can be automatically built into HTML pages during the "make
729 install". These pages rely on the Splash! library and expect the
730 images URL to be correctly defined for correct viewing.
731
732 EOF
733
734 $TT_EXAMPLES = (
a4123f8 @abw 2.04b
authored
735 ttprompt('Do you want to build the HTML example pages?',
c8d76d4 @abw *** empty log message ***
authored
736 $TT_EXAMPLES) =~ /^y/i
737 );
738
739 #--------------------------------------------------------------------
740 # write ttree config file for building examples
741 #--------------------------------------------------------------------
742
743 open(FP, "> $TT_EXAMPLE_CFG") || die "$TT_EXAMPLE_CFG: $!\n";
744 print FP <<EOF;
745 # This ttree configuration file is automatically generated by
746 # the Makefile.PL installation script. Feel free to edit it
747 # but be warned that re-installing the Template Toolkit will
748 # overwrite your changes.
749
a4123f8 @abw 2.04b
authored
750 src = $TT_PREFIX/examples/src
751 dest = $TT_PREFIX/examples/html
752 lib = $TT_PREFIX/examples/lib
753 lib = $TT_PREFIX/templates
ca4050f @abw prep for 2.02
authored
754 define splash_fg = '$TT_SPLASH_FG'
755 define splash_bg = '$TT_SPLASH_BG'
c8d76d4 @abw *** empty log message ***
authored
756 pre_process = config
911a5e3 @abw *** empty log message ***
authored
757 recurse
758 verbose
c8d76d4 @abw *** empty log message ***
authored
759 EOF
760
761 close(FP);
762 }
a4123f8 @abw 2.04b
authored
763
764
765 #--------------------------------------------------------------------
766 # write_defaults()
767 #
768 # write configuration defaults to file
769 #--------------------------------------------------------------------
770
771 sub write_defaults {
ca4050f @abw prep for 2.02
authored
772 open(FP, "> $DEFAULTS_FILE") || die "$DEFAULTS_FILE: $!\n";
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
773 my ( $ttdocs, $ttsplash, $ttexamples,
774 $ttextras, $ttxs_enable, $ttxs_default )
9be7d64 @abw approaching 2.04d
authored
775 = map { $_ ? 'y' : 'n' }
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
776 ( $TT_BUILD_DOCS, $TT_SPLASH_DOCS, $TT_EXAMPLES,
777 $TT_EXTRAS, $TT_XS_ENABLE, $TT_XS_DEFAULT );
ca4050f @abw prep for 2.02
authored
778 print FP <<EOF;
a4123f8 @abw 2.04b
authored
779 \$TT_PREFIX = '$TT_PREFIX';
f4df3b6 @abw approach v2.03
authored
780 \$TT_IMAGES = '$TT_IMAGES';
781 \$TT_BUILD_DOCS = '$ttdocs';
782 \$TT_SPLASH_DOCS = '$ttsplash';
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
783 \$TT_EXAMPLES = '$ttexamples';
784 \$TT_EXTRAS = '$ttextras';
f4df3b6 @abw approach v2.03
authored
785 \$TT_SPLASH_THEME = '$TT_SPLASH_THEME';
9be7d64 @abw approaching 2.04d
authored
786 \$TT_XS_ENABLE = '$ttxs_enable';
787 \$TT_XS_DEFAULT = '$ttxs_default';
a4123f8 @abw 2.04b
authored
788 \$TT_ACCEPT = '$TT_ACCEPT';
789 \$TT_QUIET = '$TT_QUIET';
9acc796 @abw post 2.03a
authored
790 1;
ca4050f @abw prep for 2.02
authored
791 EOF
792 close(FP);
c8d76d4 @abw *** empty log message ***
authored
793 }
794
48634a1 @abw *** empty log message ***
authored
795
796 #------------------------------------------------------------------------
797 # build_docs()
798 #
799 # Echo the relevant incantation so that 'make dist' regenerates the
800 # documentation from the template sources.
25a8d8e @abw *** empty log message ***
authored
801 #------------------------------------------------------------------------
eabb19e @abw *** empty log message ***
authored
802
3ebfa07 @abw Initial revision
authored
803 sub build_docs {
804 return <<EOF;
805 echo "Building documentation for version \$(VERSION)" ; \\
28cc36e @abw prep for 2.06d
authored
806 \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) bin/ttree -f ./docs/ttdist.cfg --define version=\$(VERSION) -a; \\
3ebfa07 @abw Initial revision
authored
807 EOF
808 }
809
48634a1 @abw *** empty log message ***
authored
810
82cbea8 @abw version 2.00
authored
811
812 #------------------------------------------------------------------------
c8d76d4 @abw *** empty log message ***
authored
813 # fix_file($file, $find, $fix)
814 #
815 # Fixes a variable definition in a file. e.g.
d941238 @abw prep 2.4d
authored
816 # fix_file('templates/splash/config', 'images', '/tt2/splash')
c8d76d4 @abw *** empty log message ***
authored
817 #------------------------------------------------------------------------
818
819 sub fix_file {
820 my ($file, $find, $fix) = @_;
821 local *FP;
822 local $/ = undef;
823
824 $find = quotemeta($find);
825
826 open(FP, "< $file") || die "$file: $!\n";
827 my $text = <FP>;
828 close(FP);
829
830 ($text =~ s/^(\s*${find}\s*=\s*)'.*?'/$1'$fix'/m)
831 || die "$find not found in $file\n";
832
833 open(FP, "> $file") || die "$file: $!\n";
834 print FP $text;
835 close(FP);
836 }
837
a4123f8 @abw 2.04b
authored
838
839 #------------------------------------------------------------------------
9be7d64 @abw approaching 2.04d
authored
840 # find_program($path, $prog)
f4df3b6 @abw approach v2.03
authored
841 #
842 # Find a program, $prog, by traversing the given directory path, $path.
843 # Returns full path if the program is found.
844 #
845 # Written by Craig Barratt, Richard Tietjen add fixes for Win32.
9be7d64 @abw approaching 2.04d
authored
846 #
847 # abw changed name from studly caps findProgram() to find_program() :-)
a4123f8 @abw 2.04b
authored
848 #------------------------------------------------------------------------
849
9be7d64 @abw approaching 2.04d
authored
850 sub find_program {
f4df3b6 @abw approach v2.03
authored
851 my($path, $prog) = @_;
714a8cd @abw * prep for release 2.07a
authored
852 # my $sep = $WIN32 ? qr/;/ : qr/:/;
853 # foreach my $dir ( split($sep, $path) ) {
854 foreach my $dir ( split($Config{path_sep}, $path) ) {
f4df3b6 @abw approach v2.03
authored
855 my $file = File::Spec->catfile($dir, $prog);
856 if ( !$WIN32 ) {
857 return $file if ( -x $file );
858 } else {
859 # Windows executables end in .xxx, exe precedes .bat and .cmd
860 foreach my $dx ( qw/exe bat cmd/ ) {
861 return "$file.$dx" if ( -x "$file.$dx" );
862 }
863 }
864 }
865 }
a4123f8 @abw 2.04b
authored
866
867
868 #------------------------------------------------------------------------
869 # message($text)
870 #
871 # Print message unless quiet mode.
872 #------------------------------------------------------------------------
873
874 sub message {
875 return if $TT_QUIET;
876 print @_;
877 }
878
879
880 #------------------------------------------------------------------------
881 # ttprompt($message, $default)
882 #------------------------------------------------------------------------
883
884 sub ttprompt {
885 my ($msg, $def)=@_;
886 my $ISA_TTY = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
887 my $dispdef = defined $def ? "[$def] " : " ";
888 $def = defined $def ? $def : "";
889 my $ans = '';
890 local $|=1;
891 print "$msg $dispdef" unless $TT_QUIET;
892 if ($TT_ACCEPT || ! $ISA_TTY) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
893 print "$def\n" unless $TT_QUIET;
a4123f8 @abw 2.04b
authored
894 }
895 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
896 chomp($ans = <STDIN>);
a4123f8 @abw 2.04b
authored
897 }
898 return ($ans ne '') ? $ans : $def;
899 }
900
901
902 #------------------------------------------------------------------------
903 # yep($text)
904 #------------------------------------------------------------------------
905
906 sub yep {
907 return if $TT_QUIET;
908 print '[X] ', shift, "\n";
909 }
910
911
912 #------------------------------------------------------------------------
913 # nope($text)
914 #------------------------------------------------------------------------
915 sub nope {
916 return if $TT_QUIET;
917 print '[ ] ', shift, "\n";
918 }
Something went wrong with that request. Please try again.