summaryrefslogtreecommitdiff
path: root/info/examples/lgc2/runltx
blob: 873963956f7387d4119e305cf7ad04e511dd13f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash 
#
# $Id: runltx,v 1.13 2007/01/15 22:39:40 frank Exp $
#
#set -x

MPFILE="FOOBAR"
PARAM=
## Is string documentclass present in ltx file?
grep documentclass $1 >& /dev/null
if test $? = 1
then 
 # no "documentclass" present --> not LaTeX --> exit
 echo "$1 not runnable LaTeX"
 exit 0
fi

## If eps file already exists --> do nothing

F=`basename $1 .ltx`
if test -r $F.eps
then
  echo $F.eps already made
  exit
fi

## No EPS file yet --> run LaTeX

LATEX=latex
export TEXINPUTS=inputs:pstricks:
export HOMETEXMF=../../texmf:
export TEXMFHOME=../../texmf:

    echo "*************************** latex $F.ltx FIRST RUN "

$LATEX $F.ltx
if test $? -gt 0
  then
    echo "*************************** latex $F.ltx has ERRORS"
    exit 1
fi
                                                                         
# we need two runs for some PSTricks examples
    echo "*************************** latex $F.ltx SECOND RUN "

$LATEX $F.ltx
if test $? -gt 0
  then
    echo "*************************** latex $F.ltx has ERRORS"
    exit 1
fi
R=`grep ' Process ' $F.log` >& /dev/null
if test $? = 0
then
  # We have to deal with Metapost

  MFILE=`grep ' Process ' $F.log | tail -1 | awk '{print $3}'`

  MPFILE=`basename $MFILE .mp`
    echo "*************************** Metapost run $MFILE.mp "
  mpost $MPFILE
  if test $? -gt 0
  then
    echo "********************** Metapost $MPFILE.mp has ERRORS"
    exit 1
  fi
  $LATEX $F.ltx
  if test $? -gt 0
  then
    echo "*************************** latex $F.ltx has ERRORS"
    exit 1
  fi
else
  R=`grep "t forget to process" $F.log` >& /dev/null
  if test $? = 0
  then
    # We have to process Metafont of Metapost file for mfpic
    MFILE=`grep "t forget to process" $F.log | tail -1 | \
             awk '{print $6}' | sed 's/\!//'`
    R=`echo $MFILE | awk -F'.' '{print $2}'`
    if test "$R" = "mf"
    then
      MFFILE=`basename $MFILE .mf`
      mf "\\mode=ljfour; input $MFFILE"
      if test $? -gt 0
      then
	echo "********************** Metafont $MFFILE.mf has ERRORS"
	exit 1
      fi
    else # hopefully now "mp"
      MPFILE=`basename $MFILE .mp`
	echo "*************************** Metapost run $MFILE.mp "
      mpost $MPFILE
      if test $? -gt 0
      then
	echo "********************** Metapost $MPFILE.mp has ERRORS"
	exit 1
      fi
    fi
    $LATEX $F.ltx
    if test $? -gt 0
    then
      echo "*************************** latex $F.ltx has ERRORS"
      exit 1
    fi
    gftopk $MFFILE.600gf
    PARAM="-mode ljfour -D600"
  else
    R=`grep -i "musixtex" $F.log` >& /dev/null
    if test $? = 0
    then
      # We have to process musxitex file with musixflex
      PARAM="-mode ljfour -D600"
      musixflx $F
      $LATEX $F.ltx
      if test $? -gt 0
      then
        echo "*************************** latex $F.ltx has ERRORS"
        exit 1
      fi
    fi
  fi
fi 
#export KPATHSEA_DEBUG=32
dvips  -j0 -E $PARAM $F -o $F.eps
#
# we can't do subesetting in chapter two as long a "w.eps" is used
#
#      ^ no font subsetting with 0

./cleaneps $F.eps

# 
if test ! -s $F.eps
then
  rm $F.eps
  echo "*************************** eps file $F.eps has zero size"
  exit 1
fi
rm -f $F.dvi $F.aux $F.log $F.idx $MPFILE.* ftmp.mp  mfpicex.* $F.mx1 $F.mx2
rm -f LGCmatrix.dat