# Examples makefile. # # Type "make" to generate examples.ps containing many examples. # Type "make .ps" to make a postscript file from .m4 # Type "make .eps" to make an .eps file from .m4 # Type "make .png" to make a .png file from .m4 # Type "make .tif" to make a .tif file from .m4 # Type "make .svg" to make a .svg file from .m4 # (uses ImageMagick convert) # # 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 the examples # directory of the distribution, copy this makefile and tst.tex # to where you want to work, redefine LIBDIR (below) appropriately, # and type "make .xxx" where xxx is one of ps, eps, png, or pdf # Examples and local distribution: make distece ; copy tmp/Circuit_macros.tar.gz # to ece, and execute installCM Circuit_macros.tar.gz # CTAN dist files: make zips # The CTAN file is tmp/Circuit_macros/Circuit_macrosN.N.tar.gz # Circuit_macro directory, change this if necessary: # LIBDIR = $$HOME/lib LIBDIR = .. # The dpic processor: PIC = dpic -p #PIC = $$HOME/dpic/test/dpic -p #PIC = $$HOME/dpic/p2c/ftp/dpic -p CONFIGFILE = pstricks.m4 # Uncomment these for gpic. Change gpic to pic if necessary on your machine: # PIC = gpic -t # PIC = pic -t # CONFIGFILE = gpic.m4 # Convert options EPSOPTS = PNGOPTS = -density 400 -scale 25% -alpha Remove ######################################################################### # RSH = /bin/rsh # RCP = /bin/rcp # Better: RSH = ssh RCP = scp # M4 = m4 -B32000 M4 = m4 -I $(LIBDIR) # Environment variable M4PATH has been set to the installation directory M4 = m4 ######################################################################### BACKGROUND = blight DOC = examples PICS = \ Adder.tex Alogix.tex ABlogix.tex AmpTable.tex Antennas.tex Audio.tex \ Bip.tex Btree.tex Byte.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 Globe.tex Grounds.tex \ Headers.tex Heathkit.tex \ I2L.tex Incleps.tex Jack.tex \ Logic.tex Loglog.tex MC.tex MotorControl.tex Multiplexer.tex \ NLG.tex NPDT.tex Nport.tex \ Opamp.tex Optoiso.tex \ Pconn.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 \ Variable.tex Windings.tex Xform.tex \ bistable.tex $(BACKGROUND).tex control.tex csc.tex diamond.tex \ ex00.tex ex01.tex ex02.tex ex03.tex ex04.tex ex05.tex ex06.tex \ ex07.tex ex08.tex ex09.tex ex10.tex ex11.tex ex12.tex ex15.tex \ ex16.tex ex17.tex ex18.tex ex19.tex ex21.tex exp.tex fet.tex \ graysurf.tex lcct.tex pwrsupply.tex quick.tex recycle.tex rose.tex \ sfg.tex thyristor.tex ujt.tex worm.tex yinyang.tex 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 bistable fet thyristor ujt # Files that have to be processed twice: BOXDIMS = ex09 Crow Incleps Loglog Opamp Windings DVIPSOPTS = -Ppdf -G0 -t letter M4LIBS = $(CONFIGFILE) DIMFILE = LTX = latex --shell-escape BS = tr '|' '\134' .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 > $*.pic $(PIC) $*.pic > $*.tex .m4.pic: @if test -n "$(DIMFILE)" ; then touch $(DIMFILE) ; fi $(M4) $(M4LIBS) $(DIMFILE) $*.m4 > $*.pic #.m4.dvi: # make $*.tex .m4.dvi: make $*.tex printf "|documentclass[11pt]{article}\n\ |usepackage{times,pstricks,boxdims,graphicx,pst-grad,pst-slpe}\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: $(M4) pgf.m4 libcct.m4 $*.m4 > $*.pic dpic -g $*.pic > test.tex sed -e '/^\\usepackage.*graphicx/s/^.*$$/\\usepackage{tikz}/' \ -e '/pstricks/d' \ $(LIBDIR)/examples/tst.tex > F$*.tex pdflatex F$* $(M4) pgf.m4 libcct.m4 $*.m4 > $*.pic dpic -g $*.pic > test.tex pdflatex F$* mv F$*.pdf $*.pdf ######################################################################### $(DOC).ps: doclinks $(DOC).dvi doclinks: # -for nm in $(MANFIGS) ; do ln -s $(LIBDIR)/doc/$$nm.m4 ; done -for nm in $(MANFIGS) ; do cp $(LIBDIR)/doc/$$nm.m4 . ; done printf '%% quick.m4\n' > quick.m4 cat $(LIBDIR)/doc/quick.m4 >> quick.m4 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 make $(PICS) cp $(LIBDIR)/doc/Version.tex . latex $(DOC) touch $(DOC).frs rm $(DOC).dvi 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 tstl: 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 # Distribution files NAME=Circuit_macros TMP=/tmp #TMP=../../tmp DISTTMP=$(TMP)/$(NAME) REMOVED = examples/test examples/xfig/info m4s examples/htmlsource \ examples/html examples/dist examples/zips examples/SCP doc/expl-m4.pdf # dist: @printf "\n making test.m4 Copying doclinks examples.ps mf/cct.tfm\n" @printf " xfig/xfiglib.fig\n\n" # @if test ! -s $(LIBDIR)/doc/CMman.pdf ; then \ # echo ; echo "Make CMman.pdf first!!"; echo ; exit 1 ; fi @if test ! -s $(LIBDIR)/doc/CMman.pdf ; then \ (cd $(LIBDIR)/doc; make ) ; fi touch test.m4; cp test.m4 $(TMP)/test`date +%Y.%m.%d.%H:%M:%S` rm test.m4; make test.m4 ( cd $(LIBDIR); mv doc/CMman.pdf . ; \ make clobber; chmod 644 CMman.pdf; mv CMman.pdf doc ) make Copying doclinks make PIC="dpic -p" CONFIGFILE="pstricks.m4" ; make clean (cd mf; make; chmod 644 cct.tfm; make clean) (cd xfig; make; make clean) (cd $(LIBDIR)/doc; make clean ) -dir=`pwd` ; if [ "`basename $$dir`" = "examples" ] ; then \ rm -f $(LIBDIR)/examples.tar.gz ; fi touch dist $(DISTTMP): if test -d $(DISTTMP); then rm -rf $(DISTTMP); mkdir -p $(DISTTMP) ; fi COPIED = boxdims.sty CHANGES Copying darrow.m4 doc examples gpic.m4 \ lib3D.m4 libcct.m4 libgen.m4 liblog.m4 \ Makefile mfpic.m4 mpost.m4 pgf.m4 postscript.m4 pstricks.m4 \ README svg.m4 xfig.m4 zips: $(DISTTMP) dist @printf "\n making zips\n" Version=`sed -e 's/Version //' $(LIBDIR)/doc/Version.tex` ; \ PCVersion=`echo $$Version | sed -e 's/\./_/g'` ; \ rm -rf $(DISTTMP)$$Version ; mkdir $(DISTTMP)$$Version; \ (cd $(LIBDIR); cp -r $(COPIED) $(DISTTMP)$$Version ); \ (cd $(DISTTMP)$$Version ; rm -rf $(REMOVED) ) ; \ (cd $(DISTTMP)$$Version ; find . -type f -exec chmod 644 {} \; ) ; \ (cd $(DISTTMP)$$Version ; find . -type f -empty -exec rm {} \; ) ; \ (cd $(LIBDIR)/doc; make clobber ) ; \ ( cd $(TMP); \ tar cf - $(NAME)$$Version | gzip > $(NAME)$$Version.tar.gz ; \ (cd $(NAME)$$Version; zip -r $(NAME) * ) ; \ mv $(NAME)$$Version/$(NAME).zip $(NAME)$$PCVersion.zip ; \ printf \ "\n$(DISTTMP)$$Version and $(TMP)/$(NAME)$$Version.tar.gz created\n"; \ printf "\n$(TMP)/$(NAME)$$PCVersion.zip created\n" ) touch zips test.m4: printf \ "%% Test.m4\n\ .PS\n\ cct_init\n\ # Use this file to do a quick test of diagrams you are developing.\n\ # Enter the drawing commands here and (if you have a \"make\" utility) type\n\ # make tst\n\ # Otherwise, to process a file called filename.m4, type one of\n\ # make filename.ps\n\ # make filename.eps\n\ # make filename.pdf\n\ # make filename.png (uses ImageMagick convert)\n\ # make filename.tif (uses ImageMagick convert)\n\ # To perform tests in a new folder, copy the Makefile and tst.tex (or\n\ # your own equivalent) to that folder.\n\ .PE\n" > test.m4 # To make but not distribute everything: make dist zips htmlfiles ECETMP = /cygdrive/d/Dwight/tmp ECENAM = ecedistfiles ECEDIR = $(ECETMP)/$(NAME) PERLFILE = Circuit_macros_access_log distece: (cd ..; make clobber; find . -type f -exec chmod 644 {} \; ) rm -f dist zips htmlfiles make dist zips htmlfiles rm -rf $(ECEDIR)* ; mkdir $(ECEDIR) Version=`sed -e 's/Version //' $(LIBDIR)/doc/Version.tex` ; \ PCVersion=`echo $$Version | sed -e 's/\./_/g'` ; \ cp -p $(TMP)/$(NAME)$$Version.tar.gz \ $(TMP)/$(NAME)$$PCVersion.zip \ $(DISTTMP)$$Version/README $(DISTTMP)$$Version/CHANGES \ $(DISTTMP)$$Version/doc/CMman.pdf \ $(ECEDIR) rm -rf $(ECEDIR)/html ; mkdir $(ECEDIR)/html cp -rp html/* $(ECEDIR)/html mv $(ECEDIR)/html/index.html $(ECEDIR)/index.html (cd $(ECETMP); tarlib $(NAME); mv $(NAME).tar.gz $(ECENAM).tar.gz ) ECEPROXY = eceweb distfile: rm -f dist zips htmlfiles make dist zips htmlfiles rm -rf distfile distfile.tar.gz; mkdir distfile Version=`sed -e 's/Version //' $(LIBDIR)/doc/Version.tex` ; \ cp -p $(DISTTMP)$$Version.tar.gz \ $(DISTTMP)$$Version/README $(DISTTMP)$$Version/CHANGES \ distfile ;\ PCVersion=`echo $$Version | sed -e 's/\./_/g'` ; \ cp -p $(DISTTMP)$$PCVersion.zip distfile ;\ mkdir distfile/html cp -rp html/* distfile/html (cd distfile/html; mv index.html .. ; rm -f access.log *.pl ) # tarlib distfile EPSFILES=${PICS:%.tex=%.eps} # Make an encapsulated Postscript file for each example (requires pstricks) eps: doclinks make ${PICS:%.tex=%.eps} Copying: $(LIBDIR)/doc/Version.tex sed -e \ "s%Version *[0-9.]*,%`cat $(LIBDIR)/doc/Version.tex`,%" $(LIBDIR)/Copying \ > xxx sed -e "s%opyright (c) [^ ][^ ]* J%opyright (c) `date '+%Y'` J%" xxx \ > $(LIBDIR)/Copying ; rm -f xxx for file in `find $(LIBDIR) -name Copying -print` ; do \ if test ! "$$file" = "$(LIBDIR)/Copying" ; then \ cp $(LIBDIR)/Copying $$file; fi ; done (cd $(LIBDIR) ; for file in `grep -l 'Version [0-9][\.0-9]*,' *` ; do \ if test ! \( "$$file" = "Copying" -o "$$file" = "CHANGES" \) ; then \ ( sed -e '/opyright (c)/,$$d' $$file ; cat Copying ; echo "" ; \ sed -e '1,/opyright (c)/d' $$file | sed -e '1,/^ *$$/d' ) > xxx ; \ sed -e "s%Version *[0-9.]*:%`cat doc/Version.tex`:%" xxx \ > $$file ; rm -f xxx ; fi ; done ; ) (cd $(LIBDIR) ; \ ( sed -e '/opyright (c)/,$$d' dpictools.pic ; \ sed -e 's/^ *\*/\#/' -e 's/\* *$$/\#/' Copying ; echo "" ; \ sed -e '1,/opyright (c)/d' dpictools.pic | sed -e '1,/^ *$$/d' ) > xxx ;\ sed -e "s%Version *[0-9.]*:%`cat doc/Version.tex`:%" xxx \ > dpictools.pic ; rm xxx ) htmlfiles: html svgfiles pngs html/examples.html html/index.html \ html/Circuit_macros.ico html/Optosample.png (cd pgf; make examples.pdf; chmod 644 examples.pdf; mv examples.pdf .. ) mv examples.pdf html/examples.pdf (cd html; chmod 644 *.svg *.txt *.html *.pdf ) touch htmlfiles html: if test ! -d html ; then mkdir html ; fi ( cd htmlsource; cp -p $(PERLFILE).pl .htaccess ../html ) svgfiles: html ( cd svg; make ) for file in `ls svg/*SVG.m4` ; \ do cp $$file html/`basename $$file .m4`.txt ; done cp -p svg/examplesSVG.html svg/*.svg svg/*.jpg html touch svgfiles html/Circuit_macros.ico: html htmlsource/favicon.m4 cp htmlsource/favicon.m4 . make favicon.eps convert -density 105 favicon.eps html/Circuit_macros.ico rm -f favicon.* html/index.html: htmlsource/index.htmx html Version=`sed -e 's/Version //' $(LIBDIR)/doc/Version.tex` ; \ sed -e 's/Version XXX/Version '$$Version'/' htmlsource/index.htmx \ > html/index.html html/Optosample.png: html htmlsource/Optosample.m4 cp htmlsource/Optosample.m4 . make Optosample.eps convert Optosample.eps Optosample.png mv Optosample.png html/Optosample.png rm Optosample.* TR = tr '^' '\012' html/examples.html: html htmlsource/examples.htmx files.tex Version=`sed -e 's/Version //' $(LIBDIR)/doc/Version.tex` ; \ sed -e 's/Version XXX/Version '$$Version'/' htmlsource/examples.htmx \ > html/examples.html cat files.tex | sed -e '/bfig[\{]/d' -e '/^ *[\}][\}]* *$$/d' \ -e '/src[\{]/d' -e '/\\if/d' -e '/\\fi/d' -e '/includegraphics/d' \ -e '/\%ignore\%/d' -e '/^\%/d' -e '/\\end[\{]/d' -e '/^\%/d' \ -e '/getpic/s/\\getpic[\{]\([^\}]*\)[\}][\}]*/ <\1> /g' \ -e '/<[^-]/s/^[^<]*[^<]* /g' -e '/[^-]>/s/>.*$$/>/' \ -e 's/\([^ -][^ -]*\)>/IS_"\1.png" A_"\1 diagram">B_"\1.txt" T_\1.m4Y/'\ -e 's/IS_/

