Makefile 7.69 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# this is <Makefile>
# ----------------------------------------------------------------------------
# Copyright (c) 2010 by Daniel Armbruster  
# ----
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. 
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ----
# Daniel Armbruster 2010/06/25
#
# REVISIONS and CHANGES 
# 25/06/2010		V1.0	Daniel Armbruster  
# 18/08/2010   	V1.1  translate help into english
# 02/07/2011		V1.2	complete update
25
# 31/01/2012    V1.3  ajusted for csback
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
# 
# 

all: pdf
default: ps

###########################################
# Your settings.
############################################
MAIN=manual
IMGDIR=img
#PDFIMAGES=$(addsuffix .pdf, $(basename $(wildcard $(IMGDIR)/*)))
#EPSIMAGES=$(addsuffix .eps, $(basename $(wildcard $(IMGDIR)/*)))
TABLEDIR=tab
TABLES= 

# =============================================================================
LATEX=/usr/bin/latex
PDFLATEX=/usr/bin/pdflatex
LATEXFLAGS=-interaction=nonstopmode
PS2PDFFLAGS=-dAutoRotatePages=true
GSCHEM=/usr/bin/gschem
CONVERT=/usr/bin/convert
ZIP=/usr/bin/zip -r
TAR=tar -zvcf
ECHO=echo
DVIPSOPTS= 
BIBTEX=bibtex
FEATURES=index abbr bib
DEL=rm -rvf

