## Makefile for the doc subdirectory of GNU libunistring.
## Copyright (C) 2009, 2011 Free Software Foundation, Inc.
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.

## Process this file with automake to produce Makefile.in.

AUTOMAKE_OPTIONS = 1.5 gnits
EXTRA_DIST =
MOSTLYCLEANFILES =

# List of -I options referring to directories that contain texinfo sources
# used by this directory.
# Should contain at least one -I option, to work around a bug in texi2dvi 1.13,
# see <http://lists.gnu.org/archive/html/bug-automake/2009-04/msg00029.html>.
TEXINCLUDES = -I .

MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@
MAKEINFOFLAGS = $(TEXINCLUDES) --no-split

info_TEXINFOS = libunistring.texi
# List of texinfo sources @included by libunistring.texi, excluding version.texi.
libunistring_TEXINFOS = \
  unitypes.texi unistr.texi uniconv.texi unistdio.texi uniname.texi \
  unictype.texi uniwidth.texi unigbrk.texi uniwbrk.texi unilbrk.texi \
  uninorm.texi unicase.texi uniregex.texi \
  gpl.texi lgpl.texi fdl.texi

# The dependencies of stamp-vti generated by automake are incomplete.
# So we have to duplicate the entire rule which would otherwise be generated
# by automake.
$(srcdir)/stamp-vti: $(info_TEXINFOS) $(libunistring_TEXINFOS) $(top_srcdir)/version.sh
	(dir=.; test -f ./libunistring.texi || dir=$(srcdir); \
	set `$(SHELL) $(top_srcdir)/build-aux/mdate-sh $$dir/libunistring.texi`; \
	echo "@set UPDATED $$1 $$2 $$3"; \
	echo "@set UPDATED-MONTH $$2 $$3"; \
	echo "@set EDITION $(VERSION)"; \
	echo "@set VERSION $(VERSION)") > vti.tmp
	cmp -s vti.tmp $(srcdir)/version.texi \
	  || (echo "Updating $(srcdir)/version.texi"; \
	      cp vti.tmp $(srcdir)/version.texi)
	rm -f vti.tmp
	cp $(srcdir)/version.texi $@

# We distribute only the split HTML documentation.
# The user can generate the others, via
#   make libunistring.ps
#   make libunistring.pdf
#   make libunistring.html

all-local: html-local
install-data-local: install-html
installdirs-local: installdirs-html
uninstall-local: uninstall-html
dist-hook: dist-html

html-local: html-split
# Override of automake's definition. The HTML files we want to distribute are
# not the ones that automake knows about, and we cannot define HTMLS to a value
# containing wildcards.
install-html: install-html-split
	@:
uninstall-html: uninstall-html-split
dist-html: dist-html-split

# CLEANFILES: libunistring.{dvi,ps,pdf,html} are already known to automake.
MAINTAINERCLEANFILES = libunistring_*.html


# Documentation in DVI format.

# Override of automake's definition:
#TEXI2DVI = @TEXI2DVI@
TEXI2DVI = @TEXI2DVI@ $(TEXINCLUDES)

# The install-dvi target is already defined by automake.

installdirs-dvi:
	$(MKDIR_P) $(DESTDIR)$(dvidir)

uninstall-dvi:
	$(RM) $(DESTDIR)$(dvidir)/libunistring.dvi


# Documentation in Postscript format.

# Override of automake's definition:
#DVIPS = @DVIPS@
DVIPS = @DVIPS@ -D600

libunistring.ps: libunistring.dvi
	$(DVIPS) -o $@ `if test -f libunistring.dvi; then echo libunistring.dvi; else echo $(srcdir)/libunistring.dvi; fi`

# The install-ps target is already defined by automake.

installdirs-ps:
	$(MKDIR_P) $(DESTDIR)$(psdir)

uninstall-ps:
	$(RM) $(DESTDIR)$(psdir)/libunistring.ps


# Documentation in Portable Document Format.

# Override of automake's definition:
#TEXI2PDF = @TEXI2DVI@ --pdf
TEXI2PDF = @TEXI2DVI@ --pdf $(TEXINCLUDES)

# The install-pdf target is already defined by automake.

installdirs-pdf:
	$(MKDIR_P) $(DESTDIR)$(pdfdir)

uninstall-pdf:
	$(RM) $(DESTDIR)$(pdfdir)/libunistring.pdf


# Documentation in HTML format.

TEXI2HTML = @PERL@ $(top_srcdir)/build-aux/texi2html

html-monolithic: libunistring.html
html-split: libunistring_toc.html

# Override of automake's definition.
# We want to use texi2html, not makeinfo --html.
libunistring.html: libunistring.texi version.texi $(libunistring_TEXINFOS)
	$(TEXI2HTML) $(TEXINCLUDES) -no-sec-nav -no-menu -toc-links -number -monolithic `if test -f libunistring.texi; then echo libunistring.texi; else echo $(srcdir)/libunistring.texi; fi`

libunistring_toc.html: libunistring.texi version.texi $(libunistring_TEXINFOS)
	case "@PERL@" in \
	  *"/missing perl") \
	     $(TEXI2HTML) $(TEXINCLUDES) -no-sec-nav -no-menu -toc-links -number -split_chapter `if test -f libunistring.texi; then echo libunistring.texi; else echo $(srcdir)/libunistring.texi; fi` || exit 0 ;; \
	  *) $(RM) libunistring_*.html ; \
	     $(TEXI2HTML) $(TEXINCLUDES) -no-sec-nav -no-menu -toc-links -number -split_chapter `if test -f libunistring.texi; then echo libunistring.texi; else echo $(srcdir)/libunistring.texi; fi` ;; \
	esac \
	&& { mv libunistring/libunistring.html libunistring_toc.html; \
	     mv libunistring/*.html .; \
	     rmdir libunistring; \
	   }

install-html-monolithic: libunistring.html
	$(MKDIR_P) $(DESTDIR)$(htmldir)
	$(INSTALL_DATA) `if test -f libunistring.html; then echo .; else echo $(srcdir); fi`/libunistring.html $(DESTDIR)$(htmldir)/libunistring.html

install-html-split: libunistring_toc.html
	$(MKDIR_P) $(DESTDIR)$(htmldir)
	for file in `if test -f libunistring_toc.html; then echo .; else echo $(srcdir); fi`/libunistring_*.html; do \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(htmldir)/`basename $$file`; \
	done

installdirs-html:
	$(MKDIR_P) $(DESTDIR)$(htmldir)

uninstall-html-monolithic:
	$(RM) $(DESTDIR)$(htmldir)/libunistring.html

uninstall-html-split:
	$(RM) $(DESTDIR)$(htmldir)/libunistring_*.html

dist-html-monolithic:
	$(MKDIR_P) $(distdir)/
	file=libunistring.html; \
	if test -f $$file; then d=.; else d=$(srcdir); fi; \
	cp -p $$d/$$file $(distdir)/$$file || exit 1

# We would like to put libunistring_*.html into EXTRA_DIST, but it doesn't work.
dist-html-split: libunistring_toc.html
	$(MKDIR_P) $(distdir)/
	file=libunistring_toc.html; \
	if test -f $$file; then d=.; else d=$(srcdir); fi; \
	for file in `cd $$d && echo libunistring_*.html`; do \
	  cp -p $$d/$$file $(distdir)/$$file || exit 1; \
	done
