VPATH		= @srcdir@
srcdir		= @srcdir@
top_srcdir	= @top_srcdir@

SUBDIRS		= fr ja sv

include ../Makefile.conf

MAN5PAGES	= deb-control.5 deb-old.5 deb.5

ifeq (@USE_SGML_DOC@, true)
all: internals.html/index.html all-recursive
else
all: all-recursive
endif

clean: clean-recursive
	$(RM) $(srcdir)/manuals-version
	$(RM) -rf internals.html/

distclean: clean distclean-recursive
	$(RM) Makefile

install: install-doc

manuals-version: $(top_srcdir)/version-nr
	set -e ; v=`sed -ne '1s/.*(\(.*\)).*/\1/' $(srcdir)/ChangeLog` ; \
	echo "<!entity manuals-version \"$$v\">" > $@
	echo "<!entity dpkg-version \"$(VERSION)\">" >> $@

internals.html/index.html: internals.sgml manuals-version
	debiandoc2html -n -D. $<

install-doc: install-doc-recursive
	$(mkinstalldirs) $(DESTDIR)$(man5dir) 
	set -e ; for i in $(MAN5PAGES) ; do \
		if test -f $$i ; then d= ; else d="$(srcdir)/" ; fi ; \
		$(INSTALL_DATA) $$d$$i $(DESTDIR)$(man5dir) ; \
	done
ifeq (@USE_SGML_DOC@, true)
	$(mkinstalldirs) $(DESTDIR)$(docdir)/internals/
	set -e ; for i in internals.html/* ; do \
		bn=`basename $$i` ; \
		$(INSTALL_DATA) $$i $(DESTDIR)$(docdir)/internals/$$bn ; \
	done
endif
	$(INSTALL_DATA) $(srcdir)/ChangeLog $(DESTDIR)$(docdir)/ChangeLog.manuals
	set -e ; for i in ChangeLog THANKS TODO ; do \
		$(INSTALL_DATA) $(top_srcdir)/$$i $(DESTDIR)$(docdir) ; \
	done
	$(INSTALL_DATA) $(top_srcdir)/COPYING $(DESTDIR)$(copyingfile)

all-recursive install-recursive install-doc-recursive clean-recursive distclean-recursive:
	set -e ; target=`echo $@ | $(SED) s/-recursive//`; \
		for s in $(SUBDIRS) ; do \
		$(MAKE) $(MFLAGS) -C $$s $$target ; \
	done;

.PHONY: all clean distclean install install-doc
.PHONY: all-recursive clean-recursive distclean-recursive install-recursive
.PHONY: install-doc-recursive
