summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/examples/Makefile
blob: 5cad778d9142c8aa9bbcc1b2bfc31927c20352b0 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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
269
# Examples Makefile
#
# Type "make" to generate examples.pdf containing many examples.
# Type "make clean; make examples.ps" to invoke latex intead of pdflatex.
# Type "make <diag>.ps" to make a postscript file from <diag>.m4
#  It may be necessary to type "make clean" before this or any of the following:
# Type "make <diag>.eps" to make an .eps file from <diag>.m4
#   The following require ImageMagick convert:
# Type "make <diag>.png" to make a .png file from <diag>.m4
# Type "make <diag>.tif" to make a .tif file from <diag>.m4
# Type "make <diag>.svg" to make a .svg file from <diag>.m4
#       See also: the svg subdirectory for generating svg directly.
#
# To test the file test.m4, type "make tst" if boxdims is used, otherwise
# type "make tst1".  In either case the file tst.ps is created.
#
# To debug a single diagram in a directory other than this examples
# directory, copy this makefile and tst.tex to where you want to work,
# redefine LIBDIR (below) appropriately, and type "make <diag>.xxx"
# where xxx is one of ps, eps, png, or pdf

#########################################################################

# Circuit_macro directory, change this if necessary:
# LIBDIR = $$HOME/lib
LIBDIR = ..

# The dpic processor:
PIC = dpic -p
#PIC = $$HOME/dpic/bu*/p2c/ftp/dpic -p
#PIC = /cygdrive/d/Dwight/dpic/p2c/Windows/dpic -p
#PIC = dpic -1 -p
#PIC = $$HOME/dpic/build/test/dpic -p
#PIC = $$HOME/tmp/dpic -p

CONFIGFILE = pstricks.m4

# This is for testing the mingw version of dpic:
#CUSTOM=windows.m4

# Uncomment for gpic.  Use gpic or pic as applicable on your machine:
# PIC = gpic -t
# PIC = pic -t
# CONFIGFILE = gpic.m4

# Convert options
EPSOPTS =
PNGOPTS = -density 400 -scale 25% -alpha Remove

# M4 = m4 -B32000
# M4 = m4 -I $(LIBDIR)
# If environment variable M4PATH has been set to the installation directory:
M4 = m4

#########################################################################

DOC = examples
PICS = \
  Adder.tex Alogix.tex ABlogix.tex AmpTable.tex Antennas.tex Audio.tex \
  Bip.tex Btree.tex Byte.tex Buttons.tex \
  CanLogic.tex CctTable.tex Conn.tex Counting.tex Crossbar.tex Crow.tex \
  Csource.tex \
  Decoder.tex Demultiplexer.tex Diodes.tex Drive.tex \
  Emarrows.tex Flow.tex Fuses.tex Grounds.tex \
  Headers.tex Heathkit.tex \
  I2L.tex Incleps.tex Jack.tex \
  Logic.tex Loglog.tex MC.tex Mixer.tex MotorControl.tex Multiplexer.tex \
  NLG.tex NPDT.tex Nport.tex \
  Opamp.tex Optoiso.tex Pconn.tex PushPull.tex \
  Quantum.tex Rectifiers.tex Relay.tex Rotbox.tex \
  Schottky.tex ShiftR.tex Sierpinski.tex Sixpole.tex Sources.tex SQUID.tex \
  Switches.tex \
  TTLnand.tex Tgate.tex Three.tex Timer.tex Ttree.tex \
  Variable.tex Windings.tex Xform.tex \
  control.tex csc.tex diamond.tex \
  ex00.tex ex01.tex ex02.tex ex03.tex ex04.tex ex05.tex ex06.tex \
  ex08.tex ex09.tex ex10.tex ex11.tex ex12.tex ex15.tex \
  ex16.tex ex17.tex ex18.tex ex21.tex exp.tex fet.tex \
  graysurf.tex lcct.tex pwrsupply.tex quick.tex \
  random.tex recycle.tex rose.tex \
  sfg.tex shapes.tex thyristor.tex ujt.tex worm.tex XOR.tex

# From the doc directory:
MANFIGS = AmpTable Antennas Audio Bip CctTable Conn Demultiplexer Diodes \
  Emarrows Fuses \
  Grounds Headers Jack Logic Multiplexer NLG NPDT Nport Opamp Pconn \
  Relay ShiftR Sources Switches \
  Tgate Variable Windings Xform fet quick thyristor ujt

