# Makefile for apercu
# Borrowed/copied from ESR.

PACKAGE=apercu
VERSION=1.0.2

# defaults to nothing; set by RPM during building of RPMs
DESTDIR ?= 

prefix=/usr
mandir=$(prefix)/share/man
bindir=$(prefix)/bin

DOCS    = $(PACKAGE).1
SOURCES = $(PACKAGE) Makefile $(DOCS) $(PACKAGE).xml $(PACKAGE).spec

all: $(PACKAGE).1

install: $(PACKAGE).1
	mkdir -p $(DESTDIR)$(bindir)
	mkdir -p $(DESTDIR)$(mandir)/man1
	cp -p $(PACKAGE) $(DESTDIR)$(bindir)
# gzipping the man page conflicts with Mandrake, which bzips it:
# gzip <$(PACKAGE).1 >$(DESTDIR)$(mandir)/man1/$(PACKAGE).1.gz
	cp -p $(PACKAGE).1 $(DESTDIR)$(mandir)/man1/$(PACKAGE).1

uninstall:
	rm -f $(DESTDIR)$(bindir)/$(PACKAGE)
	-rm -f $(DESTDIR)$(mandir)/man1/$(PACKAGE).1*
	-rm -f $(DESTDIR)$(prefix)/man/man1/$(PACKAGE).1*

# Builds the man page.
$(PACKAGE).1: $(PACKAGE).xml Makefile
	xmlto -o . man $(PACKAGE).xml

$(PACKAGE)-$(VERSION).tar.gz: $(SOURCES) $(DOCS)
	@mkdir $(PACKAGE)-$(VERSION)
	@cp $(SOURCES) $(PACKAGE)-$(VERSION)
	@tar -czf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
	@rm -fr $(PACKAGE)-$(VERSION)

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

# The following rules are not for public use.

# Builds the HTML version of the man page.
$(PACKAGE).html: $(PACKAGE).xml Makefile
	xmlto -o . html $(PACKAGE).xml
