VERSION=$(shell awk '/^RCSID=/ {print $$3}' geninitrd)
FILES=Makefile geninitrd.sysconfig geninitrd geninitrd.8 geninitrd.8.xml ChangeLog
BUILDROOT=$(DESTDIR)

mandir=/usr/share/man
sysconfdir=/etc/sysconfig

install:
	install -d $(BUILDROOT)/sbin $(BUILDROOT)$(mandir)/man8 $(BUILDROOT)$(sysconfdir)
	install -m755 geninitrd $(BUILDROOT)/sbin/geninitrd
	install -m644 geninitrd.8 $(BUILDROOT)/$(mandir)/man8/geninitrd.8
	install -m644 geninitrd.sysconfig $(BUILDROOT)/$(sysconfdir)/geninitrd

geninitrd.8: geninitrd.8.xml
	refentry2man <geninitrd.8.xml >geninitrd.8

dist:	geninitrd-$(VERSION).tar.gz 

geninitrd-$(VERSION).tar.gz: $(FILES)
	-rm -f *.tar.gz
	-rm -rf geninitrd-$(VERSION)
	mkdir geninitrd-$(VERSION)
	cp $(FILES)  geninitrd-$(VERSION)
	tar czvf geninitrd-$(VERSION).tar.gz geninitrd-$(VERSION)
	-rm -rf geninitrd-$(VERSION)
