# Makefile for the rpm2lsm distribution
VERS=1.2

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

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

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

clean:
	rm -f rpm2lsm.1 *~ 
	rm -f rpm2lsm-*-1.noarch.rpm rpm2lsm-*-1.noarch.rpm rpm2lsm-*.tar.gz

rpm2lsm.1: rpm2lsm.xml
	xmlto man rpm2lsm.xml

SOURCES = READ.ME NEWS Makefile rpm2lsm rpm2lsm.xml
rpm2lsm-$(VERS).tar.gz: $(SOURCES) rpm2lsm.1 
	mkdir rpm2lsm-$(VERS)
	cp $(SOURCES) rpm2lsm.1 rpm2lsm-$(VERS)
	tar -czf rpm2lsm-$(VERS).tar.gz rpm2lsm-$(VERS)
	rm -fr rpm2lsm-$(VERS)
	ls -l rpm2lsm-$(VERS).tar.gz

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

# Make RPMs.  You need to be root to make this work
RPMROOT=/usr/src/redhat
RPM = rpmbuild
RPMFLAGS = -bb --target noarch
rpm: rpm2lsm-$(VERS).tar.gz
	cp rpm2lsm-$(VERS).tar.gz $(RPMROOT)/SOURCES;
	cp rpm2lsm.spec $(RPMROOT)/SPECS/rpm2lsm.spec
	(cd $(RPMROOT)/SPECS; $(RPM) $(RPMFLAGS) rpm2lsm.spec)
	cp $(RPMROOT)/RPMS/noarch/rpm2lsm-$(VERS)*.rpm .
	chown $$USER *