/'^

/' -e 's/4Y/4<\/A>:/' \ -e 's/^.*caption[\{]//' -e '/^ *$$/s/^ */


/' \ | sed \ -e '/

/!s/{\\tt \([^}]*\)}/\1<\/tt>/g' \ -e '/

/!s/{\\bf \([^}]*\)}/\1<\/tt>/g' \ -e '/

/!s/{\\em \([^}]*\)}/\1<\/em>/g' \ -e '/

/!s/{\\it \([^}]*\)}/\1<\/em>/g' \ -e '/

/!s/{\\sl \([^}]*\)}/\1<\/em>/g' \ -e '/

/!s%\([^\\]\)_\(.\)%\1\2%g' \ -e '/

/!s%\([^\\]\)\^\(.\)%\1\2%g' \ -e 's%``%"%g' -e "s%''%\"%g" -e 's/\~/ /g' \ -e 's%\\%%g' -e 's/\$$//g' \ | sed -e 's/HREF=Inclpdf.m4/HREF=Inclpdf.txt/' | $(TR) \ >> html/examples.html cat htmlsource/endexamples.htmx >> html/examples.html pngs: basenames -for nm in `cat basenames` ; do \ make $$nm.png ; mv $$nm.png html/$$nm.png ;\ done make $(BACKGROUND).png ; mv $(BACKGROUND).png html/$(BACKGROUND).png rm -f $(BACKGROUND).tex -for nm in `cat basenames` ; do\ cp $$nm.m4 html/$$nm.txt ; done cp Inclpdf.m4 html/Inclpdf.txt echo "" > html/Inclpdf.m4 cat Inclpdf.m4 >> html/Inclpdf.m4 chmod 644 html/Inclpdf.m4 gifs: basenames -for nm in `cat basenames` ; do \ make $$nm.gif ; mv $$nm.gif html/$$nm.gif ;\ done make $(BACKGROUND).gif ; mv $(BACKGROUND).gif html/$(BACKGROUND).gif rm -f $(BACKGROUND).tex -for nm in `cat basenames` ; do\ cp $$nm.m4 html/$$nm.txt ; done cp Inclpdf.m4 html/Inclpdf.txt echo "" > html/Inclpdf.m4 cat Inclpdf.m4 >> html/Inclpdf.m4 chmod 644 html/Inclpdf.m4 basenames: files.tex doclinks grep '\\getpic' files.tex | sed -e '/Inclpdf/d' \ -e 's%\\getpic[\{]\([^\}]*\)[\}]% <\1> %g' \ -e 's/^[^<]*[^<]*.*$$//' \ | sort | uniq > basenames # Done separately to avoid problems with old version of convert Incleps.png: if test `hostname` = kingcong ; then \ cp test/Incleps.png.gz . ; gunzip Incleps.png.gz ; \ else make $*.eps ; convert $(PNGOPTS) $*.eps $*.png ; fi # Experimental: RPICS = rotatetext.tex rotellipse.tex rotate: make DOC=rotate PICS='$(RPICS)' BOXDIMS='rotatetext rotellipse' touch rotatetext.m4 rotellipse.m4 make DOC=rotate PICS='$(RPICS)' BOXDIMS='rotatetext rotellipse' clobber: clean rm -f *.ps -@for dir in mf mpost pdflatex xfig psfrag pgf svg; \ 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) mv Incl.pdf Incl.pdx; rm -f *.pdf; mv Incl.pdx Incl.pdf 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 clean: rm -f core snapshots rm -f *.dvi *.aux *.log *.toc *.blg *.eps *.epsi eps *-mfpic* rm -f fig*.tex $(PICS) *.roff *.int *.pic gpic.m4 test.tex xxx* *.fig rm -f *.dim *.bak *.frs $(RPICS) rotate.ps tst.ps *.bbl *-pics.ps *.gif rm -f *.tfm *[0-9]pk quick.tex quick.pic *.png *.1 rm -f F*.tex Version.tex doclinks *stackdump *.ico for nm in $(MANFIGS) ; do rm -f $$nm.* ; done rm -rf distfile distfile.tar.gz