#  aRT : API R - TerraLib                                                
#  Copyright (C) 2003-2005  LEG                                          
#                                                                        
#  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 Lesser General Public      
#  License along with this library.                                      

# needs 'apt-get install dvipng'

OBJS=conn sp bodmin table 

bodmin: aRTbodmin.dvi
conn:   aRTconn.dvi
sp:     aRTsp.dvi
table:  aRTtable.dvi
rnews:  wrapper.dvi

DVIOBJS=$(patsubst %,aRT%.dvi,$(OBJS))
TEXOBJS=$(patsubst %,aRT%.tex,$(OBJS))
PDFOBJS=$(patsubst %.dvi,%.pdf,$(DVIOBJS))
HTMOBJS=$(patsubst %.dvi,%.html,$(DVIOBJS))

all: $(DVIOBJS)
pdf: $(PDFOBJS)

html: $(HTMOBJS)
	replace aesltt aett -- *.html
	replace width= widthx= height= heightx= -- *.html

# $@ is the name of the file to be made.
# $? is the names of the changed dependents.
# $< the name of the related file that caused the action.
# $* the prefix shared by target and dependent files. 

%.html: %.dvi
	htlatex $*

%.pdf: %.dvi
	dvipdf $<

%.dvi: %.Rnw
	echo "Sweave(\"$?\")" | R --no-save --no-restore
	latex $*.tex
	latex $*.tex
			
wrapper.dvi: aRT.Rnw
	echo "Sweave(\"aRT.Rnw\")" | R --no-save --no-restore
	latex wrapper.tex
	latex wrapper.tex

clean:
	rm Rfigs/* $(TEXOBJS) *.{log,out,blg,dvi,ps,aux,eps,idv,lg,4tc,4ct,html,tmp,css,xref,png,toc} *-*.pdf

