[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / utils / mkdependHS / mkdependHS.prl
1 #
2 # perl script expect the following variables to be prepended:
3 #
4 #  RAWCPP TMPDIR TOP_PWD
5 #  libdir libexecdir datadir INSTALLING
6 #  SED 
7 #
8 # tries to work like mkdependC - capable of dealing with:
9 #
10 #  -literate Haskell code (Bird tracks or Glasgow literate style) (.lhs)
11 #  -straight Haskell source (.hs)
12 #  -literate or straight Happy specs    (.ly)
13 #  
14 # ToDo: strip out all the .h junk
15 #
16 ($Pgm = $0) =~ s/.*\/([^\/]+)$/\1/;
17 $Usage  = <<EOUSAGE;
18 Usage: $Pgm [mkdependHS options] [-- GHC options --] srcfile1 [srcfile2 ...]
19
20 Options recognised wherever they occur (mkdependHS or GHC):
21
22     -D<blah>    A cpp #define; usual meaning
23     -i<dirs>    Add <dirs> (colon-separated) to list of directories
24                 to search for "import"ed modules
25     -I<dir>     Add <dir> to list of directories to search for
26                 .h files (i.e., usual meaning)
27     -syslib <blah> This program uses this GHC system library; take
28                 appropriate action (e.g., recognise when they are
29                 "import"ing a module from that library).
30
31 mkdependHS-specific options (not between --'s):
32
33     -v          Be verbose.
34     -v -v       Be very verbose.
35     -w          No warnings
36     -f blah     Use "blah" as the makefile, rather than "makefile"
37                 or "Makefile".
38     -cpp        Wash the input files through cpp(1).
39     -o <osuf>   Use <osuf> as the "object file" suffix ( default: o)
40     -s <suf>    Make extra dependencies for files with
41                 suffix <suf><osuf>; thus, "-o hc -s _a" will
42                 make dependencies both for .hc files and for .a_hc
43                 files.  (Useful in conjunction with NoFib "ways".)
44     --exclude-module=<file> 
45                 Regard <file> as "stable"; i.e., eXclude it from having
46                 dependencies on it.
47     -x          same as --exclude-module
48     --exclude-directory=<dirs> 
49                 Regard : separated list of directories as containing stable,
50                 don't generate any dependencies on modules therein.
51     -Xdirs      same as --exclude-directory
52     --include-prelude
53                 Regard prelude libraries as unstable, i.e., generate dependencies
54                 on prelude modules. This option is normally only used by the
55                 various system libraries. If a -syslib option is used, dependencies
56                 will also be generated on the library's interfaces.
57     --include-module=<file> 
58                 Regard <file> as not "stable"; i.e., generate dependencies
59                 on it (if any). This option is normally used in conjunction 
60                 with the --exclude-directory option.
61
62 EOUSAGE
63
64 $Status     = 0; # just used for exit() status
65 $Verbose    = 0; # 1 => verbose, 2 => very verbose
66 $Warnings   = 1; # 1 => warn about duplicate interface files
67 $Dashdashes_seen = 0;
68
69 $Cpp = ${RAWCPP};
70 $Cpp_flag_set = 0; # 1 => run cpp over input files.
71
72 if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
73     $Tmp_prefix = $ENV{'TMPDIR'} . "/mkdependHS$$";
74 } else {
75     $Tmp_prefix ="${TMPDIR}/mkdependHS$$";
76     $ENV{'TMPDIR'} = "${TMPDIR}"; # set the env var as well
77 }
78
79 $TopPwd            = "${TOP_PWD}";
80 $InstLibDirGhc     = "${libdir}";
81 $InstLibExecDirGhc = "${libexecdir}";
82 $InstDataDirGhc    = "${datadir}";
83
84 $Unlit = ($INSTALLING) ? "${InstLibExecDirGhc}/unlit" 
85                        : "${TopPwd}/ghc/utils/unlit/unlit";
86
87 $Begin_magic_str = "# DO NOT DELETE: Beginning of Haskell dependencies\n";
88 $End_magic_str = "# DO NOT DELETE: End of Haskell dependencies\n";
89 @Obj_suffix =  ("o");
90 @File_suffix = ();
91
92 $Import_dirs = '.';
93 %Syslibs = ();
94 %LibIfaces  = ();  # known prelude/syslib ifaces; read from a file
95 %IgnoreMe = ();
96 # directories to considered stable.
97 @Ignore_dirs = ();
98
99 $Include_dirs = '-I.';
100 $Makefile = '';
101 @Src_files = ();
102 $Include_prelude = 0;
103 @Defines = ();
104
105 # Delete temp. file if script is halted.
106 sub quit_upon_signal { print STDERR "Deleting $Tmp_prefix.hs .. \n"; unlink "$Tmp_prefix.hs"; }
107 $SIG{'INT'}  = 'quit_upon_signal';
108 $SIG{'QUIT'} = 'quit_upon_signal';
109
110 &mangle_command_line_args();
111
112 if ( $Status ) {
113     print stderr $Usage;
114     exit(1);
115 }
116
117 @Import_dirs  = split(/:/,$Import_dirs);
118 @Include_dirs = split(/\s+/,$Include_dirs); # still has -I's in it
119
120 # set up array of ignored modules
121 local(@dirs) = ($INSTALLING) ? 
122                ("$InstLibDirGhc/imports/std")
123              : ("$TopPwd/ghc/lib/std");
124 if (!$Include_prelude) {
125     push(@Ignore_dirs, @dirs);
126 } else {
127     push(@Import_dirs, @dirs);
128 }
129
130 foreach $lib ( @Syslibs ) {
131     local($dir);
132
133     if ( $lib eq 'win32' && ! $INSTALLING ) {
134       $dir = "${TopPwd}/hslibs/${lib}/src";
135     } else {
136       $dir = ($INSTALLING) ? "${InstLibDirGhc}/imports/${lib}" 
137                            : "${TopPwd}/ghc/lib/${lib}";
138     }
139     if (!$Include_prelude) {
140        push(@Ignore_dirs,$dir);
141     } else {
142        push(@Import_dirs, $dir);
143     }
144 }
145
146
147 # NB: We keep the scalar-variable equivalents to use in error messages
148
149 if ( ! $Makefile && -f 'makefile' ) {
150     $Makefile = 'makefile';
151 } elsif ( ! $Makefile && -f 'Makefile') {
152     $Makefile = 'Makefile';
153 } elsif ( ! $Makefile) {
154     die "$Pgm: no makefile or Makefile found\n";
155 }
156
157 print STDERR "CPP defines=@Defines\n" if $Verbose;
158 print STDERR "Import_dirs=@Import_dirs\n" if $Verbose;
159 print STDERR "Include_dirs=@Include_dirs\n" if $Verbose;
160
161 &preprocess_import_dirs();
162
163 @Depend_lines = ();
164
165 foreach $sf (@Src_files) {
166
167     # just like lit-inputter
168     # except it puts each file through CPP and
169     # a de-commenter (not implemented);
170     # builds up @Depend_lines
171     print STDERR "Here we go for source file: $sf\n" if $Verbose;
172     ($bf = $sf) =~ s/\.l?(hs|y)$//;
173
174     local($str)="";
175     foreach $obj  (@Obj_suffix) {
176         $str .= "$bf.$obj ";
177         foreach $suff (@File_suffix) {
178            $str .= "$bf.${suff}_$obj ";
179         }
180     }
181     push(@Depend_lines, "$str: $sf\n");
182     # if it's a literate file, .lhs or .ly? (happy specs), then we de-literatize it: 
183     if ( $sf !~ /\.l(hs|y)$/ ) {
184         $file_to_read = $sf;
185     } else {
186         $file_to_read = "$Tmp_prefix.hs";
187         local($to_do) = "$Unlit $sf $file_to_read";
188         &run_something($to_do, $sf, 'unlit');
189     }
190     &slurp_file_for_imports($file_to_read, $sf);
191
192     # Delete the temporary.
193     if ( $sf =~ /\.l(hs|y)$/ ) {
194         unlink "$Tmp_prefix.hs";
195     }
196 }
197
198
199 #
200 # Create backup version of output file.
201
202 if ( ! -f $Makefile ) {
203    # truncate() may not be implemented, so we
204    # play it safe here.
205    local(*TRUNC);
206    open(TRUNC,"> $Makefile.bak") && close(TRUNC);
207 } else {
208    rename($Makefile,"$Makefile.bak");
209 }
210 # now copy Makefile.bak into Makefile, rm'ing old dependencies
211 # and adding the new
212 open(OMKF,"< $Makefile.bak") || die "$Pgm: can't open $Makefile.bak: $!\n";
213 open(NMKF,"> $Makefile") || die "$Pgm: can't open $Makefile: $!\n";
214 select(NMKF);
215 $_ = <OMKF>;
216 while ($_ && $_ ne $Begin_magic_str) { # copy through, 'til Begin_magic_str
217     print $_;
218     $_ = <OMKF>;
219 }
220 while ($_ && $_ ne $End_magic_str) { # delete 'til End_magic_str
221     $_ = <OMKF>;
222 }
223 # insert dependencies
224 print "\n$Begin_magic_str", @Depend_lines, $End_magic_str || die "Failed to write out dependencies ($!)";
225
226 while (<OMKF>) { # copy the rest through
227     print $_ || die "Failed to write out dependencies ($!)";
228 }
229 close(NMKF) || exit(1);
230 close(OMKF) || exit(1);
231 exit 0;
232
233 sub mangle_command_line_args {
234     while($_ = $ARGV[0]) {
235         shift(@ARGV);
236
237         if ( /^--$/ ) {
238             $Dashdashes_seen++;
239
240         } elsif ( /^-D(.*)/ ) { # recognized wherever they occur
241             push(@Defines, $_);
242         } elsif ( /^-cpp$/ ) { # recognized wherever they occur
243             $Cpp_flag_set =1; 
244         } elsif ( /^-i$/ ) {
245             $Import_dirs = ''; # import path cleared!
246         } elsif ( /^-i(.*)/ ) {
247             $Import_dirs = "$1:$Import_dirs";
248         } elsif ( /^-I/ ) {
249             $Include_dirs .= " $_";
250         } elsif ( /^-syslib$/ ) {
251             push(@Syslibs, &grab_arg_arg($_,''));
252         } elsif ( /^-fglasgow-exts$/ ) {
253             push(@Syslibs, 'exts');
254         } elsif ( /^-concurrent$/ ) {
255             push(@Syslibs, 'concurrent');
256         } elsif ($Dashdashes_seen != 1) { # not between -- ... --
257             if ( /^-v$/ ) {
258                 $Verbose++;
259             } elsif ( /^-w$/ ) {
260                 $Warnings     = 0;
261             } elsif ( /^-f(.*)/ ) {
262                 $Makefile       = &grab_arg_arg('-f',$1);
263             } elsif ( /^-o(.*)/ ) {
264                 local($suff)    = &grab_arg_arg('-o',$1);
265                 # Weed out existing entry .. there must be a better way of doing this
266                 # with arrays (non-assoc) ! -- sof
267                 @Obj_suffix     = grep(!/$suff/,@Obj_suffix);
268                 push(@Obj_suffix, $suff);
269             #
270             # --exclude-module=mod => it's stable, trust me!
271             
272             } elsif ( /^-(x|-exclude-module=)(.*)/ ) { 
273                 local($thing) = &grab_arg_arg($1,$2);
274                 $IgnoreMe{$thing} = 'Y';
275             } elsif ( /^-(X|-exclude-directory=)(.*)/ ) { 
276                 foreach $d ( split(/:/,&grab_arg_arg($1, $2)) ) {
277                    push(@Ignore_dirs,"$d");
278                 }
279             } elsif ( /^--include-module=(.*)/ ) { 
280                 local($thing) = &grab_arg_arg($1,$2);
281                 $IgnoreMe{$thing} = 'n';
282             } elsif ( /^--include-prelude$/ ) { 
283                 $Include_prelude = 1;
284             } elsif ( /^-s(.*)/ ) {
285                 local($suff)    =  &grab_arg_arg('-s',$1);
286                 push(@File_suffix, $suff);
287             } elsif ( /^-/ ) {
288                 print STDERR "$Pgm: unknown option ignored: $_\n";
289                 $Status++;
290             } else {
291                 push(@Src_files, $_);
292             }
293         }
294         # Removed support for picking up plausible source file 
295         # names inside the ghc options chunk of the command
296         # line. It failed to deal with `option-value' stuff present
297         # on some invocations of ghc (e.g., "-ohi foo.baz").
298         #  -- sof 12/97
299         #
300         # } elsif ($Dashdashes_seen == 1) {
301         #     push(@Src_files, $_) if ! /^-/;
302         # }
303     }
304     @File_suffix = sort (@File_suffix);
305 }
306
307 sub grab_arg_arg {
308     local($option, $rest_of_arg) = @_;
309     
310     if ($rest_of_arg) {
311         return($rest_of_arg);
312     } elsif ($#ARGV >= 0) {
313         local($temp) = $ARGV[0]; shift(@ARGV); 
314         return($temp);
315     } else {
316         print STDERR "$Pgm: no argument following $option option\n";
317         $Status++;
318     }
319 }
320
321 sub preprocess_import_dirs {
322     # it's probably cheaper to find out what's in all
323     # the @Import_dirs before we start processing.
324     local($d, $thing);
325     local($_);
326     %ModuleIn = ();
327
328     foreach $d ( @Import_dirs ) {
329         # Check to see if it can be ignored
330         #print STDERR "Ignore imports from $d\n" if $Verbose && $Ignore_dirs{$d};
331         #next if $Ignore_dirs{$d};
332
333         opendir(DIR, $d) || die "$Pgm: can't open directory $d\n";
334
335         for ($_ = readdir(DIR); $_; $_ = readdir(DIR)) {
336             next unless /(.*)\.hi$/;
337             $thing = $1;
338             if ($ModuleIn{$thing} && $ModuleIn{$thing} ne $d) {
339                 print STDERR "$Pgm: warning: $thing.hi appears in both $ModuleIn{$thing} and $d!\n" if ($Warnings);
340             } else {
341                 $ModuleIn{$thing} = $d;
342             }
343         }
344         closedir(DIR); # No, don't check the error code
345     }
346
347     # Add all the modules
348     # to the IgnoreMe array before we start scanning for imports.
349     foreach $d (@Ignore_dirs) {
350
351         opendir(DIR, $d) || die "$Pgm: can't open directory $d\n";
352
353         for ($_ = readdir(DIR); $_; $_ = readdir(DIR)) {
354             next unless /(.*)\.(hi|l?hs|l?y)$/;
355             #don't tag it twice or overwrite it with a diff. value
356             next if $IgnoreMe{$1};
357             print STDERR "Module $d will be ignored\n" if $Verbose;
358
359             $IgnoreMe{$1} = 'y';
360         }
361         closedir(DIR); # No, don't check the error code
362     }
363 }
364
365 sub slurp_file_for_imports {
366     local($file_to_read, $orig_src_file) = @_;
367     local($follow_file,$read_from_file);
368     local($cleanup)=0;
369
370     local($last_seen_dir) = $orig_src_file;
371     $last_seen_dir =~ s/\/[^\/]+$//; # strip to dir name
372     $last_seen_dir = '.' if ($last_seen_dir eq $orig_src_file);
373
374     local($mod_name) = $orig_src_file;
375
376     $mod_name =~ s/.*\/([^\/]+)$/$1/g;
377     $mod_name =~ s/^([^.]+)\.(.*)$/$1/;
378
379     print STDERR "Warning: processing module $mod_name, which I was supposed to ignore.\n"
380         if ( $IgnoreMe{$mod_name} eq 'Y' && $Warnings );
381
382     &process_dependency('import',0,'Prelude') if ($Include_prelude);
383
384     # we mangle #include's so they will also leave something
385     # behind to indicate the dependency on _them_
386     
387     local ($open_cmd);
388     if ($Cpp_flag_set) {
389 #       $open_cmd = "${SED} -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines |";
390        &run_something("${SED} -e '/^# *include/{p;s/^# *include/!include/;};s/'\\''//g;s/\"//g' $file_to_read | $Cpp $Include_dirs -I$last_seen_dir @Defines 2>&1 > ${file_to_read}.i", $orig_src_file, 'cpp');
391        $read_from_file="${file_to_read}.i";
392        $cleanup=1;
393     } else {
394        $read_from_file="${file_to_read}";
395        $open_cmd = $file_to_read;
396     }
397     print STDERR "$open_cmd\n" if $Verbose;
398
399     open(SRCFILE, $read_from_file) || die "$Pgm: Can't open $file_to_read: $!\n";
400
401     while (<SRCFILE>) {
402         #
403         # import {-# SOURCE #-} Foo (bar) generates dependencies on the source file only,
404         # the compiler will deal with the absence of Foo.hi by consulting the
405         # source for Foo directly. (for dealing with recursive modules).
406         #
407         next unless (/^>?\s*(import)(\s+{-#\s*SOURCE\s*#-})?(\s+qualified)?\s+([A-Z][A-Za-z0-9_']*)/ || /^!(include)(\s+)"(\S+)"/);
408         $todo    = $1;
409         $source  = ( $2 ne '') ? 1 : 0;
410         $modname = $4;
411
412         next if $modname eq '';
413         &process_dependency($todo,$source,$modname);
414     }
415     close(SRCFILE) || exit(1);
416     # remove temporary file, if any.
417     if ($cleanup) {
418            # truncate() may not be implemented, so we
419            # play it safe here.
420            local(*TRUNC);
421            open(TRUNC,"> $read_from_file") && close(TRUNC);
422     }
423 }
424
425 #
426 # Handle
427 sub process_dependency {
428   local($todo,$source,$modname) = @_;
429
430   if ($todo eq 'import') {
431     if ( $IgnoreMe{$modname} eq 'Y' ) {
432          # user specifically asked for this module
433          # to be ignored.
434          $follow_file = '__ignore__';
435     } elsif ( $ModuleIn{$modname} ) {
436         $follow_file = "$ModuleIn{$modname}/$modname.hi";
437     } else { # hard way
438         $follow_file =
439           &find_in_Import_dirs($orig_src_file, $modname, $last_seen_dir, $source );
440     }
441   } else {
442         $follow_file
443           = &find_in_Include_dirs($orig_src_file, $modname, $last_seen_dir);
444   }
445
446   if (! $follow_file) { # it didnae find anything
447       die "$orig_src_file: Couldn't handle: $_\n";
448
449   } else { # it found something
450     if ($follow_file ne '__ignore__') {
451         local($int_file) = $follow_file;
452
453         if ( $int_file !~ /\.(l?hs|hi|l?y)$/ ) {
454             local($str) = "";
455             foreach $obj  (@Obj_suffix) {
456                 $str .= "$bf.$obj ";
457                 foreach $suff (@File_suffix) {
458                    $str .= "$bf.${suff}_$obj ";
459                 }
460             }
461             push(@Depend_lines, "$str: $int_file\n");
462         } else {
463             $int_file =~ s/\.l?hs$//;
464             $int_file =~ s/\.l?y$//;
465             $int_file =~ s/\.hi$//;
466             local($source_dep);
467
468             if ( $source ) {
469                 $source_dep = "$int_file.hi-boot";
470             } else {
471                 local($str)="";
472                 foreach $obj (@Obj_suffix) {
473                    $str .= "$bf.$obj ";
474                 }
475                 push(@Depend_lines, "$str: $int_file.hi\n");
476             }
477
478             if ( ! $source ) {
479                foreach $suff  (@File_suffix) {
480                   local($str) = "";
481                   foreach $obj (@Obj_suffix) {
482                     $str .= "$bf.${suff}_$obj ";
483                   }
484                   push(@Depend_lines, "$str: $int_file.${suff}_hi\n");
485                }
486             } else {
487                local($str) = "";
488                foreach $obj  (@Obj_suffix) {
489                    $str .= "$bf.$obj ";
490                    foreach $suff (@File_suffix) {
491                      $str .= "$bf.${suff}_$obj ";
492                    }
493                }
494                push(@Depend_lines, "$str: $source_dep\n");
495             }
496         }
497      }
498    }
499 }
500
501 # when we see something, we cache that fact ('y').
502 # also, when we get a miss, we cache that (so we don't try later); ('n')
503 %FileExists = ();
504
505 sub find_in_Import_dirs {
506     local($orig_src_file, $modname, $last_seen_dir, $source) = @_;
507     local($import_dir);
508     local($do_magical_check) = 0;
509     local($name_to_check);
510
511     # do it the old hard way: hop along Import_dir list
512     foreach $import_dir (@Import_dirs) {
513         # handle . magically
514         if ($import_dir eq '.') {
515             # record that we should do a SPECIAL try for a file in last_seen_dir (LAST)
516             $do_magical_check = 1;
517         }
518
519         $name_to_check = "$import_dir/$modname.hi";
520         if ( $FileExists{$name_to_check} ne 'n' ) { # either 'y' or nothing
521             print STDERR "trying $name_to_check...\n" if $Verbose >= 2; # very verbose
522             return($name_to_check) if $FileExists{$name_to_check} eq 'y';
523             if (-f $name_to_check) {
524                 $FileExists{$name_to_check} = 'y';
525                 return($name_to_check) ;
526             } else {
527                 $FileExists{$name_to_check} = 'n';
528             }
529         }
530
531         for $suff ('hs', 'lhs', 'ly', 'y') {
532             $name_to_check = "$import_dir/$modname.$suff";
533             print STDERR "trying... $name_to_check\n" if $Verbose >= 2; # very verbose
534             return($name_to_check) if -f $name_to_check;
535         }
536
537         if ( $source ) {
538             $name_to_check = "$import_dir/$modname.hi-boot";
539             print STDERR "trying... $name_to_check\n" if $Verbose >= 2; # very verbose
540             return($name_to_check) if -f $name_to_check;
541         }               
542     }
543     if ($do_magical_check == 1) {
544         $name_to_check = "$last_seen_dir/$modname.hi";
545
546         if ( $FileExists{$name_to_check} ne 'n' ) { # either 'y' or nothing
547             print STDERR "trying $name_to_check...\n" if $Verbose >= 2; # very verbose
548             return($name_to_check) if $FileExists{$name_to_check} eq 'y';
549             if (-f $name_to_check) {
550                 $FileExists{$name_to_check} = 'y';
551                 return($name_to_check) ;
552             } else {
553                 $FileExists{$name_to_check} = 'n';
554             }
555         }
556
557         for $suff ('lhs', 'hs', 'ly', 'y') {
558             $name_to_check = "$last_seen_dir/$modname.$suff";
559             print STDERR "trying... $name_to_check\n" if $Verbose >= 2; # very verbose
560             return($name_to_check) if -f $name_to_check;
561         }
562     }
563
564     # OK, maybe it's referring to something in a system library
565     #foreach $lib ( @Syslibs ) {
566     #   return('__ignore__') if $LibIfaces{"$lib:$modname"};
567     #}
568
569     # Last hope: referring to a Prelude interface
570     return('__ignore__') if ( $IgnoreMe{$modname} eq 'y' );
571
572     die "No file `$modname.hi', `$modname.lhs', `$modname.hs' (reqd from file `$orig_src_file')\namong import directories:\n\t$Import_dirs\n";
573 }
574
575 sub find_in_Include_dirs {
576     local($orig_src_file, $name, $last_seen_dir) = @_;
577     local($include_dir);
578     local($do_magical_check) = 0;
579
580     # no funny name guessing here
581
582     # hop along Include_dir list
583     foreach $include_dir (@Include_dirs) {
584         $include_dir =~ s/^-I//;
585
586         # handle . magically
587         if ($include_dir eq '.') {
588             # record that we should do a SPECIAL try for a file in last_seen_dir (LAST)
589             $do_magical_check = 1;
590         }
591         print STDERR "trying $include_dir/$name...\n" if $Verbose >= 2; # very verbose
592         if (-f "$include_dir/$name") {
593             return("$include_dir/$name");
594         }
595     }
596     if ($do_magical_check == 1) {
597         print STDERR "trying $last_seen_dir/$name...\n" if $Verbose >= 2; # very verbose
598         if (-f "$last_seen_dir/$name") {
599             return("$last_seen_dir/$name");
600         }
601     }
602     die "No file `$name' (reqd from file `$orig_src_file') among include directories: $Include_dirs\n";
603 }
604
605 # out of the driver, actually
606 sub run_something {
607     local($str_to_do, $file_to_read, $tidy_name) = @_;
608
609     print STDERR "\n$tidy_name:\n\t" if $Verbose;
610     print STDERR "$str_to_do\n" if $Verbose;
611
612     local($return_val) = system($str_to_do) >> 8;
613
614     if ($return_val != 0) {
615         local($die_msg) = "$Pgm: Running $tidy_name ( on $file_to_read ) failed";
616         $die_msg .= " program not found: $str_to_do " if $return_val == 255;
617         $die_msg .= " ($!)" if $Verbose && $! != 0;
618         $die_msg .= "\n";
619         print STDERR $die_msg;
620         exit $return_val;
621     }
622 }