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}";
21 $InstLibDirGhc = "${INSTLIBDIR_GHC}";
23 $Unlit = ( $INSTALLING ?
24 "${InstLibDirGhc}/unlit" :
25 "${TopPwd}/ghc/utils/unlit/unlit" );
26 # but this is re-set to "cat" (after options) if -cpp not seen
27 $HsCpp = ( $INSTALLING ?
28 "${InstLibDirGhc}/hscpp" :
29 "${TopPwd}/ghc/utils/hscpp/hscpp" );
30 $HsP = ( $INSTALLING ?
31 "${InstLibDirGhc}/hsp" :
32 "${TopPwd}/ghc/compiler/hsp" );
35 "${InstLibDirGhc}/hstags-help" :
36 "${TopPwd}/ghc/utils/hstags/hstags-help" );
45 while ($ARGV[0] =~ /^-./) {
48 /^-v/ && ($Verbose = 1, next);
49 /^-a$/ && ($Append = '>>', next);
50 /^-fglasgow-exts/ && ($HsP_opts .= ' -N', next);
51 /^-optP(.*)/ && ($Cpp_opts .= " $1", next);
52 /^-[UDI]/ && ($Cpp_opts .= " $_", next);
53 /^-cpp/ && ($DoCpp = 1, next);
54 /^-/ && next; # ignore the rest
58 $ghc_version_info = int(${PROJECTVERSION} * 100);
59 $DoHsCpp = ( ! $DoCpp ) ? 'cat'
60 : "$HsCpp -D__HASKELL1__=2 -D__GLASGOW_HASKELL__=$ghc_version_info $Cpp_opts";
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`;