# Makefile for octave's doc/liboctave directory
#
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
#               2005, 2006, 2007 John W. Eaton
#
# This file is part of Octave.
# 
# Octave 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.
# 
# Octave 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 Octave; see the file COPYING.  If not, see
# <http://www.gnu.org/licenses/>.

TOPDIR = ../..

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

include $(TOPDIR)/Makeconf

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

SOURCES =

MAIN_TEXINFO = liboctave.texi

SUB_TEXINFO = \
	array.texi bugs.texi cp-idx.texi dae.texi diffeq.texi \
	error.texi factor.texi fn-idx.texi install.texi intro.texi \
	matvec.texi nleqn.texi nlfunc.texi ode.texi \
	optim.texi preface.texi quad.texi range.texi

TEXINFO_SOURCE = $(MAIN_TEXINFO) $(SUB_TEXINFO)

TEXINFO = $(TEXINFO_SOURCE) ../conf.texi

FORMATTED = liboctave.dvi liboctave.ps liboctave.pdf liboctave.info

DISTFILES = $(addprefix $(srcdir)/, Makefile.in gpl.texi $(TEXINFO_SOURCE)) \
	 $(FORMATTED)

DISTDIRS = HTML

SPELL = $(patsubst %.texi, %.spell, $(TEXINFO))

%.spell : %.texi
	rm -f $@
	$(SED) -e 's/@@/ at /g' -e 's/@[a-zA-Z]*//g' $< | spell > $@.tmp
	mv $@.tmp $@

all: liboctave.info liboctave.dvi liboctave.ps liboctave.pdf HTML/index.html
.PHONY: all

liboctave.info: $(TEXINFO)
	-$(MAKEINFO) -I.. -I$(srcdir) -I$(srcdir)/.. $<

liboctave.dvi: $(TEXINFO)
	-TEXINPUTS="..$(sepchar)$(srcdir)$(sepchar)$(srcdir)/..$(sepchar)$(TEXINPUTS)$(sepchar)" \
	  $(TEXI2DVI) $<

liboctave.ps: liboctave.dvi
	-dvips -o $@ $<

liboctave.pdf: $(TEXINFO)
	-TEXINPUTS="..$(sepchar)$(srcdir)$(sepchar)$(srcdir)/..$(sepchar)$(TEXINPUTS)$(sepchar)" \
	  $(TEXI2PDF) $<

HTML/index.html: $(TEXINFO)
	-$(MAKEINFO) --html --ifinfo --output=HTML -I.. -I$(srcdir) -I$(srcdir)/.. $<

check:
.PHONY: check

install install-strip: all
.PHONY: install install-strip

uninstall:
	rm -f $(DESTDIR)$(infodir)/liboctave.info*
.PHONY: uninstall

tags: $(SOURCES)
	ctags $(SOURCES)

TAGS: $(SOURCES)
	etags $(SOURCES)

spell: $(SPELL)
.PHONY: spell

mostlyclean clean:
	rm -f liboctave.cp liboctave.fn liboctave.pg liboctave.tp \
	liboctave.vr liboctave.ky liboctave.op liboctave.vrs \
	liboctave.kys liboctave.ops liboctave.cps liboctave.fns \
	liboctave.pgs liboctave.tps liboctave.aux liboctave.log \
	liboctave.toc
.PHONY: mostlyclean clean

distclean: clean
	rm -f Makefile
.PHONY: distclean

maintainer-clean: distclean
	rm -f tags TAGS liboctave.info liboctave.info-*
	rm -f liboctave.dvi liboctave.ps liboctave.pdf
	rm -rf HTML
.PHONY: maintainer-clean

dist: all
	ln $(DISTFILES) ../../`cat ../../.fname`/doc/liboctave
	for dir in $(DISTDIRS); do \
	  mkdir ../../`cat ../../.fname`/doc/liboctave/$$dir; \
	  ln ../../doc/liboctave/$$dir/* ../../`cat ../../.fname`/doc/liboctave/$$dir; \
	done
.PHONY: dist
