#  Makefile for InterBib2007

all:
	chmod a+x Scripts/bib2target.py

	ln -s interbib.html index.html

	# Only make a bibliography directory none exists:

	-mkdir bibliographies

	chmod a+w bibliographies	

	# Make commandline Scripts that all refer to bib2target.py:

	ln -s Scripts/bib2target.py bib2html
	ln -s Scripts/bib2target.py bib2endnote
	ln -s Scripts/bib2target.py endnote2bib
	ln -s Scripts/bib2target.py endnote2html
	ln -s Scripts/bib2target.py bib2refer
	ln -s Scripts/bib2target.py refer2bib
	ln -s Scripts/bib2target.py bib2mif
	ln -s Scripts/bib2target.py bib2interbib

	# Bibliography conversion and document transform share a script:

	(cd Scripts; ln -s nph-bibservicecgi.py nph-bibconvertcgi.py)
	(cd Scripts; ln -s nph-bibservicecgi.py nph-bibdocxformcgi.py)

	mkdir Scripts/tmp
	chmod a+wrx Scripts/tmp

	echo ""
	echo "InterBib Make Successful"

clean:
	# The minus sign causes 'make' to ignore errors:
	-rm index.html bib2html bib2endnote endnote2bib endnote2html   \
	    bib2refer refer2bib bib2mif bib2interbib Scripts/*.pyc
	-rm Scripts/nph-bibconvertcgi.py Scripts/nph-bibdocxformcgi.py

	# Clean out the tmp dir, but leave the bibliographies dir alone:
	-rm -rf Scripts/tmp/*
	-rmdir Scripts/tmp

	-rm interbib.tar.gz

	echo ""
	echo "InterBib Cleanup Successful"

distrib:
	# I need lots of --exclude for files that are symlinked. Theoretically
	# the --dereference option should accomplish this, but on Cygwin, at least,
	# it doesn't:

	-rm interbib.tar.gz
	tar -cvf interbib.tar --exclude='CVS' --exclude='tmp' --exclude='*.pyc' \
	--exclude='bib2html' --exclude='bib2interbib' --exclude='bib2mif' --exclude='bib2refer' \
	--exclude='refer2bib' --exclude='endnote2bib' --exclude='bib2endnote' \
	--exclude='endnote2html' --exclude='nph-bibconvertcgi.py' \
	--exclude='nph-bibdocxformcgi.py' --exclude='index.html' .

	gzip interbib.tar

	echo ""
	echo "Created distribution: interbib.tar.gz"