# Files that have to be processed twice:
BOXDIMS = ex09 Crow Incleps Loglog Opamp random Ttree Windings

DVIPSOPTS = -Ppdf -G0 -t letter
M4LIBS = $(CONFIGFILE) $(CUSTOM)
DIMFILE = $(DOC).dim
BS = tr '|' '\134'

# Might be needed (change latex commands to $(LTX) )
# LTX = latex --shell-escape

.SUFFIXES: .ps .dvi .tex .m4 .pic .eps .png .pdf .svg .tif .gif
.dvi.ps:
	dvips $(DVIPSOPTS) $* -o $*.ps
	chmod 644 $*.ps
.m4.tex:
	@if test -n "$(DIMFILE)" ; then touch $(DIMFILE) ; fi ; touch F_$*.dim
	$(M4) $(M4LIBS) $(DIMFILE) F_$*.dim $*.m4 | sed -e '/^ *$$/d' > $*.pic
	$(PIC) $*.pic > $*.tex
#	grep Production dpic.log >> newp.txt
.m4.pic:
	@if test -n "$(DIMFILE)" ; then touch $(DIMFILE) ; fi
	$(M4) $(M4LIBS) $(DIMFILE) $*.m4 > $*.pic
.m4.dvi:
	make $*.tex
	printf "|documentclass[11pt]{article}\n\
|usepackage{times,pstricks,boxdims,graphicx,pst-grad,pst-slpe}\n\
|usepackage[amssymb,Gray,thinqspace,textstyle]{SIunits}\n\
|setlength{|textwidth}{28cm}|setlength{|textheight}{28cm}\n\
|setlength{|oddsidemargin}{0pt}|setlength{|evensidemargin}{0pt}\n\
|setlength{|hoffset}{-1cm}\n\
|pagestyle{empty}|thispagestyle{empty}\n\
|newbox|graph\n\
|begin{document}\n\
|noindent|input{"$*".tex}\n\
|end{document}\n" | $(BS) > F_$*.tex
	latex F_$*
	touch F_$*.dim $(DIMFILE) ; rm -f $*.tex $*.pic ; make $*.tex 
	latex F_$*
	touch F_$*.dim $(DIMFILE) ; rm -f $*.tex $*.pic ; make $*.tex 
	latex F_$*
.m4.eps:
	make $*.dvi
	dvips -Ppdf F_$* -T128cm,28cm -o $*.ps
# Recent changes to PSTricks(?) have clashed with the use of TeXtoEPS
#  so use ps2epsi
	ps2epsi $*.ps $*.epsi
	sed -e '/%%Pages:/d' -e '/BeginPreview/,$$d' $*.epsi \
     | tr '\015' '\012' > $*.eps
	sed -e '1,/EndPreview/d' $*.epsi >> $*.eps
.m4.ps:
	make $*.tex && mv $*.tex test.tex; latex tst
	rm -f test.tex $*.pic
	if test -f tst.dim ; then cp tst.dim F_$*.dim ; fi
	make $*.tex && mv $*.tex test.tex; latex tst
	dvips $(DVIPSOPTS) tst -o $*.ps
	chmod 644 $*.ps
.m4.svg:
	make $*.eps
	convert $(EPSOPTS) $*.eps $*.svg
.m4.png:
	make $*.eps
	convert $(PNGOPTS) $*.eps $*.png
	@if test -f $*.png.0 ; then mv $*.png.0 $*.png ; fi
.m4.gif:
	make $*.ps
	convert $(GIFOPTS) $*.ps $*.gif
#	@if test -f $*.png.0 ; then mv $*.png.0 $*.png ; fi
.m4.tif:
	make $*.eps
	convert $(EPSOPTS) $*.eps $*.tif
	@if test -f $*.tif.0 ; then mv $*.tif.0 $*.tif ; fi
.m4.pdf:
	touch F_$*.dim
	$(M4) pgf.m4 F_$*.dim $*.m4 > $*.pic
	dpic -g $*.pic > test.tex
	sed -e '/^\\usepackage.*graphicx/s/^.*$$/\\usepackage{tikz}/' \
     -e '/pstricks/d' tst.tex > F_$*.tex
	pdflatex F_$*
	$(M4) pgf.m4 F_$*.dim $*.m4 > $*.pic
	dpic -g $*.pic > test.tex
	pdflatex F_$*
	mv F_$*.pdf $*.pdf

#########################################################################

