summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/ctangleboot-sh.in
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
committerKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
commitad547a6b5986815fda458221149728d9d9ab1d87 (patch)
tree16296910eb3eca724371474ea9aea3994dc69614 /Build/source/texk/web2c/ctangleboot-sh.in
parent947b43de3dd21d58ccc2ffadefc4441ea1c2a813 (diff)
restore Build,TODO from r57911
git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/ctangleboot-sh.in')
-rw-r--r--Build/source/texk/web2c/ctangleboot-sh.in80
1 files changed, 80 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/ctangleboot-sh.in b/Build/source/texk/web2c/ctangleboot-sh.in
new file mode 100644
index 00000000000..1cc839f058c
--- /dev/null
+++ b/Build/source/texk/web2c/ctangleboot-sh.in
@@ -0,0 +1,80 @@
+#! @SHELL@
+# ctangleboot-sh: shell script to invoke ctangleboot and if required
+# update c{tangle,web}boot.[ch]in from c{tangle,web}.[ch].
+# For details see tangle-sh.
+#
+# Copyright (C) 2009-2012 Peter Breitenlohner <tex-live@tug.org>
+#
+# This file is free software; the copyright holder
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+target=$1; shift
+base=$1
+case $base in
+ common) file=cweb; exts=c;;
+ ctangle) file=ctangle; exts=c;;
+ *) echo "Usage: $0 TARGET {common|ctangle} [CHANGEFILE]" >&2; exit 1;;
+esac
+
+TEXMFCNF=@srcdir@/../kpathsea; export TEXMFCNF
+CWEBINPUTS=@srcdir@/cwebdir; export CWEBINPUTS
+
+do_ctangleboot () {
+ echo timestamp >$stamp.tmp
+ if $AM_V_P; then
+ echo "@CTANGLEBOOT@ $@"
+ @CTANGLEBOOT@ "$@" || exit 1
+ else
+ echo " CTANGLE " $base
+ @CTANGLEBOOT@ "$@" >$base.out 2>&1; rc=$?
+ test $rc -eq 0 || { cat $base.out; exit $rc; }
+ rm -f $base.out
+ fi
+ mv -f $stamp.tmp $stamp
+}
+
+stamp=$base-ctangle
+case $target in
+ $stamp)
+ # Normal build.
+ rm -f $stamp.tmp
+ do_ctangleboot "$@"
+ ;;
+ *)
+ # Recover from removal of $target
+ test -f $target && exit 0
+ trap "rm -rf $stamp $stamp.lock" 1 2 13 15
+ if mkdir $stamp.lock 2>/dev/null; then
+ # Code executed by the first process.
+ rm -f $stamp $stamp.tmp
+ do_ctangleboot "$@"
+ rmdir $stamp.lock
+ else
+ # Code executed by the follower processes.
+ # Wait until the first process is done.
+ while test -d $stamp.lock; do sleep 1; done
+ # Succeed if and only if the first process succeeded.
+ test -f $stamp; exit $?
+ fi
+ ;;
+esac
+
+for ext in $exts; do
+ src=$file.$ext
+ dst=@srcdir@/${file}boot.${ext}in
+ sed -e 's,@srcdir@/cwebdir,cwebdir,' \
+ $src >$stamp.tmp
+ if cmp -s $stamp.tmp $dst; then
+ rm -f $stamp.tmp
+ else
+ if $AM_V_P; then
+ echo "Updating $src => $dst"
+ else
+ echo " UPD " ${file}boot.${ext}in
+ fi
+ mv -f $stamp.tmp $dst || exit 1
+ fi
+done
+
+exit 0