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

all: nwf.info nwf.dvi nwf.ps nwf.html nwf.txt 

#####

nwf.dvi: nwf.texi pic1.eps pic2.eps pic3.eps Makefile
	texi2dvi nwf.texi

nwf.info: nwf.texi
	makeinfo nwf.texi

nwf.html: nwf.texi Makefile pic1.pre pic2.pre pic3.pre \
		pic1.html pic2.html pic3.html
	ln -fs nwf.texi nwf
	perl5 ./texi2html -menu -split_node nwf
	for i in nwf_*.html ;								\
	do										\
		echo fixing $$i ;							\
		sed -e '/@paragraphindent/d' 						\
		    -e '/@bigskip/d' 							\
		    -e '/@parindent/d' 							\
		    -e '/@psfig{figure=pic1.eps/r pic1.pre' 				\
		    -e '/@psfig{figure=pic1.eps/d' 					\
		    -e '/@psfig{figure=pic2.eps/r pic2.pre' 				\
		    -e '/@psfig{figure=pic2.eps/d' 					\
		    -e '/@psfig{figure=pic3.eps/r pic3.pre' 				\
		    -e '/@psfig{figure=pic3.eps/d' 					\
		    -e 's/\*\*\*[Pp]icture 1/<A HREF="pic1.html">Picture 1<\/A>/g' 	\
		    -e 's/\*\*\*[Pp]icture 2/<A HREF="pic2.html">Picture 2<\/A>/g' 	\
		    -e 's/\*\*\*[Pp]icture 3/<A HREF="pic3.html">Picture 3<\/A>/g' 	\
		    -e /ATZ/s/\"/\'\'/g							\
		    <$$i >xxx ;								\
		mv xxx $$i ;								\
	done
	sed -e 's/{}//g' nwf_toc.html >xxx
	mv xxx nwf_toc.html
	rm nwf

nwf.ps: nwf.dvi
	dvips nwf.dvi

nwf.txt: nwf.info
	#egrep -vh '^File:.*Node:' *.info-* >xxx
	#egrep -v '^.$$' xxx >nwf.txt
	#egrep -v '^\* .*::?' nwf.txt > xxx
	#mv xxx nwf.txt
	#
	[ -f nwf_toc.html ] && mv nwf_toc.html nwf_toc.html.BAK
	ln -fs nwf.texi nwf
	perl5 ./texi2html  nwf
	( lynx -dump nwf_toc.html ;				\
	  lynx -dump nwf.html 					\
	) | sed -e '/@paragraphindent/d' 			\
		-e '/@bigskip/d' 				\
		-e '/@parindent/d' 				\
		-e '/{}/d'					\
	| egrep -v 	-e ^References 				\
			-e'[0-9]+\. (file|http|ftp)://' 	\
	| sed -e 's/\[[0-9]*\]//g'				\
	>nwf.txt
	rm nwf nwf.html
	[ -f nwf_toc.html.BAK ] && mv nwf_toc.html.BAK nwf_toc.html

#####

pic1.txt pic2.txt pic3.txt: nwf.texi
	perl5 ./cutout nwf.texi

pic1.pre: pic1.txt Makefile
	echo '<A NAME="pic1"><PRE>'   			 >pic1.pre
	cat pic1.txt					>>pic1.pre
	echo '</PRE>'					>>pic1.pre

pic2.pre: pic2.txt Makefile
	echo '<A NAME="pic2"><PRE>'	   		 >pic2.pre
	cat pic2.txt					>>pic2.pre
	echo '</PRE>'					>>pic2.pre

pic3.pre: pic3.txt Makefile
	echo '<A NAME="pic3"><PRE>' 	  		 >pic3.pre
	cat pic3.txt					>>pic3.pre
	echo '</PRE>'					>>pic3.pre

pic1.html: pic1.pre Makefile
	echo '<H1>Picture 1</H1>'			 >pic1.html
	cat pic1.pre					>>pic1.html

pic2.html: pic2.pre Makefile
	echo '<H1>Picture 2</H1>'			 >pic2.html
	cat pic2.pre					>>pic2.html

pic3.html: pic3.pre Makefile
	echo '<H1>Picture 3</H1>'			 >pic3.html
	cat pic3.pre					>>pic3.html

pic1.eps: pic1.fig 
	fig2dev -L ps pic1.fig >pic1.eps

pic2.eps: pic2.fig 		
	fig2dev -L ps pic2.fig >pic2.eps

pic3.eps: pic3.fig 		
	fig2dev -L ps pic3.fig >pic3.eps

#####

show: nwf.dvi
	xdvi -s 8 -copy nwf.dvi

###

clean:
	-rm -fr nwf.aux nwf.cp nwf.fn nwf.ky nwf.log nwf.pg
	-rm -fr nwf.toc nwf.tp nwf.vr xxx
	-rm -fr pic1.eps pic2.eps pic3.eps
	-rm -fr pic1.txt pic2.txt pic3.txt
	-rm -fr pic1.pre pic2.pre pic3.pre
	-rm -fr nwf.dvi
	-rm -fr nwf

###

veryclean: clean
	-rm -fr nwf.dvi
	-rm -fr nwf.info*
	-rm -fr nwf.html nwf_toc.html nwf_*.html
	-rm -fr pic1.html pic2.html pic3.html
	-rm -fr nwf.ps
	-rm -fr nwf.txt
	-rm -fr NWF.tar.gz

###

backup:
	cd .. ; tar -zvc --exclude NWF.tar.gz --exclude '*1.2' --exclude '*MAIL*' --exclude '*.BAK' -f NWF.tar.gz NWF

dist: clean backup
	mv ../NWF.tar.gz .

