base=randomlist
default: package doc test # package ou class
final: package doc-final test

package: $(base).sty
$(base).sty: $(base).ins $(base).dtx
	tex '\nonstopmode \input $(base).ins'

class: $(base).cls
$(base).cls: $(base).ins $(base).dtx
	tex '\nonstopmode \input $(base).ins'

doc:
	latex '\nonstopmode \input $(base).dtx'
	dvips $(base)
	ps2pdf $(base).ps $(base).pdf
	rm $(base).dvi $(base).ps

doc-final:
	latex '\nonstopmode \input $(base).dtx'
	latex '\nonstopmode \input $(base).dtx'
	makeindex -s gind.ist -o $(base).ind $(base).idx
	makeindex -s gglo.ist -o $(base).gls $(base).glo
	latex '\nonstopmode \input $(base).dtx'
	dvips $(base)
	ps2pdf $(base).ps $(base).pdf
	rm $(base).dvi $(base).ps

test: randomlist.tex test.tex testtex.tex
	pdflatex '\nonstopmode \input test.tex'
	etex '\nonstopmode \input testtex.tex'
	pdftex '\nonstopmode \input testtex.tex'

ecm: ecm.tex
	pdflatex '\nonstopmode \input ecm.tex'

clean:
	rm -rf *~ *.aux *.dvi *.glo *.gls *.idx *.ilg *.ind *.log *.out *.ps *.toc

zip:
	cd .. ; zip $(base).zip randomlist/$(base).dtx randomlist/$(base).ins randomlist/$(base).pdf randomlist/$(base).sty randomlist/readme.txt randomlist/Makefile randomlist/comets.dat randomlist/pupils.dat randomlist/pythagoras.dat randomlist/test.tex randomlist/test.pdf randomlist/testtex.tex randomlist/testtex.pdf; mv $(base).zip randomlist/