lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Makefile rule for a lout document


From: Valeriy E. Ushakov
Subject: Makefile rule for a lout document
Date: Fri, 1 Aug 1997 14:14:19 +0400 (MSD)

Quite a while ago DaviD W. Sanderson <address@hidden> posted a
makefile fragment for a lout document.

Below is a slighlty more elaborated makefile rule that keeps on
formatting your document if it has unresolved xrefs in it but stops on
first `real' error.  The only problem with this code (and it can't be
easyly fixed) is when you have some xref that is really undefined.  In
this case the code will desperately loop until it reaches its
iteration limit.  This code is a slightly modified version of code I
use in my louttib package.

<makefile>

LOUT      = lout        # how to run lout
LTFLAGS   =             # whatever flags you want to pass except -o and -e

PSFILE    = output.ps   # whatever your ouput is
LTFILE    = all.lt      # main file to process with lout
LTDEPS    = setup.lt mydefs.lt ch1.lt ch2.lt # etc... -- lout files included

$(PSFILE): $(LTFILE) $(LTDEPS)
        @(umask 022; \
        errdir="$${TMPDIR-/tmp}/.lc$$$$"; \
        mkdir "$$errdir" || { \
            echo Temporary directory "$$errdir" already exists 1>&2; \
            ls -alF "$$errdir"; \
            exit 1; \
        }; \
        trap "rm -rf '$$errdir'" 0 1 2 3 4 5 6 7 8 10 12 13 14 15; \
        errs="$$errdir/errors"; \
        realerrs="$$errdir/realerrs"; \
        for time in first second third; do \
            echo === Running Lout for the $$time time; \
            $(LOUT) $(LTFLAGS) -o $@ $(LTFILE) 2>&1 | tee "$$errs" | \
                fgrep -v ': unresolved' | tee "$$realerrs"; \
            if [ -s "$$realerrs" ]; then exit 1; \
            elif [ ! -s "$$errs" ]; then break; fi \
        done; \
        if [ -s "$$errs" ]; then \
            echo === Unresolved cross references remain after $$time run; \
            cat "$$errs"; \
        fi;)

</makefile>

Some explanations:

o mkdir is necessary to prevent bad guys playing nasty tricks with
  symlinks from (world writable) /tmp to some of your precious files.
  (see excelent discussion in bugtraq mailing list).

o adjust list of trapped signals to your pleasure.  solaris /bin/sh
  refuses to trap SIGSEGV(11) (`bad trap').  SIGKILL(9) is
  uncatchable.

o adjust the number of times to run.  useful values are from 2 to 4.
  less than 2 is useless :-).  more than 4 is hardly necessary and if
  you have real undefined xrefs in your document the loop will run
  through all those iterations before giving up.  I believe that 3 is
  optimal.

o stderr from lout is captured to $errs.  all errors except unresolved
  xrefs are also captured to $realerrs.

o if $realerrs is not empty we have a real error so we exit immediately.

o if $errs is empty we are done and we break out of the loop.

o if there're some error messages you don't consider to be real errors
  the script can be modified to accomodate them:

  ...
  # file with patters for fgrep
  $pats="$errdir/patterns"

  # stuff it with `innocuous' error messages
  echo ': unresolved' > "$pats"
  echo 'scaled horizontally by factor' >> "$pats"
  ...

  # change the fgrep command
  ... | fgrep -v -f "$pats" | ...


o making this into `lc' lout compiler shell script is left as an
  exercise to the reader.


SY, Uwe
-- 
address@hidden                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen


reply via email to

[Prev in Thread] Current Thread [Next in Thread]