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 ="${TMPDIR}/$$.eht";
17 $ENV{'TMPDIR'} = ${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 $ghc_version_info = ${ProjectVersionInt}
60 $DoHsCpp = ( ! $DoCpp ) ? 'cat'
61 : "$HsCpp -D__HASKELL1__=2 -D__GLASGOW_HASKELL__=$ghc_version_info $Cpp_opts";
63 # to find Prelude.hi and friends.
64 $HsP_opts .= ( $INSTALLING ?
65 "-J${InstLibDirGhc}/imports" :
66 ( '-J' . join(' -J',split(/:/,${HSP_IMPORTS})) ));
68 open(STDOUT, "$Append TAGS") || die "can't create TAGS";
70 foreach $f ( @ARGV ) {
71 # if file is in a dir && we are CPPing, then we add its dir to the -I list.
72 if ( $DoCpp && $f =~ /(.+)\/[^\/]+$/ ) {
78 if ( $f =~ /\.lhs$/ ) {
79 $ToDo = "$Unlit $f - | $DoHsCpp $Idir | $HsP -E $HsP_opts | $HsTagsHelp $f > $tmp";
81 $ToDo = "$DoHsCpp $Idir < $f | $HsP -E $HsP_opts | $HsTagsHelp $f > $tmp";
83 print STDERR "$ToDo\n" if $Verbose;
86 die "Fatal error $return_val\n" if $return_val != 0;
88 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
89 $atime,$mtime, $ctime,$blksize,$blocks) = stat("$tmp");
91 print STDOUT "\f\n$f,${size}\n";
92 print STDOUT `cat $tmp`;