2 # Perl stub requires the following variable to be prepended
6 ($Pgm = $0) =~ s/.*\/([^\/]+)$/\1/;
7 $Usage = "\n" . <<EOUSAGE;
9 $Pgm [-? or -help] [-k] [-n] [-v] [-t] dir/module-target(s)
11 This script runs `make' to build the requested target, WITHOUT
12 including the dependencies generated by `mkdependHS' (i.e., all those
13 derived from import declarations).
15 With a -t flag, it also sets the modification time of the resulting
16 .hi file (one target only, please) to some EARLY date, so that changes
17 to that interface will not trigger much useless recompilation.
19 Typical uses, for module "Bar" in directory "foo":
21 (1) You've changed "Bar" and you want to recompile it; you know that
22 other module interfaces are stable, so you'd rather do without all
23 of `make''s prognostications:
27 (2) You've ADDED a new function to "Bar"; you want to recompile that
28 module, BUT NOT TRIGGER LOTS OF FURTHER COMPILATION because of the
29 "changed" interface file:
33 USE AT YOUR OWN RISK: you can make a big mess with this script!
36 $Makefile = 'Makefile';
37 if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
38 $Tmpfile = $ENV{'TMPDIR'} . "/Makefile$$";
40 $Tmpfile = "${TMPDIR}/Makefile$$";
41 $ENV{'TMPDIR'} = "${TMPDIR}"; # set the env var as well
43 $SleazyTouch = '/usr/5bin/touch';
49 print STDERR "rm $Tmpfile\n" if $Verbose;
53 $SIG{'INT'} = 'rm_temp_file';
54 $SIG{'QUIT'} = 'rm_temp_file';
57 $DirMod = ''; # the dir/module-file to make
60 while ($_ = $ARGV[0]) {
62 if (/^-\?$/ || /^-help$/) {
76 print STDERR "$Pgm: unknown option: $_\n\n$Usage";
78 } elsif (/^([A-Z_]+)=(.+)/) {
79 $MakeFlags .= " $1=\"$2\"";
81 } elsif ($Do_touch) { # the module file
83 if ( /([^\/]+\/[^\/\.]+)\.[a-z]+/ ) {
86 print STDERR "$Pgm: argument not of the form: directory/Module.suffix: $_\n\n$Usage";
89 } else { # accumulate as "Target"...
94 if ($Do_touch && $Target =~ / /) {
95 print STDERR "$Pgm: too many arguments\n\n$Usage";
99 open(INF, "<$Makefile") || die "Can't open $Makefile for input\n";
101 open(OUTF,">$Tmpfile") || die "Can't open $Tmpfile for output\n";
106 # copy through until ...
107 while ( $_ && ! /^# DO NOT DELETE: Beginning of Haskell dependencies/ ) {
112 # now copy through 'til the end, omitting the %.{o,s,hc} : %.hi dependencies
114 print $_ if ! /^\S+ : \S+\.hi$/;
121 $Make = 'make JMAKE=jmake LIT2PGM=lit2pgm LIT2LATEX=lit2latex LIT2TEXI=lit2texi MKDEPENDLIT=mkdependlit MAKEINFO=makeinfo POSTMAKEINFO=postmakeinfo';
123 print STDERR "$Make $MakeFlags -f $Tmpfile $Target; rm $Tmpfile\n" if $Verbose;
125 system( "$Make $MakeFlags -f $Tmpfile $Target; rm $Tmpfile" );
128 print STDERR "$SleazyTouch -m 01010101 $DirMod\.hi\n" if $Verbose;
129 system( "$SleazyTouch -m 01010101 $DirMod\.hi" );