Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 488 lines (374 sloc) 13.773 kB
a4123f8 @abw 2.04b
authored
1 #!/usr/bin/perl -w # -*- perl -*-
2
3 use strict;
c942c1b @abw Version 2.15
authored
4 use warnings;
a4123f8 @abw 2.04b
authored
5
2d0a850 @abw Added "use 5.006" constraint in Makefile.PL
authored
6 use 5.006;
a4123f8 @abw 2.04b
authored
7 use lib qw( ./lib );
714a8cd @abw * prep for release 2.07a
authored
8 use Config;
9 use File::Spec::Functions qw( catfile );
a4123f8 @abw 2.04b
authored
10 use Template;
11 use ExtUtils::MakeMaker;
c8d76d4 @abw *** empty log message ***
authored
12 use Cwd;
3ebfa07 @abw Initial revision
authored
13
e39913f @abw *** empty log message ***
authored
14 select STDERR;
15 $| = 1;
16 select STDOUT;
17
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
18 use vars qw( $TT_VERSION $TT_PREFIX
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
19 $TT_XS_ENABLE $TT_XS_DEFAULT
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
20 $TT_QUIET $TT_ACCEPT $TT_YES );
a4123f8 @abw 2.04b
authored
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';
8b5c5f7 @abw Couple more fixes/unfixes for Makefile.PL
authored
28 $PREFIX = 'C:/Program Files/Template Toolkit 2';
29 $IMAGES = '/tt2/images';
a4123f8 @abw 2.04b
authored
30 }
31 else {
32 $WIN32 = 0;
33 $FLAVOUR = 'Unix';
8b5c5f7 @abw Couple more fixes/unfixes for Makefile.PL
authored
34 $PREFIX = '/usr/local/tt2';
35 $IMAGES = '/tt2/images';
a4123f8 @abw 2.04b
authored
36 }
86cfaef @abw Updated Changes, TODO, Makefile.PL, MANIFEST and MANIFEST.SKIP
authored
37 $MAKE=$Config{'make'};
a4123f8 @abw 2.04b
authored
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
8b5c5f7 @abw Couple more fixes/unfixes for Makefile.PL
authored
63 perl Makefile.PL TT_XS_DEFAULT=y TT_ACCEPT=y
9be7d64 @abw approaching 2.04d
authored
64
65 TT_XS_ENABLE Enable XS Stash (y)
66 TT_XS_DEFAULT Use XS Stash by default (y)
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
67 TT_QUIET no messages (n)
9be7d64 @abw approaching 2.04d
authored
68 TT_ACCEPT accept defaults (n)
a4123f8 @abw 2.04b
authored
69
70 By default, the Makefile.PL runs in interactive mode,
71 prompting for confirmation of the various configuration
72 options. Setting the TT_ACCEPT option causes the default
73 value (possibly modified by other command line options)
74 to be accepted. The TT_QUIET option can also be set to
75 suppress the prompt messages.
76
77 EOF
78 exit(0);
79 }
ca4050f @abw prep for 2.02
authored
80
9be7d64 @abw approaching 2.04d
authored
81 # these global package variables are the main flags used
82 # in this script, here defaulted to sensible values
83
a4123f8 @abw 2.04b
authored
84 $TT_VERSION = $Template::VERSION;
9be7d64 @abw approaching 2.04d
authored
85 $TT_XS_ENABLE = 'y';
86 $TT_XS_DEFAULT = 'y';
a4123f8 @abw 2.04b
authored
87 $TT_QUIET = 'n';
88 $TT_ACCEPT = 'n';
f4df3b6 @abw approach v2.03
authored
89
ca4050f @abw prep for 2.02
authored
90 my $DEFAULTS_FILE = '.defaults.cfg';
91 my $DEFAULTS = '';
911a5e3 @abw *** empty log message ***
authored
92
ca4050f @abw prep for 2.02
authored
93 if (-f $DEFAULTS_FILE) {
94 require $DEFAULTS_FILE;
95 $DEFAULTS = " read from '$DEFAULTS_FILE'";
96 }
97
9be7d64 @abw approaching 2.04d
authored
98 $TT_XS_ENABLE = $ttconfig{ TT_XS_ENABLE } if defined $ttconfig{ TT_XS_ENABLE };
99 $TT_XS_DEFAULT = $ttconfig{ TT_XS_DEFAULT } if defined $ttconfig{ TT_XS_DEFAULT };
100 $TT_QUIET = $ttconfig{ TT_QUIET } if defined $ttconfig{ TT_QUIET };
101
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
102 if (defined $ttconfig{ TT_ACCEPT }) {
103 $TT_ACCEPT = $ttconfig{ TT_ACCEPT };
104 }
105 else {
106 # standard behaviour for MakeMaker to indicate accept all defaults
107 $TT_ACCEPT = $ENV{PERL_MM_USE_DEFAULT} ? 'y' : 'n';
108 }
109
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
110 foreach ($TT_XS_ENABLE, $TT_XS_DEFAULT ) {
a4123f8 @abw 2.04b
authored
111 $_ = 'n' if ! $_;
112 }
113 $TT_ACCEPT = 0 if $TT_ACCEPT eq 'n';
114 $TT_QUIET = 0 if $TT_QUIET eq 'n';
115 $TT_QUIET = 0 unless $TT_ACCEPT;
116
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
117 # define version numbers of required modules
d56b9a8 @abw commit for 2.14a
authored
118 my $TT_APPCONFIG_VERSION = '1.56';
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
119 my $TT_FILE_SPEC_VERSION = '0.8';
120 my $TT_FILE_TEMP_VERSION = '0.12';
121
122
a4123f8 @abw 2.04b
authored
123 #========================================================================
124
125 welcome_message();
126 version_check();
28cc36e @abw prep for 2.06d
authored
127 mandatory_modules();
9be7d64 @abw approaching 2.04d
authored
128 optional_stash_xs();
a4123f8 @abw 2.04b
authored
129 write_defaults();
130
131 print "\n";
132
133
134 #------------------------------------------------------------------------
135 # build options and write Makefile
136 #------------------------------------------------------------------------
137
138 package main;
139
140 my %opts = (
141 %config,
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
142 'NAME' => 'Template',
a4123f8 @abw 2.04b
authored
143 'DISTNAME' => 'Template-Toolkit',
144 'VERSION_FROM' => 'lib/Template.pm',
145 'EXE_FILES' => [ 'bin/tpage', 'bin/ttree' ],
146 'PMLIBDIRS' => [ 'lib' ],
9be7d64 @abw approaching 2.04d
authored
147 'DIR' => [ ],
c7d3d41 @abw * removed mandatory modules check from Makefile.PL to keep CPAN module
authored
148 'PREREQ_PM' => {
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
149 'AppConfig' => $TT_APPCONFIG_VERSION,
150 'File::Spec' => $TT_FILE_SPEC_VERSION,
151 'File::Temp' => $TT_FILE_TEMP_VERSION,
c7d3d41 @abw * removed mandatory modules check from Makefile.PL to keep CPAN module
authored
152 },
a4123f8 @abw 2.04b
authored
153 'dist' => {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
154 'COMPRESS' => 'gzip',
155 'SUFFIX' => 'gz',
a4123f8 @abw 2.04b
authored
156 },
50fc1a2 @abw * changed TESTS to reflect the fact that vmethod tests have moved int…
authored
157 'test' => {
86cfaef @abw Updated Changes, TODO, Makefile.PL, MANIFEST and MANIFEST.SKIP
authored
158 'TESTS' => join(' ', map { glob } qw( t/*.t t/vmethods/*.t )),
50fc1a2 @abw * changed TESTS to reflect the fact that vmethod tests have moved int…
authored
159 },
28cc36e @abw prep for 2.06d
authored
160 'clean' => {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
161 'FILES' => join(' ', qw( docs/ttree.cfg
162 examples/ttree.cfg
163 t/dbi_test.cfg
164 t/test/src/baz.ttc
165 t/test/src/complex.org
166 t/test/src/complex.ttc
167 t/test/src/evalperl.ttc
168 t/test/src/foo.ttc )),
28cc36e @abw prep for 2.06d
authored
169 },
a4123f8 @abw 2.04b
authored
170 );
171
9be7d64 @abw approaching 2.04d
authored
172 push @{ $opts{'DIR'} }, 'xs' if $TT_XS_ENABLE;
173
7cd902d @abw applied Adam Kennedy's patches from v2.16 and v2.17
authored
174 # Handle dev versions in our check
175 my $mmv = $ExtUtils::MakeMaker::VERSION;
176 $mmv =~ s/\_.+//;
177
178 if ($mmv >= 5.43) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
179 $opts{ AUTHOR } = 'Andy Wardley <abw@wardley.org>';
180 $opts{ ABSTRACT } = 'comprehensive template processing system',
a4123f8 @abw 2.04b
authored
181 }
182
86cfaef @abw Updated Changes, TODO, Makefile.PL, MANIFEST and MANIFEST.SKIP
authored
183 if ($ExtUtils::MakeMaker::VERSION ge '6.30_00') {
184 $opts{'LICENSE' } = 'perl';
185 }
a4123f8 @abw 2.04b
authored
186
187 WriteMakefile( %opts );
188
189 print <<EOF;
190
191 Configuration complete. You should now run '$MAKE', '$MAKE test' and
192 then '$MAKE install'. See the README file for further information.
193 EOF
194
195
196 #========================================================================
197
198
199
200 #------------------------------------------------------------------------
201 # welcome_message()
202 #
203 # Print opening banner.
204 #------------------------------------------------------------------------
205
206 sub welcome_message {
207 print(<<EOF);
208
209 Template Toolkit Version $TT_VERSION
c542301 @abw *** empty log message ***
authored
210 =============================
911a5e3 @abw *** empty log message ***
authored
211
ca4050f @abw prep for 2.02
authored
212 Using $FLAVOUR defaults$DEFAULTS.
9be7d64 @abw approaching 2.04d
authored
213 Run 'perl Makefile.PL TT_HELP' for a summary of options.
48634a1 @abw *** empty log message ***
authored
214 EOF
a4123f8 @abw 2.04b
authored
215 print "Messages suppressed (TT_QUIET). " if $TT_QUIET;
216 print "Accepting defaults automatically (TT_ACCEPT)." if $TT_ACCEPT;
217 }
218
219
48634a1 @abw *** empty log message ***
authored
220
221 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
222 # version_check()
223 #
224 # Check for pre-version 2.00 installation and issue warning
48634a1 @abw *** empty log message ***
authored
225 #------------------------------------------------------------------------
226
a4123f8 @abw 2.04b
authored
227 sub version_check {
228 eval "use Template";
229 unless ($@ or $Template::VERSION =~ /^2/) {
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
230 warn(<<EOF) unless $TT_QUIET;
48634a1 @abw *** empty log message ***
authored
231
c542301 @abw *** empty log message ***
authored
232 IMPORTANT NOTE:
a4123f8 @abw 2.04b
authored
233
48634a1 @abw *** empty log message ***
authored
234 You have version $Template::VERSION of the Template Toolkit installed.
25a8d8e @abw *** empty log message ***
authored
235
82cbea8 @abw version 2.00
authored
236 There are some minor incompatabilities between version 1 and 2
48634a1 @abw *** empty log message ***
authored
237 of the Template Toolkit which you should be aware of. Installing
238 this version will overwrite your version $Template::VERSION files
239 unless you take measures to install one or the other version in a
82cbea8 @abw version 2.00
authored
240 different location (i.e. perl Makefile.PL PREFIX=/other/path).
48634a1 @abw *** empty log message ***
authored
241
242 Please consult the README and Changes file for further details.
243 Most of the changes are in the more obscure features and
244 directives so hopefully you will find the upgrade process fairly
9be7d64 @abw approaching 2.04d
authored
245 painless. If you're feeling brave, then answer 'y', otherwise 'n'.
25a8d8e @abw *** empty log message ***
authored
246
247 EOF
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
248 exit unless ttprompt("Do you want to continue?", 'y') =~ /y/i;
a4123f8 @abw 2.04b
authored
249 }
48634a1 @abw *** empty log message ***
authored
250 }
251
a4123f8 @abw 2.04b
authored
252
48634a1 @abw *** empty log message ***
authored
253 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
254 # mandatory_modules()
255 #
256 # Detect mandatory module
c8d76d4 @abw *** empty log message ***
authored
257 #------------------------------------------------------------------------
258
a4123f8 @abw 2.04b
authored
259 sub mandatory_modules {
260 eval "use AppConfig";
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
261 if ($@ or $AppConfig::VERSION < $TT_APPCONFIG_VERSION) {
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
262 warn(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
263
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
264 The Template Toolkit requires that the AppConfig module (version $TT_APPCONFIG_VERSION
265 or later) first be installed. This is used by
266 the 'ttree' program for reading command line options and configuration
267 files. It is available from CPAN:
c8d76d4 @abw *** empty log message ***
authored
268
269 http://www.cpan.org/authors/Andy_Wardley/
270
271 EOF
a4123f8 @abw 2.04b
authored
272 }
c8d76d4 @abw *** empty log message ***
authored
273
a4123f8 @abw 2.04b
authored
274 eval "use File::Spec";
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
275 if ($@ or $File::Spec::VERSION < $TT_FILE_SPEC_VERSION) {
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
276 warn(<<EOF);
911a5e3 @abw *** empty log message ***
authored
277
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
278 The Template Toolkit requires that the File::Spec module (version $TT_FILE_SPEC_VERSION
911a5e3 @abw *** empty log message ***
authored
279 or later) first be installed. This is used by the File plugin. It is
280 available from CPAN:
281
282 http://search.cpan.org/search?dist=File-Spec
283
284 EOF
a4123f8 @abw 2.04b
authored
285 }
911a5e3 @abw *** empty log message ***
authored
286
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
287 eval "use File::Temp";
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
288 if ($@ or $File::Temp::VERSION < $TT_FILE_TEMP_VERSION) {
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
289 warn(<<EOF);
290
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
291 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
292 or later) first be installed. This is used by the Template::Document
293 class for storing compiled templates. It is available from CPAN:
294
295 http://search.cpan.org/search?dist=File-Temp
296
297 EOF
298 }
299 }
911a5e3 @abw *** empty log message ***
authored
300
a4123f8 @abw 2.04b
authored
301
c8d76d4 @abw *** empty log message ***
authored
302 #------------------------------------------------------------------------
9be7d64 @abw approaching 2.04d
authored
303 # optional_stash_xs()
304 #
305 # Prompt for installation and default use of XS Stash.
306 #------------------------------------------------------------------------
307
308 sub optional_stash_xs {
309 # return if $TT_ACCEPT && (! $TT_XS_ENABLE || $TT_XS_ENABLE eq 'n');
310
311 message(<<EOF);
312
313
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
314 Template::Stash::XS
315 -------------------
316
317 The Template::Stash module is a core part of the Template Toolkit,
318 implementing the magic for accessing data using the dot notation.
9be7d64 @abw approaching 2.04d
authored
319
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
320 There is a high speed version, Template::Stash::XS, written in C.
321 This makes the Template Toolkit run about twice as fast as when using
322 the regular Template::Stash written in Perl. If you've got a C
323 compiler on your system then you can elect to have the XS Stash built.
324 You can also specify that you want to use the XS Stash by default.
9be7d64 @abw approaching 2.04d
authored
325
d56b9a8 @abw commit for 2.14a
authored
326 Note that as of version 2.15 the XS Stash now supports access to tied
327 hashes and arrays.
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
328
329 See 'perldoc Template::Config' for further details.
9be7d64 @abw approaching 2.04d
authored
330
331 EOF
332
333 $TT_XS_ENABLE = (ttprompt('Do you want to build the XS Stash module?',
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
334 $TT_XS_ENABLE) =~ /^y/i);
9be7d64 @abw approaching 2.04d
authored
335
336 if ($TT_XS_ENABLE) {
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
337 $TT_XS_DEFAULT =
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
338 (ttprompt('Do you want to use the XS Stash by default?',
339 $TT_XS_DEFAULT) =~ /^y/i);
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
340 }
341 else {
342 # If the XS stash is disabled, we cannot use it as the default stash.
343 $TT_XS_DEFAULT = 0;
344 }
9be7d64 @abw approaching 2.04d
authored
345
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
346 # Actually, we would have to fix 'Config.pm' only if the XS stash is
347 # disabled. But this way, we are sure the correct module is used.
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
348 fix_file(catfile('lib','Template','Config.pm'),
349 '$STASH',
350 $TT_XS_DEFAULT ? 'Template::Stash::XS' : 'Template::Stash');
c8d76d4 @abw *** empty log message ***
authored
351 }
352
353
354
a4123f8 @abw 2.04b
authored
355
356
357 #--------------------------------------------------------------------
358 # write_defaults()
359 #
360 # write configuration defaults to file
361 #--------------------------------------------------------------------
362
363 sub write_defaults {
ca4050f @abw prep for 2.02
authored
364 open(FP, "> $DEFAULTS_FILE") || die "$DEFAULTS_FILE: $!\n";
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
365 my ( $ttxs_enable, $ttxs_default )
366 = map { $_ ? 'y' : 'n' }
367 ( $TT_XS_ENABLE, $TT_XS_DEFAULT );
ca4050f @abw prep for 2.02
authored
368 print FP <<EOF;
9be7d64 @abw approaching 2.04d
authored
369 \$TT_XS_ENABLE = '$ttxs_enable';
370 \$TT_XS_DEFAULT = '$ttxs_default';
a4123f8 @abw 2.04b
authored
371 \$TT_ACCEPT = '$TT_ACCEPT';
372 \$TT_QUIET = '$TT_QUIET';
9acc796 @abw post 2.03a
authored
373 1;
ca4050f @abw prep for 2.02
authored
374 EOF
375 close(FP);
c8d76d4 @abw *** empty log message ***
authored
376 }
377
48634a1 @abw *** empty log message ***
authored
378
379
82cbea8 @abw version 2.00
authored
380
381 #------------------------------------------------------------------------
c8d76d4 @abw *** empty log message ***
authored
382 # fix_file($file, $find, $fix)
383 #
384 # Fixes a variable definition in a file. e.g.
d941238 @abw prep 2.4d
authored
385 # fix_file('templates/splash/config', 'images', '/tt2/splash')
c8d76d4 @abw *** empty log message ***
authored
386 #------------------------------------------------------------------------
387
388 sub fix_file {
389 my ($file, $find, $fix) = @_;
390 local *FP;
391 local $/ = undef;
392
393 $find = quotemeta($find);
394
395 open(FP, "< $file") || die "$file: $!\n";
396 my $text = <FP>;
397 close(FP);
398
399 ($text =~ s/^(\s*${find}\s*=\s*)'.*?'/$1'$fix'/m)
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
400 || die "$find not found in $file\n";
c8d76d4 @abw *** empty log message ***
authored
401
402 open(FP, "> $file") || die "$file: $!\n";
403 print FP $text;
404 close(FP);
405 }
406
a4123f8 @abw 2.04b
authored
407
408 #------------------------------------------------------------------------
9be7d64 @abw approaching 2.04d
authored
409 # find_program($path, $prog)
f4df3b6 @abw approach v2.03
authored
410 #
411 # Find a program, $prog, by traversing the given directory path, $path.
412 # Returns full path if the program is found.
413 #
414 # Written by Craig Barratt, Richard Tietjen add fixes for Win32.
9be7d64 @abw approaching 2.04d
authored
415 #
416 # abw changed name from studly caps findProgram() to find_program() :-)
a4123f8 @abw 2.04b
authored
417 #------------------------------------------------------------------------
418
9be7d64 @abw approaching 2.04d
authored
419 sub find_program {
f4df3b6 @abw approach v2.03
authored
420 my($path, $prog) = @_;
714a8cd @abw * prep for release 2.07a
authored
421 # my $sep = $WIN32 ? qr/;/ : qr/:/;
422 # foreach my $dir ( split($sep, $path) ) {
423 foreach my $dir ( split($Config{path_sep}, $path) ) {
f4df3b6 @abw approach v2.03
authored
424 my $file = File::Spec->catfile($dir, $prog);
425 if ( !$WIN32 ) {
426 return $file if ( -x $file );
427 } else {
428 # Windows executables end in .xxx, exe precedes .bat and .cmd
429 foreach my $dx ( qw/exe bat cmd/ ) {
430 return "$file.$dx" if ( -x "$file.$dx" );
431 }
432 }
433 }
434 }
a4123f8 @abw 2.04b
authored
435
436
437 #------------------------------------------------------------------------
438 # message($text)
439 #
440 # Print message unless quiet mode.
441 #------------------------------------------------------------------------
442
443 sub message {
444 return if $TT_QUIET;
445 print @_;
446 }
447
448
449 #------------------------------------------------------------------------
450 # ttprompt($message, $default)
451 #------------------------------------------------------------------------
452
453 sub ttprompt {
454 my ($msg, $def)=@_;
455 my $ISA_TTY = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
456 my $dispdef = defined $def ? "[$def] " : " ";
457 $def = defined $def ? $def : "";
458 my $ans = '';
459 local $|=1;
460 print "$msg $dispdef" unless $TT_QUIET;
461 if ($TT_ACCEPT || ! $ISA_TTY) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
462 print "$def\n" unless $TT_QUIET;
a4123f8 @abw 2.04b
authored
463 }
464 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
465 chomp($ans = <STDIN>);
a4123f8 @abw 2.04b
authored
466 }
467 return ($ans ne '') ? $ans : $def;
468 }
469
470
471 #------------------------------------------------------------------------
472 # yep($text)
473 #------------------------------------------------------------------------
474
475 sub yep {
476 return if $TT_QUIET;
477 print '[X] ', shift, "\n";
478 }
479
480
481 #------------------------------------------------------------------------
482 # nope($text)
483 #------------------------------------------------------------------------
484 sub nope {
485 return if $TT_QUIET;
486 print '[ ] ', shift, "\n";
487 }
Something went wrong with that request. Please try again.