#
# (C) Baldine Evgueni
#   
#
MainDIR   = `pwd`
SHELL     = /bin/bash
TOP 	  = Physics
TOPTEX    = $(TOP)/TEX
TOPPS     = $(TOP)/PS
TEXES	  = Introduction/Introduction.tex \
            Center-of-the-earth/Center-of-the-earth.tex \
            Chaose/Chaose.tex \
            Climet-heat/Climet-heat.tex \
            Demon-Maxwella/Demon-Maxwella.tex \
            Energy-type/Energy-type.tex \
            Entropia/Entropia.tex \
            Fuleren/Fuleren.tex \
            Mass-in-space/Mass-in-space.tex \
            Oto/Oto.tex \
            Perpetuum-Mobile/Perpetuum-Mobile.tex \
            Quarks/Quarks.tex \
            Spin/Spin.tex \
            Vertical-component/Vertical-component.tex \
            Water-life/Water-life.tex \
            What-is-life/What-is-life.tex \
            Small/Small.tex \
            Chernobl-Novosibirsk/Chernobl-Novosibirsk.tex \
            Most-Wheatstone/Most-Wheatstone.tex \
            Lep/Lep.tex \
            Sound-Demonstration/Sound-Demonstration.tex \
            Signal/Signal.tex \
            AI/AI.tex \
            Fmsha/Fmsha.tex 


SOURCEDIR = Introduction Center-of-the-earth Chaose Climet-heat \
            Demon-Maxwella Energy-type Entropia Fuleren \
            Mass-in-space  Oto   Perpetuum-Mobile  Quarks \
            Spin  Vertical-component Water-life   What-is-life \
            Small  Chernobl-Novosibirsk   Most-Wheatstone\
            Lep Sound-Demonstration Sound-Demonstration \
            Sound-Demonstration  Signal  AI Fmsha 

L2H 	  = latex2html 
LaTeX	  = latex
DVIPS	  = dvips

all: ps html

html: $(TOP)/$(TOP).html   $(TOPTEX)/$(TOP).tar.gz $(TOPPS)/$(TOP).ps.gz 
ps:   $(TOP).ps
dvi:  $(TOP).dvi

        
$(TOPTEX)/$(TOP).tar.gz:  $(TOP).tex $(TOP).aux
	@list='$(SOURCEDIR)';\
        cd $(MainDIR);\
        FILELIST=Makefile;\
        echo Making TEX Source  $(TOPTEX)/$(TOP).tar.gz;\
        for  file in  `ls *.tex *.eps *.sty 2> /dev/null`; \
           do  FILELIST=$$FILELIST' '$$file;\
        done;\
        for sourcefilesdir in $$list;\
        do\
            cd $$sourcefilesdir;\
            for  file in  `ls *.tex *.eps 2> /dev/null`; \
                do  FILELIST=$$FILELIST' '$$sourcefilesdir/$$file;\
            done;\
            cd ..;\
        done;\
        tar cf $(TOPTEX)/$(TOP).tar $$FILELIST;\
        gzip  -f $(TOPTEX)/$(TOP).tar;echo Done


$(TOPPS)/$(TOP).ps.gz: $(TOP).ps
	@echo Making PS Source  $(TOPPS)/$(TOP).ps.gz;\
	cp $(TOP).ps $(TOPPS)/$(TOP).ps;\
	gzip  -f $(TOPPS)/$(TOP).ps;echo Done
        
$(TOP).dvi:     $(TOP).tex $(TOP).aux
	$(LaTeX) $(TOP).tex

$(TOP).aux:	$(TOP).tex $(TEXES)
	$(LaTeX) $(TOP).tex

$(TOP).ps:	$(TOP).dvi
	$(DVIPS) -o $@ $(TOP)

$(TOP)/$(TOP).html :	$(TOP).tex $(TOP).aux 
	$(L2H) $(TOP).tex


clean:	
	rm -rf $(TOP) $(TOP).dvi $(TOP).aux $(TOP).log $(TOP).toc \
	    $(TOP).lof $(TOP).ps 

