# Makefile for cvsdelta (http://cvsdelta.sourceforge.net)

PACKAGE       = cvsdelta
VERSION       = 1.6.9

PKG_VER       = ${PACKAGE}-$(VERSION}
DIST_SOURCES  = cvsdelta.ps cvsdelta.pdf cvsdelta.1 cvsdelta Makefile ChangeLog
INSTALL       = /usr/bin/install -c
PREFIX       ?= /usr

distdir       = ${PACKAGE}-${VERSION}
srcdir        = .

TAR           = gtar
GZIP_ENV      = --best

SOURCE_FILES  = \
Makefile \
bin/rbsto1 \
ansicolor.rb \
cvsaddset.rb \
cvsdelta.rb \
cvsdeltaopt.rb \
cvsdeltarun.rb \
cvsdiff.rb \
cvsexec.rb \
cvsignore.rb \
cvsstats.rb \
env.rb \
file.rb \
log.rb \
progmet.rb \
regexp.rb \
string.rb

DISTFILES     = \
$(SOURCE_FILES) \
cvsdelta \
cvsdelta.1 \
cvsdelta.pod

all: cvsdelta.1

docs: cvsdelta.ps cvsdelta.pdf cvsdelta.1 cvsdelta.html

cvsdelta.ps: cvsdelta.dvi
	dvips -o $@ $^

cvsdelta.pdf: cvsdelta.ps
	ps2pdf $^ $@

cvsdelta.dvi: cvsdelta.tex
	latex $^

cvsdelta.tex: cvsdelta.pod
	pod2latex -full $^

cvsdelta.1: cvsdelta.pod Makefile
	pod2man --release "${PACKAGE} ${VERSION}" \
		--center "${PACKAGE} ${VERSION}" \
		cvsdelta.pod > $@

cvsdelta.html: cvsdelta.pod
	pod2html $^ > $@

dist: $(distdir)
	-chmod -R a+r $(distdir)
	GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
	-rm -rf $(distdir)

$(distdir): $(DISTFILES)
	rm -rf $(distdir)
	mkdir $(distdir)
	mkdir $(distdir)/bin
	-chmod 777 $(distdir)
	-chmod 777 $(distdir)/bin
	distdir=`cd $(distdir) && pwd`; \
	cd $(top_srcdir)
	@for file in $(DISTFILES); do \
	  d=$(srcdir); \
	  if test -d $$d/$$file; then \
	    cp -pr $$d/$$file $(distdir)/$$file; \
	  else \
	    test -f $(distdir)/$$file \
	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
	    || cp -p $$d/$$file $(distdir)/$$file || :; \
	  fi; \
	done

install: cvsdelta.1
	${INSTALL} cvsdelta $(PREFIX)/bin
	${INSTALL} cvsdelta.1 $(PREFIX)/share/man/man1

uninstall: cvsdelta.1
	rm -f $(PREFIX)/bin/cvsdelta
	-rm -f $(PREFIX)/man/man1/cvsdelta.1
	-rm -f $(PREFIX)/share/man/man1/cvsdelta.1

clean:
	rm -f cvsdelta.ps cvsdelta.pdf cvsdelta.1 cvsdelta.dvi cvsdelta.tex

# Builds the real cvsdelta from its modules. Not for external use.

complete: cvsdelta cvsdelta.1

cvsdelta: $(SOURCE_FILES)
	./bin/rbsto1 cvsdeltarun.rb > $@
	chmod +x $@
