2 # web2c-sh: shell script to invoke ${srcdir}/web2c/convert.
4 # Copyright (C) 2009-2014 Peter Breitenlohner <tex-live@tug.org>
6 # This file is free software; the copyright holder
7 # gives unlimited permission to copy and/or distribute it,
8 # with or without modifications, as long as this notice is preserved.
10 # Convert creates several files, e.g., FOO.c and FOO.h from FOO.p.
12 # FOO.c FOO.h: FOO.p $(web2c_depend)
13 # srcdir=$(srcdir) $(SHELL) $(srcdir)/web2c/convert FOO
14 # could run 'convert FOO' twice in parallel and fail. To avoid this
15 # and yet recover from removal of FOO.c and/or FOO.h, we use an auxiliary
16 # stamp file FOO-web2c and the two rules
17 # FOO.c FOO.h: FOO-web2c
18 # $(SHELL) ./web2c-sh $@ FOO
19 # FOO-web2c: FOO.p $(web2c_depend)
20 # $(SHELL) ./web2c-sh $@ FOO
21 # Compare Automake manual (info Automake) 27.9: Multiple Outputs
23 srcdir=@srcdir@; export srcdir
28 echo timestamp >$stamp.tmp
30 echo "@SHELL@ $srcdir/web2c/convert $base"
31 @SHELL@ $srcdir/web2c/convert $base || exit 1
34 @SHELL@ $srcdir/web2c/convert $base >$base.out 2>&1; rc=$?
35 test $rc -eq 0 || { cat $base.out; exit $rc; }
38 mv -f $stamp.tmp $stamp
49 # Recover from removal of $target
50 test -f $target && exit 0
51 trap "rm -rf $stamp $stamp.lock" 1 2 13 15
52 if mkdir $stamp.lock 2>/dev/null; then
53 # Code executed by the first process.
54 rm -f $stamp $stamp.tmp
58 # Code executed by the follower processes.
59 # Wait until the first process is done.
60 while test -d $stamp.lock; do sleep 1; done
61 # Succeed if and only if the first process succeeded.
62 test -f $stamp; exit $?