2 # To fully function, this script needs the following variables
12 if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
13 $tmp = $ENV{'TMPDIR'} . "/$$.eht";
15 $tmp ="${TMPDIR}/$$.eht";
16 $ENV{'TMPDIR'} = ${TMPDIR}; # set the env var as well
19 $TopPwd = "${TOP_PWD}"; # *Only* needed when using it in-situ (i.e., INSTALLING=0).
20 $InstLibDirGhc = "${libdir}";
22 $Unlit = ( $INSTALLING ?
23 "${InstLibDirGhc}/unlit" :
24 "${TopPwd}/ghc/utils/unlit/unlit" );
25 # but this is re-set to "cat" (after options) if -cpp not seen
26 $HsCpp = ( $INSTALLING ?
27 "${InstLibDirGhc}/hscpp" :
28 "${TopPwd}/ghc/utils/hscpp/hscpp" );
29 $HsP = ( $INSTALLING ?
30 "${InstLibDirGhc}/hsp" :
31 "${TopPwd}/ghc/compiler/hsp" );
34 "${InstLibDirGhc}/hstags-help" :
35 "${TopPwd}/ghc/utils/hstags/hstags-help" );
44 while ($ARGV[0] =~ /^-./) {
47 /^-v/ && ($Verbose = 1, next);
48 /^-a$/ && ($Append = '>>', next);
49 /^-fglasgow-exts/ && ($HsP_opts .= ' -N', next);
50 /^-optP(.*)/ && ($Cpp_opts .= " $1", next);
51 /^-[UDI]/ && ($Cpp_opts .= " $_", next);
52 /^-cpp/ && ($DoCpp = 1, next);
53 /^-/ && next; # ignore the rest
57 $ghc_version_info = int(${PROJECTVERSION} * 100);
58 $DoHsCpp = ( ! $DoCpp ) ? 'cat'
59 : "$HsCpp -D__HASKELL1__=2 -D__GLASGOW_HASKELL__=$ghc_version_info $Cpp_opts";
61 # to find Prelude.hi and friends.
62 $HsP_opts .= ( $INSTALLING ?
63 "-J${InstLibDirGhc}/imports" :
64 ( '-J' . join(' -J',split(/:/,${HSP_IMPORTS})) ));
66 open(STDOUT, "$Append TAGS") || die "can't create TAGS";
68 foreach $f ( @ARGV ) {
69 # if file is in a dir && we are CPPing, then we add its dir to the -I list.
70 if ( $DoCpp && $f =~ /(.+)\/[^\/]+$/ ) {
76 if ( $f =~ /\.lhs$/ ) {
77 $ToDo = "$Unlit $f - | $DoHsCpp $Idir | $HsP -E $HsP_opts | $HsTagsHelp $f > $tmp";
79 $ToDo = "$DoHsCpp $Idir < $f | $HsP -E $HsP_opts | $HsTagsHelp $f > $tmp";
81 print STDERR "$ToDo\n" if $Verbose;
84 die "Fatal error $return_val\n" if $return_val != 0;
86 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
87 $atime,$mtime, $ctime,$blksize,$blocks) = stat("$tmp");
89 print STDOUT "\f\n$f,${size}\n";
90 print STDOUT `cat $tmp`;