#
# Installation Makefile for gendoc
#
# $History: Makefile,v $
#

PYTHON_BIN = `python -c "import sys; print sys.prefix + '/bin'"`
PYTHON_LIB = `python -c "import sys; print sys.prefix + '/lib/python' + sys.version[:3] + '/site-packages'"`

PROG    = pythondoc
PACKAGE = pythondoc

INSTALL = install
#INSTALL = /opt/imake/bin/bsdinst # On HP/UX 10.20

INSTALL_PRG = $(INSTALL) -c -m 755
INSTALL_DATA= $(INSTALL) -c -m 644

VERSION = 0.5
RCS_VERSION = R0_5

DOCS=        README.html \
	     LICENSE.TXT \
	     Makefile \
	     test.py

MODULES    = StructuredText.py \
	     __init__.py \
	     codeutil.py \
	     docobjects.py \
	     docregex.py \
	     docstring.py \
	     doctree.py \
	     message.py \
	     options.py \
             pythondoc.py \
	     regex_util.py \
	     stdmarkup.py \
	     utilities.py \
	     version.py \
             formatters/__init__.py \
	     formatters/format_init.py \
	     formatters/HTML4Formatter.py \
	     formatters/HTML4strings.py \
	     formatters/XMLFormatter.py \
	     formatters/SaveFormatter.py \
	     xref/__init__.py \
	     xref/xref.py \
	     xref/internalXref.py

INSTALL_FILES = \
	     pythondoc.opts \
	     formatters/HTML4styles.css \
	     formatters/HTML4ValidateFooter.html \
	     formatters/HTML4StdHeader.html

all:
	@echo Type \"make install\" to install $(PACKAGE).
	@echo The program $(PROG) will be put in $(PYTHON_BIN)
	@echo The modules will be put in $(PYTHON_LIB) as the
	@echo package $(PACKAGE).
	@echo
	@echo You can control the path to the bin and the lib
	@echo directories by setting PYTHON_BIN and PYTHON_LIB
	@echo respectively.
	@echo
	@echo You can also try running \"make test\", which will
	@echo build HTML4 pages for pythondoc itself in /tmp/html.

install:
	@echo $(PYTHON_BIN) $(PYTHON_LIB)
	-mkdir $(PYTHON_BIN) 2>/dev/null || true
	$(INSTALL_PRG) $(PROG) $(PYTHON_BIN)/$(PROG)

	-mkdir $(PYTHON_LIB)/$(PACKAGE) 2>/dev/null || true
	-mkdir $(PYTHON_LIB)/$(PACKAGE)/formatters 2>/dev/null || true
	-mkdir $(PYTHON_LIB)/$(PACKAGE)/xref 2>/dev/null || true

	@for file in $(MODULES) $(INSTALL_FILES); do \
	    $(INSTALL_DATA) $$file $(PYTHON_LIB)/$(PACKAGE)/$$file; \
	done

	@echo Installation of $(PACKAGE) done.
	@bindir=$(PYTHON_BIN); \
	echo Type $$bindir/$(PROG) -? for usage.

patch:
	@echo Making a patch for $(VERSION)

	@for file in $(DOCS) $(MODULES) $(INSTALL_FILES); do \
	  rcsdiff -r$(RCS_VERSION) -c $$file; \
	done > patch$(PATCH)

DIST_DOCS = $(addprefix $(PACKAGE)-$(VERSION)/, $(DOCS))
DIST_MODULES = $(addprefix $(PACKAGE)-$(VERSION)/, $(MODULES))
DIST_INSTALLS = $(addprefix $(PACKAGE)-$(VERSION)/, $(INSTALL_FILES))

dist:
	(cd ..; mv $(PACKAGE) $(PACKAGE)-$(VERSION); tar cf - $(DIST_DOCS) $(DIST_MODULES) $(DIST_INSTALLS) $(PACKAGE)-$(VERSION)/$(PROG)) | gzip --best > $(PACKAGE)-$(VERSION).tgz
	cd ..; mv $(PACKAGE)-$(VERSION) $(PACKAGE)

release:
	rcs -N$(RCS_VERSION): $(DOCS) $(MODULES) $(INSTALL_FILES)

test:
	@echo Building HTML4 output for pythondoc in /tmp/html.
	@echo pythondoc sources in the current directory will be
	@echo used (run \"make test_install\" to use the installed
	@echo pythondoc).
	@export PYTHONPATH=$$PWD; \
	cp pythondoc /tmp; \
	cd /tmp; \
	mkdir html; \
	./pythondoc -f HTML4 -i -d html pythondoc

test_install:
	@echo Building HTML4 output for pythondoc in /tmp/html2.
	@echo The installed pythondoc will be used.
	cd /tmp; \
	mkdir html2; \
	./pythondoc -f HTML4 -i -d html2 pythondoc


