3 ($Pgm = $0) =~ s/.*\/([^\/]+)$/\1/;
4 $Usage = "\n" . <<EOUSAGE;
6 $Pgm [-? or -help] [-k] [-n] [-v] [-t] dir/module-target(s)
8 This script runs `make' to build the requested target, WITHOUT
9 including the dependencies generated by `mkdependHS' (i.e., all those
10 derived from import declarations).
12 With a -t flag, it also sets the modification time of the resulting
13 .hi file (one target only, please) to some EARLY date, so that changes
14 to that interface will not trigger much useless recompilation.
16 Typical uses, for module "Bar" in directory "foo":
18 (1) You've changed "Bar" and you want to recompile it; you know that
19 other module interfaces are stable, so you'd rather do without all
20 of `make''s prognostications:
24 (2) You've ADDED a new function to "Bar"; you want to recompile that
25 module, BUT NOT TRIGGER LOTS OF FURTHER COMPILATION because of the
26 "changed" interface file:
30 USE AT YOUR OWN RISK: you can make a big mess with this script!
33 $Makefile = 'Makefile';
34 if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
35 $Tmpfile = $ENV{'TMPDIR'} . "/Makefile$$";
37 $Tmpfile = "$(TMPDIR)/Makefile$$";
38 $ENV{'TMPDIR'} = '$(TMPDIR)'; # set the env var as well
40 $SleazyTouch = '/usr/5bin/touch';
46 print STDERR "rm $Tmpfile\n" if $Verbose;
50 $SIG{'INT'} = 'rm_temp_file';
51 $SIG{'QUIT'} = 'rm_temp_file';
54 $DirMod = ''; # the dir/module-file to make
57 while ($_ = $ARGV[0]) {
59 if (/^-\?$/ || /^-help$/) {
73 print STDERR "$Pgm: unknown option: $_\n\n$Usage";
75 } elsif (/^([A-Z_]+)=(.+)/) {
76 $MakeFlags .= " $1=\"$2\"";
78 } elsif ($Do_touch) { # the module file
80 if ( /([^\/]+\/[^\/\.]+)\.[a-z]+/ ) {
83 print STDERR "$Pgm: argument not of the form: directory/Module.suffix: $_\n\n$Usage";
86 } else { # accumulate as "Target"...
91 if ($Do_touch && $Target =~ / /) {
92 print STDERR "$Pgm: too many arguments\n\n$Usage";
96 open(INF, "<$Makefile") || die "Can't open $Makefile for input\n";
98 open(OUTF,">$Tmpfile") || die "Can't open $Tmpfile for output\n";
103 # copy through until ...
104 while ( $_ && ! /^# DO NOT DELETE: Beginning of Haskell dependencies/ ) {
109 # now copy through 'til the end, omitting the %.{o,s,hc} : %.hi dependencies
111 print $_ if ! /^\S+ : \S+\.hi$/;
118 $Make = 'make JMAKE=jmake LIT2PGM=lit2pgm LIT2LATEX=lit2latex LIT2TEXI=lit2texi MKDEPENDLIT=mkdependlit MAKEINFO=makeinfo POSTMAKEINFO=postmakeinfo';
120 print STDERR "$Make $MakeFlags -f $Tmpfile $Target; rm $Tmpfile\n" if $Verbose;
122 system( "$Make $MakeFlags -f $Tmpfile $Target; rm $Tmpfile" );
125 print STDERR "$SleazyTouch -m 01010101 $DirMod\.hi\n" if $Verbose;
126 system( "$SleazyTouch -m 01010101 $DirMod\.hi" );