$(DOC).pdf: clean pdfmode $(DOC).frp
	touch $(DOC).dim
	for file in $(BOXDIMS) ; do \
      rm -f $$file.tex $$file.pic ; \
      make PIC="dpic -g" CONFIGFILE=pgf.m4 DIMFILE=$(DOC).dim $${file}.tex ; \
      done
	pdflatex $(DOC)
	for file in $(BOXDIMS) ; do \
      rm -f $$file.tex $$file.pic ; \
      make PIC="dpic -g" CONFIGFILE=pgf.m4 DIMFILE=$(DOC).dim $${file}.tex ; \
      done
	pdflatex $(DOC)

$(DOC).ps: psmode $(DOC).dvi

psmode:
	printf "|usepackage{pstricks,pst-grad}\n" | $(BS) > mode.tex

pdfmode:
	printf "|usepackage{tikz}\n" | $(BS) > mode.tex

doclinks:
	-for nm in $(MANFIGS) ; do cp $(LIBDIR)/doc/$$nm.m4 . ; done
	touch doclinks

$(DOC).dvi: $(DOC).frs
	touch $(DOC).dim
	for file in $(BOXDIMS) ; do \
      rm -f $$file.tex $$file.pic ; \
      make PIC="$(PIC)" DIMFILE=$(DOC).dim $${file}.tex ; done
	latex $(DOC)
	for file in $(BOXDIMS) ; do \
      rm -f $$file.tex $$file.pic ; \
      make PIC="$(PIC)" DIMFILE=$(DOC).dim $${file}.tex ; done
	latex $(DOC)

$(DOC).frs: doclinks $(DOC).tex files.tex header.tex psmode
	make $(PICS)
	cp $(LIBDIR)/doc/Version.tex .
	latex $(DOC)
	touch $(DOC).frs
	rm -f $(DOC).dvi

$(DOC).frp: doclinks $(DOC).tex files.tex header.tex pdfmode
	make CONFIGFILE=pgf.m4 PIC="dpic -g" $(PICS)
	cp $(LIBDIR)/doc/Version.tex .
	pdflatex $(DOC)
	rm -f $(DOC).pdf
	touch $(DOC).frp

tst:
	make test.tex; latex tst; rm -f test.tex test.pic
	make DIMFILE=tst.dim test.tex; latex tst
	dvips $(DVIPSOPTS) tst -o tst.ps

tst1: test.tex tst.tex
	latex tst
	dvips $(DVIPSOPTS) tst -o tst.ps

gtst:
	touch test.m4; make PIC="gpic -t" CONFIGFILE="" tst

gtst1:
	touch test.m4; make PIC="gpic -t" CONFIGFILE="" tst1

echopics:
	@echo $(PICS)

clobber:	clean
	rm -f *.ps
	-@for dir in mf mpost pdflatex xfig psfrag pgf svg dev test; \
      do (if test -d $$dir ; then cd $$dir; make clobber; fi) ; done
	rm -f *.warn quick.m4
	rm -rf index.html html basenames *.png* dist zips htmlfiles svgfiles
	rm -rf $(TMP)/Cir* $(ECETMP)/Cir* $(ECEDIR)
	if test -f Incl.pdf ; then \
      mv Incl.pdf Incl.pdx; rm -f *.pdf; mv Incl.pdx Incl.pdf ; fi
	for file in `ls *.tex` ; do \
      nm=`echo $$file | sed -e "s/\(.*\)\.tex/\1/"` ; \
      if test -s $$nm.m4 ; then rm -f $$nm.pic $$nm.tex ; fi ; done
	@if test -f distmakefile ; then make -f distmakefile clobber ; fi

clean:
	@printf "\n examples clean:\n"
	rm -f core examples.pdf boxdims.tar.gz
	rm -f *.dvi *.aux *.log *.toc *.blg *.eps *.tif *.epsi eps *-mfpic*
	rm -f fig*.tex $(PICS) *.roff *.int *.pic gpic.m4 test.tex xxx* *.fig
	rm -f *.dim *.bak *.frs *.frp $(RPICS) rotate.ps tst.ps *.bbl *-pics.ps
	rm -f *.tfm *[0-9]pk *.png *.1 *.gif
	rm -f F_* Version.tex doclinks *stackdump *.ico quick.m4
	for nm in $(MANFIGS) ; do rm -f $$nm.* ; done
	rm -rf distfile distfile.tar.gz mode.tex
	@printf "\n"
	@if test -f distmakefile ; then make -f distmakefile clean ; fi