2 # To fully function, this script needs the following variables
13 if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
14 $tmp = $ENV{'TMPDIR'} . "/$$.eht";
16 $tmp ="${DEFAULT_TMPDIR}/$$.eht";
17 $ENV{'TMPDIR'} = ${DEFAULT_TMPDIR}; # set the env var as well
20 $TopPwd = "${TOP_PWD}"; # *Only* needed when using it in-situ (i.e., INSTALLING=0).
21 $InstLibDirGhc = "${libdir}";
22 $InstLibExecDirGhc = "${libexecdir}";
24 $Unlit = ( $INSTALLING ?
25 "${InstLibExecDirGhc}/unlit" :
26 "${TopPwd}/ghc/utils/unlit/unlit" );
27 # but this is re-set to "cat" (after options) if -cpp not seen
28 $HsCpp = ( $INSTALLING ?
29 "${InstLibDirGhc}/hscpp" :
30 "${TopPwd}/ghc/utils/hscpp/hscpp" );
31 $HsP = ( $INSTALLING ?
32 "${InstLibExecDirGhc}/hsp" :
33 "${TopPwd}/ghc/compiler/hsp" );
36 "${InstLibExecDirGhc}/hstags-help" :
37 "${TopPwd}/ghc/utils/hstags/hstags-help" );
46 while ($ARGV[0] =~ /^-./) {
49 /^-v/ && ($Verbose = 1, next);
50 /^-a$/ && ($Append = '>>', next);
51 /^-fglasgow-exts/ && ($HsP_opts .= ' -N', next);
52 /^-optP(.*)/ && ($Cpp_opts .= " $1", next);
53 /^-[UDI]/ && ($Cpp_opts .= " $_", next);
54 /^-cpp/ && ($DoCpp = 1, next);
55 /^-/ && next; # ignore the rest
59 $DoHsCpp = ( ! $DoCpp ) ? 'cat'
60 : "$HsCpp -D__HASKELL1__=2 -D__GLASGOW_HASKELL__=$ProjectVersionInt $Cpp_opts";
62 # to find Prelude.hi and friends.
63 $HsP_opts .= ( $INSTALLING ?
64 "-J${InstLibDirGhc}/imports" :
65 ( '-J' . join(' -J',split(/:/,${HSP_IMPORTS})) ));
67 open(STDOUT, "$Append TAGS") || die "can't create TAGS";
69 foreach $f ( @ARGV ) {
70 # if file is in a dir && we are CPPing, then we add its dir to the -I list.
71 if ( $DoCpp && $f =~ /(.+)\/[^\/]+$/ ) {
77 if ( $f =~ /\.lhs$/ ) {
78 $ToDo = "$Unlit $f - | $DoHsCpp $Idir | $HsP -E $HsP_opts | $HsTagsHelp $f > $tmp";
80 $ToDo = "$DoHsCpp $Idir < $f | $HsP -E $HsP_opts | $HsTagsHelp $f > $tmp";
82 print STDERR "$ToDo\n" if $Verbose;
85 die "Fatal error $return_val\n" if $return_val != 0;
87 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
88 $atime,$mtime, $ctime,$blksize,$blocks) = stat("$tmp");
90 print STDOUT "\f\n$f,${size}\n";
91 print STDOUT `cat $tmp`;