
# -*-makefile-*-
# Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
#     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
#     2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
#     2015, 2016, 2017, 2018, 2019, 2020 Massachusetts Institute of
#     Technology
#
# This file is part of MIT/GNU Scheme.
#
# MIT/GNU Scheme 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 2 of the
# License, or (at your option) any later version.
#
# MIT/GNU Scheme 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 MIT/GNU Scheme; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301, USA.

# **** BEGIN BOILERPLATE ****

SHELL = @SHELL@

prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datarootdir = @datarootdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
docdir = @docdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include

PACKAGE_TARNAME = @PROJECT@
PROJECT = @PROJECT@

DESTDIR =
top_builddir = .

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

LN_S = @LN_S@
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs

# **** END BOILERPLATE ****

htmldir = @htmldir@
pdfdir = @pdfdir@
psdir = @psdir@

INSTALL_INFO_PROG = @INSTALL_INFO_PROG@
TARGETS = @TARGETS@
INST_TARGETS = @INST_TARGETS@

INFO_TARGET = $(TARGET_ROOT).info
HTML_TARGET = $(TARGET_ROOT)
HTML_NOSPLIT_TARGET = $(TARGET_ROOT).html
DVI_TARGET = $(TARGET_ROOT).dvi
PDF_TARGET = $(TARGET_ROOT).pdf
PS_TARGET = $(TARGET_ROOT).ps

GS = gs
EPS2EPS = eps2eps
PS2PDF = ps2pdf
PS2PNG = $(GS) -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300

TEX_OPTIONS = --quiet $(EXTRA_TEX_OPTIONS)

FIGURES_PNG = $(FIGURES_EPS:.eps=.png)
FIGURES_PDF = $(FIGURES_EPS:.eps=.pdf)

all: $(INFO_TARGET) $(TARGETS)

$(INFO_TARGET): $(SOURCES) $(FIGURES_PNG)
	rm -f $(INFO_TARGET)*
	texi2any --info --output=$(INFO_TARGET) $(TEXINFO_ROOT).texinfo

$(HTML_TARGET)/index.html: $(SOURCES) $(FIGURES_PNG)
	rm -rf $(HTML_TARGET)
	texi2any --html $(TEXINFO_ROOT).texinfo

$(HTML_NOSPLIT_TARGET): $(SOURCES) $(FIGURES_PNG)
	rm -f $(HTML_NOSPLIT_TARGET)
	texi2any --html --no-split $(TEXINFO_ROOT).texinfo

$(PDF_TARGET): $(SOURCES) $(FIGURES_PDF)
	texi2dvi --pdf $(TEX_OPTIONS) --output=$@ $(TEXINFO_ROOT).texinfo

$(PS_TARGET): $(SOURCES) $(FIGURES_EPS)
	-rm -f $(DVI_TARGET)
	texi2dvi --ps $(TEX_OPTIONS) --output=$@ $(TEXINFO_ROOT).texinfo

.SUFFIXES: .eps
.SUFFIXES: .eps.in
.SUFFIXES: .pdf
.SUFFIXES: .png

.eps.in.eps:
	$(EPS2EPS) $(EPS2EPSFLAGS) $< $@.tmp && mv -f $@.tmp $@

.eps.pdf:
	$(PS2PDF) -dEPSCrop -sOutputFile=$@.tmp $< && mv -f $@.tmp $@

.eps.png:
	$(PS2PNG) -dEPSCrop -sOutputFile=$@.tmp $< && mv -f $@.tmp $@

mostlyclean:

clean: mostlyclean
	rm -f $(INFO_TARGET)* $(PDF_TARGET) $(PS_TARGET)
	rm -f $(FIGURES_PDF)
	rm -f $(FIGURES_PNG)
	rm -rf $(HTML_TARGET)
	rm -f $(HTML_NOSPLIT_TARGET)
	rm -rf $(TEXINFO_ROOT).aux $(TEXINFO_ROOT).log $(TEXINFO_ROOT).toc
	rm -rf $(TEXINFO_ROOT).pg $(TEXINFO_ROOT).tp
	rm -rf $(TEXINFO_ROOT).cp* $(TEXINFO_ROOT).fn* $(TEXINFO_ROOT).ky*
	rm -rf $(TEXINFO_ROOT).nv* $(TEXINFO_ROOT).op* $(TEXINFO_ROOT).vr*

distclean: clean
	rm -f Makefile

maintainer-clean: distclean

# The install rules depend on macro variables passwd down from the
# makefile in the top-level documentation directory.

install: install-info-gz $(INST_TARGETS)

install-info: $(INFO_TARGET)
	-rm -f $(DESTDIR)$(infodir)/$(INFO_TARGET)*
	$(INSTALL_DATA) $(INFO_TARGET)* $(DESTDIR)$(infodir)/.
	$(INSTALL_INFO_PROG) --info-dir $(DESTDIR)$(infodir)/ $(INFO_TARGET)

install-info-gz: install-info
	gzip -v $(DESTDIR)$(infodir)/$(INFO_TARGET)*

install-html: $(HTML_TARGET)/index.html $(HTML_NOSPLIT_TARGET)
	-rm -rf $(DESTDIR)$(htmldir)/$(HTML_TARGET)
	$(mkinstalldirs) $(DESTDIR)$(htmldir)/$(HTML_TARGET)
	$(INSTALL_DATA) $(HTML_TARGET)/* $(DESTDIR)$(htmldir)/$(HTML_TARGET)/.
	$(INSTALL_DATA) $(HTML_NOSPLIT_TARGET) $(DESTDIR)$(htmldir)/.

install-pdf: $(PDF_TARGET)
	$(INSTALL_DATA) $(PDF_TARGET) $(DESTDIR)$(pdfdir)/.

install-ps: $(PS_TARGET)
	$(INSTALL_DATA) $(PS_TARGET) $(DESTDIR)$(psdir)/.

.PHONY: all mostlyclean clean distclean maintainer-clean
.PHONY: install-info install-html install-pdf install-ps
