Mercurial > ~dholland > hg > ag > index.cgi
comparison doc/manual/buildchapter.sh @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 #!/bin/sh | |
2 # buildchapter.sh - build just one chapter of the AG manual | |
3 # usage: path-to-doc/manual/buildchapter.sh filename | |
4 # | |
5 # The build happens in a subdirectory so as not to leave turds behind | |
6 # that might confuse the main build. | |
7 # | |
8 # The filename should not have a path on it. | |
9 # | |
10 | |
11 if [ $# != 1 ]; then | |
12 echo "Usage: $0 filename" 1>&2 | |
13 exit 1 | |
14 fi | |
15 | |
16 case "$1" in | |
17 /*) echo "$0: filename given with path" 1>&2; exit 1;; | |
18 *.tex) ;; | |
19 *) echo "$0: not a tex file?" 1>&2; exit 1;; | |
20 esac | |
21 | |
22 TMPDIR=.pdftmp.$$ | |
23 SRCDIR=`dirname "$0"` | |
24 INPUT="$1" | |
25 INPUTBASE=`echo "$INPUT" | sed 's/\.tex$//'` | |
26 OUTPUT="$INPUTBASE.pdf" | |
27 | |
28 case "$SRCDIR" in | |
29 /*) ;; | |
30 *) SRCDIR="../$SRCDIR";; | |
31 esac | |
32 | |
33 echo ' [MKDIR] '"$TMPDIR" | |
34 mkdir "$TMPDIR" || exit 1 | |
35 cd "$TMPDIR" | |
36 | |
37 clean() { | |
38 cd .. | |
39 echo ' [RM] '"$TMPDIR" | |
40 rm -rf "$TMPDIR" | |
41 } | |
42 trap clean 0 HUP INT TERM | |
43 | |
44 TEXINPUTS=".:${SRCDIR}:" | |
45 export TEXINPUTS | |
46 | |
47 for F in agdefs.tex "$INPUT"; do | |
48 echo ' [CP] '"$F" | |
49 cp "$SRCDIR/$F" . || exit 1 | |
50 done | |
51 | |
52 echo ' [CREATE] tmp.tex' | |
53 ( | |
54 echo '\documentclass{book}' | |
55 echo '\include{agdefs}' | |
56 echo '\begin{document}' | |
57 echo '\include{'"$INPUTBASE"'}' | |
58 echo '\end{document}' | |
59 ) > tmp.tex | |
60 | |
61 echo ' [LATEX] tmp.tex' | |
62 #pdflatex tmp.tex || exit 1 | |
63 pdflatex "\\newcommand{\\nohtml}{1}\\input{tmp.tex}" | |
64 | |
65 | |
66 echo ' [MV] '"$OUTPUT" | |
67 mv -f tmp.pdf ../"$OUTPUT" | |
68 | |
69 # handled by clean() | |
70 #cd .. | |
71 #rm -rf $TMPDIR | |
72 exit 0 | |
73 |