TARGETS	= $(OBJDIR)index.html $(OBJDIR)player.1 $(OBJDIR)player.html $(OBJDIR)playerctl.1 $(OBJDIR)playerctl.html
OBJDIR	=
PREFIX	= /usr/local
DESTDIR	=
RM	= rm -f
LN	= ln -f
MKDIR	= mkdir -m 0755 -p
INSTALL	= install


all: $(TARGETS)

$(OBJDIR)index.html: docbook.sh index.xml index.xsl player.xml playerctl.xml
	./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)index.html"

$(OBJDIR)player.1: docbook.sh player.xml
	./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)player.1"

$(OBJDIR)player.html: docbook.sh manual.css.xml player.css.xml player.xml
	./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)player.html"

$(OBJDIR)playerctl.1: docbook.sh playerctl.xml
	./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)playerctl.1"

$(OBJDIR)playerctl.html: docbook.sh manual.css.xml playerctl.css.xml playerctl.xml
	./docbook.sh -P "$(PREFIX)" -- "$(OBJDIR)playerctl.html"

clean:
	./docbook.sh -c -P "$(PREFIX)" -- "$(OBJDIR)index.html"
	./docbook.sh -c -P "$(PREFIX)" -- "$(OBJDIR)player.1"
	./docbook.sh -c -P "$(PREFIX)" -- "$(OBJDIR)player.html"
	./docbook.sh -c -P "$(PREFIX)" -- "$(OBJDIR)playerctl.1"
	./docbook.sh -c -P "$(PREFIX)" -- "$(OBJDIR)playerctl.html"

distclean: clean
	$(RM) -- $(TARGETS)

install: all
	./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)player.1"
	./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)player.html"
	./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)playerctl.1"
	./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "$(OBJDIR)playerctl.html"

uninstall:
	./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "player.1"
	./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "player.html"
	./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "playerctl.1"
	./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "playerctl.html"

.PHONY: all clean distclean install uninstall
