# SAMPLE Makefile
#	for latex of paper
#	for power4 talk
#	for compiling programs
#	for moving files 
######################################################

#variables
######################################################
# number
n=1
n=

# file
p=p${n}
p=h1

# extension
ext=
ext=.tex

# default target
d=gcc
d=slide
d=dvi

# path for getting/putting file
curpath=pap/cur/exact/mesh/isotopic

# file to get/put (NOTE: wildcard * is OK!)
f=figs/*fig
f=${p}${ext}

# standard files to save:
s=Makefile Notes lmac.tex README

######################################################
# defaults: paper(dvi), slides, compile(gcc)
######################################################
default: $(d)

######################################################
# Targets for paper
######################################################
	
dvi ${p}.dvi:	${p}.tex
	latex ${p}.tex 

ps ${p}.ps:	${p}.tex ${p}.dvi
	dvips -t letter ${p}.dvi -o

bib ${p}.bbl:
	bibtex ${p}

gv:
	# ideal for my solaris display
	gv ${p}.ps -geometry 800x800-20+10 &

gvv:
	# ideal for my laptop display
	gv ${p}.ps -geometry 1000x700+20+10 &

vi:
	gvim ${p}${ext} &

spell:
	aspell -c ${p}${ext}

pdf ${p}.pdf:	${p}.dvi
	dvips -o ${p}.ps -Ppdf ${p}
	ps2pdf ${p}.ps ${p}.pdf

${p}.ps.gz gz:	${p}.ps
	gzip ${p}.ps

cp: pdf
	cp ${p}.pdf ~/tmp/tmp
	chmod a+rw ~/tmp/tmp/${p}.pdf

a8:	${p}.ps
	a2ps -1 -Pnhp8 ${p}.ps &

a1 a a23: ${p}.ps
	a2ps -1 -Pnhp23 ${p}.ps &

# how to do simplex with pdf file?
l8:	${p}.ps
	lp -dnhp8 -osimplex ${p}.ps

######################################################
# Targets for programs
######################################################
	
gcc:
	gcc $(p).c -o $(p)

run:
	$(p)

######################################################
#Targets for cvs, rcs 
######################################################

old-com:
	export CVSROOT=:ext:yap@dept.cs.nyu.edu:/home/yap/cvsroot ; cvs commit

com commit:
	-@cvs commit -m "from makefile" 

# Update: -I = ignore list, -l = local (nonrecursive)
cvsup:
	cvs update -l -I '*.aux *.pdf *.ps *.dvi *.blg *.log *.swp *.bbl'
	(cd figs; cvs update -I '*.tex *.eps *.ps')

# Update: -I = ignore list, -l = local (nonrecursive) 
#	We need -l since figs is a subdirectory with different ignores.
#	Bug: if figs subdirectory is missing, error (ignore it)
up update:
	-@cvs update -l \
	   -I '*.aux *.pdf *.ps *.dvi *.blg *.log *.swp *.bbl *.tmp *.swp *.swo *.swn'
	-@cd figs; cvs update -I '*.tex *.eps *.ps *.swp *.swo *.swn'

# just for figs directory:
upfig:
	-@cvs update -I '*.tex *.eps *.ps *.swp *.swo *.swn'

########## rcs 
ci:
	-@ci -l -m"from makefile" ${p}.tex

######################################################
#Targets for slides
######################################################

slide pp4:	$(p)-tmp.pdf
	pp4 $(p)-tmp.pdf $(p).pdf

tmp $(p)-tmp.pdf: $(p).tex
	pdflatex $(p).tex
	mv $(p).pdf $(p)-tmp.pdf

ac: $(p).pdf
	acroread $(p).pdf &

out outline:
	latex outline.tex


######################################################
# Housekeeping
######################################################
#
#
    ########## file transfers ###############

putf putfile:
	echo Putting file $(f) to $(curpath)
	-@scp $(f) yap@access.cims.nyu.edu:$(curpath)

getf getfile:
	echo Getting file $(f) from $(curpath)
	-@scp4 $(curpath)/$(f)

#getf getfile:
#	-@scp4 yap@access.cims.nyu.edu:$(curpath)/$(f)

    ########## fig file transfers ###############
figfile=fig.tar 

figtar:
	-@tar cvf $(figfile) --exclude=CVS \
		figs

getfig:
	echo Getting fig file $(figfile) from $(curpath)
	-@scp4 $(curpath)/$(figfile)
	-@tar xvf $(figfile)

    ########## tar file transfers ###############
tarfile=T.tar 

tar:
	-@tar cvf $(tarfile) \
		t.tex Makefile lmac.tex figs \
		abstract.txt Notes

scp4 gettar:
	echo Getting tar file $(tarfile) from $(curpath)
	scp4 $(curpath)/$(tarfile) 
	-@tar xvf $(tarfile)

scp2 puttar:
	echo Putting tar file $(tarfile) to $(curpath)
	-@scp $(tarfile) yap@access.cims.nyu:$(curpath)

    ########## saving files ###############
save ci:
	-@ci -m"make save"  -l ${p}.tex \
		$(s)
	
clean:
	-@rm -f *-tmp.pdf
	-@rm -f *.log *.aux *.dvi *.out

post: pdf
	chmod a+r ${p}.pdf
	chmod a+rx ..

######################################################
# END
######################################################
