1#!/bin/sh
2# Make links named `lcircle10' for all TFM and GF/PK files, if no
3# lcircle10 files already exist.
4
5# Don't override definition of prefix and/or libdir if they are
6# already defined in the environment. 
7if test "z${prefix}" = "z" ; then
8  prefix=/usr/local
9else
10  # prefix may contain references to other variables, thanks to make.
11  eval prefix=\""${prefix}"\"
12fi
13
14if test "z${libdir}" = "z" ; then
15  libdir="${prefix}/lib/tex"
16else
17  # libdir may contain references to other variables, thanks to make.
18  eval libdir=\""${libdir}"\"
19fi
20
21texlibdir="${libdir}"
22texfontdir="${texlibdir}/fonts"
23
24# Directories for the different font formats, in case they're not all
25# stored in one place.
26textfmdir="${textfmdir-${texfontdir}}"
27texpkdir="${texpkdir-${texfontdir}}"
28texgfdir="${texgfdir-${texfontdir}}"
29
30test "z${TMPDIR}" = "z" && TMPDIR="/tmp"
31
32tempfile="${TMPDIR}/circ$$"
33tempfile2="${TMPDIR}/circ2$$"
34
35# EXIT SIGHUP SIGINT SIGQUIT SIGTERM
36#trap 'rm -f "${tempfile}" "${tempfile2}"' 0 1 2 3 15
37
38# Find all the fonts with names that include `circle'.
39(cd "${texfontdir}"; find . -name '*circle*' -print > "${tempfile}")
40
41# If they have lcircle10.tfm, assume everything is there, and quit.
42if grep 'lcircle10\.tfm' "${tempfile}" > /dev/null 2>&1 ; then
43  echo "Found lcircle10.tfm."
44  exit 0
45fi
46
47# No TFM file for lcircle.  Make a link to circle10.tfm if it exists,
48# and then make a link to the bitmap files.
49grep 'circle10\.tfm' "${tempfile}" > "${tempfile2}" \
50 || {
51  echo "I can't find any circle fonts in ${texfontdir}.
52If it isn't installed somewhere else, you need to get the Metafont sources
53from somewhere, e.g., labrea.stanford.edu:pub/tex/latex/circle10.mf, and
54run Metafont on them."
55  exit 1
56 }
57
58# We have circle10.tfm.  (If we have it more than once, take the first
59# one.)  Make the link.
60tempfile2_line1="`sed -ne '1p;q' \"${tempfile2}\"`"
61ln "${tempfile2_line1}" "${textfmdir}/lcircle10.tfm"
62echo "Linked to ${tempfile2_line1}."
63
64# Now make a link for the PK files, if any.
65(cd "${texpkdir}"
66 for f in `grep 'circle10.*pk' "${tempfile}"` ; do
67    set - `echo "$f" \
68            | sed -ne '/\//!s/^/.\//;s/\(.*\)\/\([^\/][^\/]*\)$/\1 \2/;p'`
69    ln "$f" "${1}/l${2}"
70    echo "Linked to $f."
71 done
72)
73
74# And finally for the GF files.
75(cd "${texgfdir}"
76 for f in `grep 'circle10.*gf' "${tempfile}"` ; do
77    set - `echo "$f" \
78            | sed -ne '/\//!s/^/.\//;s/\(.*\)\/\([^\/][^\/]*\)$/\1 \2/;p'`
79    ln "$f" "${1}/l${2}"
80    echo "Linked to $f."
81 done
82)
83
84# eof
85