# $Id: Makefile,v 1.13 2002/10/04 06:41:17 dan Exp $
# Makefile for installing autospec
#
# $Log: Makefile,v $
# Revision 1.13  2002/10/04 06:41:17  dan
# Shuffled targets around.
#
# Revision 1.12  2002/05/14 06:04:55  dan
# Use distutils to generate a MANIFEST file and therefore tar ball contents.
# Added clean and distclean targets.
#
# Revision 1.11  2002/04/04 08:25:06  dan
# Get version number directly from the source code.
# Don't create destination directories if they already exist.
#
# Revision 1.10  2002/02/10 02:59:21  dan
# Don't install COPYING file any more.
#
# Revision 1.9  2002/02/10 02:51:46  dan
# Added txt2html and tidy postprocessing to HTML man page (commented out
# by default).
#
# Revision 1.8  2002/02/10 01:30:55  dan
# Added DISTFILES macro. Bumped version number to 0.7.
#
# Revision 1.7  2001/05/08 20:57:40  dan
# Bumped version number to 0.6.
#
# Revision 1.6  2001/03/30 05:12:01  dan
# Moved Python source to /usr/share/autospec. Bumped version number to 0.5.
#
# Revision 1.5  2000/06/05 20:21:02  dan
# Removed unneeded lists.py
#
# Revision 1.4  2000/06/05 19:35:33  dan
# Bumped version number to 0.4. Now preserving permissions in dist:
#
# Revision 1.3  1999/02/26 07:51:00  dan
# Added .lsm file to distribution. Added -f flag to rm.
#
# Revision 1.2  1999/02/26 07:21:10  dan
# Added dist target.  Added files to install target.
# Bumped version number to 0.3.
#
# Revision 1.1  1998/08/10 06:41:49  dan
# Initial revision
#

VERSION = $(shell python -c 'import autospec,string;print string.split(autospec.version_msg)[-1]')

ifndef prefix
prefix = /usr
endif

SOURCES = *.py autospec
DISTFILES = $(shell cat MANIFEST) MANIFEST MANIFEST.in
CLEAN_FILES = *.pyc *.pyo autospec.man autospec.html MANIFEST

all:
	@echo Use \'make prefix=/usr/local install\' to install autospec ver. $(VERSION)
	@echo in the given directory root or \'make dist\' to create a distribution archive

clean:
	-rm -f $(CLEAN_FILES)

autospec.man: autospec.1
	nroff -man $^ > $@

autospec.html: autospec.man
	#man2html -topm 5 -compress -cgiurl 'http://www.linux.com/develop/man/$${section}/$${title}/' < $^ > $@
	man2html -topm 5 -compress -seealso -cgiurl 'http://batboy.fms.indiana.edu/manpages/r/$${title}.$${section}.html' < $^ > $@
	#txt2html --linkonly < $@ > autospec.tmp && mv -f autospec.tmp $@
	#-tidy -m $@

# The remaining targets could all be replaced by Python's distutils one day.
# The included setup.py can be used for that purpose.

install:
	test -d $(prefix)/bin || install -d $(prefix)/bin
	test -d $(prefix)/share/autospec || install -d $(prefix)/share/autospec
	test -d $(prefix)/man/man1 || install -d $(prefix)/man/man1
	install autospec $(prefix)/bin
	install -m 644 *.py $(prefix)/share/autospec
	install -m 644 autospec.1 $(prefix)/man/man1

dist: MANIFEST
	test ! -e autospec-$(VERSION)
	mkdir autospec-$(VERSION)
	cp -p $(DISTFILES) autospec-$(VERSION)
	tar --gzip -cvf autospec-$(VERSION).tar.gz autospec-$(VERSION)
	rm -rf autospec-$(VERSION)

distclean: clean

MANIFEST: MANIFEST.in setup.py
	python setup.py sdist --manifest-only

