2 # ctangleboot-sh: shell script to invoke ctangleboot and if required
3 # update c{tangle,web}boot.[ch]in from c{tangle,web}.[ch].
4 # For details see tangle-sh.
6 # Copyright (C) 2009-2012 Peter Breitenlohner <tex-live@tug.org>
8 # This file is free software; the copyright holder
9 # gives unlimited permission to copy and/or distribute it,
10 # with or without modifications, as long as this notice is preserved.
15 common) file=cweb; exts='c h';;
16 ctangle) file=ctangle; exts=c;;
17 *) echo "Usage: $0 TARGET {common|ctangle} [CHANGEFILE]" >&2; exit 1;;
20 TEXMFCNF=@srcdir@/../kpathsea; export TEXMFCNF
21 CWEBINPUTS=@srcdir@/cwebdir; export CWEBINPUTS
24 echo timestamp >$stamp.tmp
26 echo "@CTANGLEBOOT@ $@"
27 @CTANGLEBOOT@ "$@" || exit 1
29 echo " CTANGLE " $base
30 @CTANGLEBOOT@ "$@" >$base.out 2>&1; rc=$?
31 test $rc -eq 0 || { cat $base.out; exit $rc; }
34 mv -f $stamp.tmp $stamp
45 # Recover from removal of $target
46 test -f $target && exit 0
47 trap "rm -rf $stamp $stamp.lock" 1 2 13 15
48 if mkdir $stamp.lock 2>/dev/null; then
49 # Code executed by the first process.
50 rm -f $stamp $stamp.tmp
54 # Code executed by the follower processes.
55 # Wait until the first process is done.
56 while test -d $stamp.lock; do sleep 1; done
57 # Succeed if and only if the first process succeeded.
58 test -f $stamp; exit $?
65 dst=@srcdir@/${file}boot.${ext}in
66 sed -e 's,@srcdir@/cwebdir,cwebdir,' \
67 -e 's,^#include "cweb.h",#include "cwebboot.h",' \
69 if cmp -s $stamp.tmp $dst; then
73 echo "Updating $src => $dst"
75 echo " UPD " ${file}boot.${ext}in
77 mv -f $stamp.tmp $dst || exit 1