# Makefile for the waitfor project

# Don't forget to change the spec file when you bump the version number.
VERS=$(shell sed <waitfor.spec -n -e '/Version: \(.*\)/s//\1/p')

MANDIR=/usr/share/man/man1
BINDIR=/usr/bin

DOCS    = README COPYING INSTALL waitfor.xml waitfor.1
SOURCES = waitfor Makefile $(DOCS) waitfor.spec

all: waitfor-$(VERS).tar.gz

install: waitfor.1
	cp waitfor $(BINDIR)
	gzip <waitfor.1 >$(MANDIR)/waitfor.1.gz

waitfor.1: waitfor.xml
	xmlto man waitfor.xml

waitfor.html: waitfor.xml
	xmlto html-nochunks waitfor.xml

waitfor-$(VERS).tar.gz: $(SOURCES) waitfor.1
	mkdir waitfor-$(VERS)
	cp $(SOURCES) waitfor-$(VERS)
	tar -czf waitfor-$(VERS).tar.gz waitfor-$(VERS)
	rm -fr waitfor-$(VERS)
	ls -l waitfor-$(VERS).tar.gz

dist: waitfor-$(VERS).tar.gz waitfor.html
	ln -sf waitfor-$(VERS).tar.gz waitfor.tar.gz

rpm:	dist
	cp waitfor-$(VERS).tar.gz ~/rpmbuild/SOURCES
	cp waitfor.spec ~/rpmbuild/SPECS
	rpmbuild -ba ~/rpmbuild/SPECS/waitfor.spec
	cp ~/rpmbuild/RPMS/noarch/waitfor-$(VERS)*.rpm .

upload: dist
	shipper -f
