# Makefile for the imgsizer distribution
VERS=$(shell sed <imgsizer.spec -n -e '/Version: \(.*\)/s//\1/p')

# These choices are correct for Linux.  Season to taste.
BINDIR = /usr/bin
MANDIR = /usr/share/man/man1

install: imgsizer.1 uninstall
	cp imgsizer $(BINDIR)
	cp imgsizer.1 $(MANDIR)/imgsizer.1

uninstall:
	rm -f $(BINDIR)/imgsizer $(BINDIR)/imgsizer $(MANDIR)/imgsizer.1

clean:
	rm -f imgsizer.1 *~ 
	rm -f imgsizer-*-1.noarch.rpm imgsizer-*-1.noarch.rpm imgsizer-*.tar.gz
	rm -f test-after.html

imgsizer.1: imgsizer.xml
	xmlto man imgsizer.xml

SOURCES = README COPYING Makefile imgsizer.spec \
	imgsizer imgsizer.xml \
	test-before.html test-converted.html test.png tnhd2.jpg

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

# Regression test is good if there is no output
test: 
	imgsizer <test-before.html >test-after.html
	diff -c test-after.html test-converted.html

dist: imgsizer-$(VERS).tar.gz

release: imgsizer-$(VERS).tar.gz imgsizer.html
	shipper -f; rm -f CHANGES ANNOUNCE* *.1 *.html *.rpm *.lsm
