summaryrefslogtreecommitdiff
path: root/support/make_latex/make_latex
blob: a646c525f0826c01a169524a541617c74124f6fc (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
# make_latex
# - A file to be included to enable make(1) to process LaTeX files.
# Suitable for single-part documents with BibTeX references and diagrams.
# David Beasley,  <David.Beasley@cm.cf.ac.uk>, December 1992
# Department of Computing Mathematics, Univeristy of Wales College of Cardiff.
# Last Update: 13/10/93
#
# Note on commands:
# 'make doc1.dvi' - creates dvi file if make thinks that something has changed.
# 'make doc1' - also creates dvi file, unconditionally (useful if you havent
#		specified _all_ the things it depends on)
#
# Refer to man entry for make(1) for explanation of syntax and command options

.KEEP_STATE:

# ---- The following shows the type of entries required in each Makefile ----

# include $(HOME)/lib/make_latex
# # Name(s) of LaTeX document file(s) (without suffixes)
# # eg.
# FILES = doc1 doc2
#
# # List here dependencies of documents on other files (eg diagrams 
# # from .gnu files) eg.
# doc1.dvi : fig1.ps fig2.ps fig3.ps
# doc2.dvi : diag1.ps diag2.ps
#
# # Names of additional files to be deleted by TIDY and CLEAN commands
# TIDYFILES = x
# CLEANFILES = y

# --------------- The following defaults may be user-configured --------------

# Default name(s) of BibTeX source files, eg.
BIBFILES = $(HOME)/Refs/myrefs.bib

# default printer resolution
PRINT_RES = 300

# Switch over resolution between lo and hi res devices
PR_RES_BOUNDARY = 400

# default printer names
PRINTER = lw0		# for output below $(PR_RES_BOUNDARY)
PR_HI_RES = lwpro	# for output >= $(PR_RES_BOUNDARY)

# name of print command
LPR = lpr

# options given to lpr command - delete after printing by default
PR_OPT = -r

# Pattern(s) to match for old versions of files to be deleted by 'make clean'
OLDVERSIONS = *%

# -------------- Lines below here shouldnt need changing -----------------

# default page range to print
PAGE_F = -999999
PAGE_T = 999999

# name of BibTeX command
BIBTEX = bibtex

# name of LaTeX command
LATEX = latex

# names of all DVI files
DVIFILES = $(FILES:%=%.dvi) 

# assume that all dvi files named depend on all bib files named
$(FILES:%=%.bbl) : $(BIBFILES)


# -------------- generic target names ----------------

# create all dvi files
all: $(DVIFILES)

#create all postscript files
allps: $(FILES:%=%.ps)

# print all files
allpr: $(FILES:%=%.pr)

# delete all files which can easily be regenerated
tidy:
	-rm -f $(DVIFILES) $(TIDYFILES)
	-rm -f $(FILES:%=%.ps) $(FILES:%=%.log) $(FILES:%=%.blg)

# delete all files which can be regenerated
clean:	tidy
	-rm -f $(FILES:%=%.aux) $(FILES:%=%.bbl) $(CLEANFILES)
	@# delete editor old-version files
	-rm -f $(OLDVERSIONS)

# -------------- pattern matching rules --------------

# ensure that the bbl file gets regenerated if the bib file is changed
%.bbl : $(BIBFILES)
	@# if there is no aux file, skip this, it will get done later
	-@if [ -r $*.aux ] ;\
	then $(BIBTEX) $* ; \
	     fi

# create a dvi file from a tex file
% %.dvi: %.tex
	$(LATEX) $*
	-@egrep -c 'Citation .* undefined.' $*.log && ($(BIBTEX) $*;$(LATEX) $*)
	-@grep 'Rerun to get cross-references right' $*.log && $(LATEX) $*

# create postscript file of a dvi file
%.ps: %.dvi
	@if [ $(PAGE_F) -lt -999998 ] ;\
	then 	echo dvips -D $(PRINT_RES) -l $(PAGE_T) -o $@ $* ;\
		dvips -D $(PRINT_RES) -l $(PAGE_T) -o $@ $* ;\
	else	echo dvips -D $(PRINT_RES) -p $(PAGE_F) -l $(PAGE_T) -o $@ $* ;\
		dvips -D $(PRINT_RES) -p $(PAGE_F) -l $(PAGE_T) -o $@ $* ;\
	fi

# create postscript file of a gnu plot
%.ps: %.gnu
	gnuplot $<

# create a latex picture file from an xfig file
%.pic: %.fig
	fig2dev -L latex $< $@

# create a postscript file from an xfig file
%.ps: %.fig
	fig2dev -L ps $< $@

# send a postcript file to be laser printed
%.pr: %.ps
	@if [ $(PRINT_RES) -lt $(PR_RES_BOUNDARY) ] ;\
	then echo $(LPR) $(PR_OPT) -P$(PRINTER) $< ;\
		  $(LPR) $(PR_OPT) -P$(PRINTER) $< ;\
	else echo $(LPR) $(PR_OPT) -P$(PR_HI_RES) $< ;\
		  $(LPR) $(PR_OPT) -P$(PR_HI_RES) $< ;\
	fi