TEXFILES = $(wildcard *.tex)
PICS = $(wildcard ./$(IMGDIR)/*)

60
61
62
63
64
65
66
67
68
CSBACKTOOLS=csback2cron.py csbackgen.py csbackchk.py csbackntfy.py

CSBACKHELPS=$(addsuffix .help,$(basename $(CSBACKTOOLS)))

$(CSBACKHELPS): %.help: 
	/bin/bash -c "chmod +x ../$(addsuffix .py,$(basename $@))"
	/bin/bash -c "./../$(addsuffix .py,$(basename $@)) -h 2>&1" > $@  
 

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# =============================================================================
.PHONY: clean
clean: ; 
	-/bin/rm -vf $(MAIN).pdf
	-/bin/rm -vf $(MAIN).ps
	-find . -name \*.eps | xargs --no-run-if-empty /bin/rm -vf
	-find . -name \*.toc | xargs --no-run-if-empty /bin/rm -vf
	-find . -name \*.log | xargs --no-run-if-empty /bin/rm -vf
	-find . -name \*.lof | xargs --no-run-if-empty /bin/rm -vf
	-find . -name \*.lot | xargs --no-run-if-empty /bin/rm -vf
	-find . -name \*.aux | xargs --no-run-if-empty /bin/rm -vf
	-find . -name \*.dvi | xargs --no-run-if-empty /bin/rm -vf
	-find . -name \*.nav | xargs --no-run-if-empty /bin/rm -vf
	-find . -name \*.snm | xargs --no-run-if-empty /bin/rm -vf
	-find . -name \*.out | xargs --no-run-if-empty /bin/rm -vf
84
	-find . -name \*.help | xargs --no-run-if-empty /bin/rm -vf
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
143
144
145
146
147
148
149
150
151
152
153
154

# =============================================================================
# pattern rules
# =============================================================================

.SUFFIXES:
.SUFFIXES: .pdf .tex .ps .dvi .png .gif .bmp .jpg .eps .fig .csv .sch .svg .gpt

.tex.pdf:
	$(PDFLATEX) $(LATEXFLAGS) $<
	$(PDFLATEX) $(LATEXFLAGS) $<
	$(PDFLATEX) $(LATEXFLAGS) $<
.tex.dvi:
	$(LATEX) $(LATEXFLAGS) $<
	$(LATEX) $(LATEXFLAGS) $<
	$(LATEX) $(LATEXFLAGS) $<
.dvi.ps:
	dvips $(DVIPSOPTS) $<
.bmp.png:
	$(CONVERT) $< $@
.eps.png:
	$(CONVERT) $< $@
.jpg.png:
	$(CONVERT) $< $@
.gif.png:
	$(CONVERT) $< $@
.jpg.eps:
	$(CONVERT) $< $@
.svg.eps:
	inkscape $< --export-eps=$@
.gif.eps:
	$(CONVERT) $< $@
.fig.eps:
	fig2dev -L eps $< $@
.bmp.eps:
	$(CONVERT) $< $@
.png.eps:
	$(CONVERT) $< $@
.ps.eps:
	ps2eps -f $< 
.eps.pdf:
	epstopdf $< 
.svg.pdf:
	inkscape $< --export-pdf=$@
.ps.pdf:
	ps2pdf $(PS2PDFFLAGS) $< $@
.fig.pdf:
	fig2dev -L eps $< $@.eps
	epstopdf $@.eps -o=$@
	rm $@.eps
.gpt.ps:
	gnuplot $<
.sch.ps:
	$(GSCHEM) -q -s /usr/share/gEDA/scheme/print.scm -o $(notdir $@) $<
.csv.tex:
	cat $< | sed "s/;/\t\&\t/g"|sed 's/$$/\t\\\\/g'|sed 's/\"//g' > $@


# =============================================================================
# pdflatex, latex

pdfimages: $(PDFIMAGES) 
	mkdir -p $(IMGDIR)
	cd $(IMGDIR)
	$(MAKE) $<
epsimages: $(EPSIMAGES) 
	mkdir -p $(IMGDIR)
	cd $(IMGDIR)
	$(MAKE) $<

155

156
ifdef PDFIMAGES 
157
pdf: pdfimages $(CSBACKHELPS)
158
159
160
	rm -f $(MAIN).pdf
	$(MAKE) $(MAIN).pdf
else
161
pdf: $(CSBACKHELPS)
162
163
164
165
166
	rm -f $(MAIN).pdf
	$(MAKE) $(MAIN).pdf
endif

ifdef EPSIMAGES
167
dvi: epsimages $(CSBACKHELPS) 
168
169
	$(MAKE) $(MAIN).dvi
else
170
dvi: $(CSBACKHELPS) 
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
	$(MAKE) $(MAIN).dvi
endif


ps: dvi
	rm -f $(MAIN).ps
	$(MAKE) $(MAIN).ps

# =============================================================================
# bibliography, index, and list of abbreviations
index: $(MAIN).ind $(MAIN).ilg
abbr: $(MAIN).nls
bib: $(MAIN).blg $(MAIN).bbl

# preparation
$(MAIN).idx $(MAIN).nlo $(MAIN).aux: $(MAIN).tex
	$(LATEX) $(LATEXFLAGS) $(MAIN).tex
				 
# index (rule: index)
$(MAIN).ind $(MAIN).ilg: $(MAIN).tex $(MAIN).idx
	$(MAKEINDEX) $(MAIN).idx

# list of abbreviations (rule: abbr)
$(MAIN).nls: $(MAIN).tex $(MAIN).nlo
	$(MAKEINDEX) $(MAIN).nlo -s nomencl.ist -o $(MAIN).nls

# bibliography (rule: bib)
$(MAIN).blg $(MAIN).bbl: $(MAIN).tex $(MAIN).bib $(MAIN).aux
	$(BIBTEX) $(MAIN)

# =============================================================================
# archiv
ARCHIVFILES = $(TEXFILES) $(PICS) 
ARCHIVFILES += [mM]akefile

tararchiv: $(MAIN).tar.gz
$(MAIN).tar.gz: $(ARCHIVFILES)
	$(TAR) $(MAIN).tar.gz $(ARCHIVFILES)
ziparchiv: $(MAIN).zip
$(MAIN).zip: $(ARCHIVFILES)
	$(ZIP) $(MAIN).zip $(ARCHIVFILES)

# =============================================================================
# show
pdfshow: pdf
	@xpdf $(MAIN).pdf &

psshow: ps
	@gv $(MAIN).ps &

# =============================================================================
# table
table: $(TABLES)
	mkdir -p $(TABLEDIR)
	cd $(TABLEDIR)
	$(MAKE) -f ../[mM]akefile $<

# =============================================================================
# help
help:
	@$(ECHO) "*************************************************************"
	@$(ECHO) "                 Makefile - LaTeX"
	@$(ECHO)	"author:    Daniel Armbruster"
	@$(ECHO) "email:     dani.armbruster@gmx.de"
	@$(ECHO) "created:   12.12.09"
	@$(ECHO) "modified:  17.12.09"
	@$(ECHO) "*************************************************************"
	@$(ECHO) "-------------------------------------------------------------" 
	@$(ECHO) "Help - for this Makefile"
	@$(ECHO) "-------------------------------------------------------------" 
	@$(ECHO) "pdf:          create a *.pdf document"
	@$(ECHO) "tararchiv:    create a *.tar archive"
	@$(ECHO) "ziparchiv:    create a *.zip archive"
	@$(ECHO) "pdfshow:      show the *.pdf document with xpdf"
	@$(ECHO) "psshow:       show the *.ps document with evince"
	@$(ECHO) "table:        convert tables -> *.csv to *.tex"
	@$(ECHO) "clean:        delete all temporary files"
	@$(ECHO) "help:         print this help"
	@$(ECHO) 
	@$(ECHO) "-------------------------------------------------------------" 
	@$(ECHO) "Info:"
	@$(ECHO) "-------------------------------------------------------------" 
	@$(ECHO) "main file: $(MAIN).tex"
	@$(ECHO) "lastly used pics: $(PDFIMAGES)" 
	@$(ECHO) "lastly converted tables: $(TABLES)"
	@$(ECHO)
	@$(ECHO) "-------------------------------------------------------------" 
	@$(ECHO) "Notices:"
	@$(ECHO) "-------------------------------------------------------------"
	@$(ECHO) "1. give the names of the images in the *.tex file without    "
	@$(ECHO) "   any file endings                                          "
	@$(ECHO) "2. declare images with file ending in this Makefile          "  
	@$(ECHO) "3. tables must contain as delimiter the ';' token and as     " 
	@$(ECHO) "   text-delimiter a '\"' token."
	@$(ECHO) 

# ----- END OF Makefile -----