%.1: %.pod
	pod2man -c '' $< $@
bin/fig2pdf:
	cd bin;ln -s fig2ps fig2pdf; cd ..;
doc/fig2pdf.1:
	cd doc;ln -s fig2ps.1 fig2pdf.1; cd ..;

build: doc/fig2ps.1 check

check:
	perl -c -w bin/fig2ps

install: build
	echo Destination: $(DESTDIR)
	for dir in `cat dirs`;do echo $$dir;install -d $(DESTDIR)/$$dir/; done;
	cp bin/fig2ps $(DESTDIR)/usr/bin/fig2ps
	cp fig2ps.rc $(DESTDIR)/etc/fig2ps/fig2ps.rc
	gzip --best -c doc/fig2ps.1 > $(DESTDIR)/usr/share/man/man1/fig2ps.1.gz
	# really small documentation
	cp examples/Example.fig $(DESTDIR)/usr/share/doc/fig2ps/examples/Example.fig
	gzip --best -c examples/Example.ps > $(DESTDIR)/usr/share/doc/fig2ps/examples/Example.ps.gz
	cp README $(DESTDIR)/usr/share/doc/fig2ps


	# then, the links:
	ln -s fig2ps $(DESTDIR)/usr/bin/fig2pdf
	ln -s fig2ps $(DESTDIR)/usr/bin/fig2eps
	ln -s fig2ps.1.gz $(DESTDIR)/usr/share/man/man1/fig2pdf.1.gz
	ln -s fig2ps.1.gz $(DESTDIR)/usr/share/man/man1/fig2eps.1.gz

install-home: build
	if test -d $(HOME)/bin ;\
	then cp bin/fig2ps $(HOME)/bin;\
	ln -s  $(HOME)/bin/fig2ps  $(HOME)/bin/fig2pdf;\
	ln -s  $(HOME)/bin/fig2ps  $(HOME)/bin/fig2eps;\
	cp fig2ps.rc $(HOME)/.fig2ps.rc;\
	else echo "You should have a $(HOME)/bin directory";\
	fi;

clean:
	-rm -f `find . -name "*~"`;
	-rm doc/fig2ps.1;

