include $(top_srcdir)/misc/Makefile.common

hackersguide_sgml = hackersguide.sgml \
		    intro.sgml \
		    library.sgml \
		    overview.sgml \
		    internals.sgml \
		    stream.sgml \
		    output.sgml

docs_DATA = hackersguide.html \
            architecture.png library.png overlays.png post_frame.png

EXTRA_DIST = README $(hackersguide_sgml) \
	architecture.fig library.fig overlays.fig post_frame.fig $(docs_DATA)

docsdir = $(prefix)/share/doc/xine/hackersguide

docs: $(docs_DATA)

distclean-local: clean-docs

docs-prepare: $(addprefix $(srcdir)/, $(hackersguide_sgml) $(wildcard *.fig))
	if test "$(srcdir)" != "." ; then \
	  for file in $(hackersguide_sgml) *.fig ; do \
	    test -f ./$$file -a ./$$file -nt $(srcdir)/$$file || cp $(srcdir)/$$file .; \
	  done ; \
	fi

clean-docs:
	rm -f $(docs_DATA)
	test "x$(srcdir)" = x. || rm -f $(hackersguide_sgml)

dist-hook:
	@if test x"$(distcheck_lax)" = x ; then \
	  $(MAKE) fail_if_missing=yes docs ; \
	else \
	  $(MAKE) docs ; \
	fi

if HAVE_SGMLTOOLS
hackersguide.html: $(hackersguide_sgml)
	@$(MAKE) docs-prepare
	$(SGMLTOOLS) -b onehtml hackersguide.sgml;
else
hackersguide.html: $(hackersguide_sgml)
	@$(MAKE) docs-prepare
	if test x"$(fail_if_missing)" = x"yes"; then \
	  echo "Please install sgmltools-lite."; \
	  exit 1; \
	fi
	if test x"$(fail_if_missing)" != x"yes"; then \
	  touch $@; \
	  sleep 1; \
	  touch $(notdir $^); \
	fi
endif

if HAVE_FIG2DEV
%.png: %.fig
	@$(MAKE) docs-prepare
	$(FIG2DEV) -L png -S 4 $< $@;
else
%.png: %.fig
	@$(MAKE) docs-prepare
	if test x"$(fail_if_missing)" = x"yes"; then \
	  echo "Please install fig2dev."; \
	  exit 1; \
	fi
	if test x"$(fail_if_missing)" != x"yes"; then \
	  touch $@; \
	  sleep 1; \
	  touch $(notdir $^); \
	fi
endif
