2 # Convert WEB programs not needing special treatment to C.
8 BASE is the root part of the file to be converted; it is extended with
9 .p to make the name of the (input) Pascal file, and extended with .c and
10 .h to make the name of the main (output) C files. Additional files
11 BASEini.c, BASEd.h, BASEcoerce.h are created for the larger programs.
15 while test $# -gt 0; do
17 -*) echo "$1?" >&2; echo "$usage" >&2; exit 1;;
18 *) if test -n "$basefile"; then
19 echo "$1?" >&2; echo "$usage" >&2; exit 1; fi
24 if test -z "$basefile"; then
25 echo "$0: missing base (Pascal) file argument." >&2
30 pascalfile
=$basefile.p
33 # This is for tangleboot if the build and source directories are different.
34 test -r $pascalfile || pascalfile
=$srcdir/$pascalfile
36 # We use cpascal.h by default instead of config.h because straight C
37 # routines can only be confused by the definitions for `chr', etc.
40 web2c_options
=-c$basefile
44 # This used to have various values to control the number of *tex[0-9].c files.
45 # We now avoid to split the C code for MF and all TeX-like engines.
46 splitup_options
="-i -l 65000"
49 output_files
="$cfile $basefile.h"
52 pbibtex|pdvitype|ppltotf|ptftopl
)
53 more_defines
="$srcdir/ptexdir/ptex.defines"
56 upbibtex|updvitype|uppltotf|uptftopl
)
57 more_defines
="$srcdir/uptexdir/uptex.defines"
58 hfile
=uptexdir
/kanji.h
63 bibtex|pbibtex|upbibtex
)
64 midcmd
="| sed -f $srcdir/web2c/cvtbib.sed"
67 mf|mflua|mfluajit|tex|aleph|etex|pdftex|ptex|eptex|euptex|uptex|xetex
)
70 more_defines
="$srcdir/web2c/texmf.defines $srcdir/web2c/mfmp.defines"
71 precmd
="| sed -f $srcdir/web2c/cvtmf1.sed"
72 web2c_options
="-m -c${basefile}coerce"
73 midcmd
="| sed -f $srcdir/web2c/cvtmf2.sed"
77 more_defines
="$srcdir/web2c/texmf.defines $srcdir/synctexdir/synctex.defines"
78 web2c_options
="-t -c${basefile}coerce"
82 prog_defines
="$srcdir/${basefile}dir/$basefile.defines"
83 if test -f $prog_defines; then
84 more_defines
="$more_defines $prog_defines"
87 postcmd
="| ./web2c/splitup $splitup_options $basefile"
88 cfile
=${basefile}0.c
# last output file, or thereabouts
90 output_files
="$basefile[0-9].c ${basefile}ini.c ${basefile}d.h \
97 eval "cat $srcdir/web2c/common.defines $more_defines $pascalfile \
99 | ./web2c/web2c -h$hfile $web2c_options \
101 | ./web2c/fixwrites $fixwrites_options $basefile \
105 # Using the above pipeline as the condition of an if does no good, since
106 # typical sh's use the status of the first command as the pipeline result.
107 # So check for an empty output file, or one with the error marker we put in.
108 if test ! -s $cfile ||
grep @error@
$output_files >/dev
/null
; then
110 # Don't just delete it, since it may be useful for debugging.
111 echo "$0: conversion of $pascalfile failed, moving dregs:" >&2
112 cmd
="mv $output_files $TMPDIR"
113 (cd $TMPDIR && rm -f $output_files)
120 bibtex|pbibtex|upbibtex
)
121 sed -e 's/(buftype)//g' -e 's/(pdstype)//g' <$basefile.h
>x
$basefile.h
122 mv x
$basefile.h
$basefile.h
124 mf|mflua|mfluajit|tex|aleph|etex|pdftex|ptex|eptex|euptex|uptex|xetex
)
125 sleep 2 # so timestamps are definitely later, to avoid make weirdness
126 cat $srcdir/web2c
/coerce.h
>>${basefile}coerce.h