#*********************************************************************#
#                                                                     #
#                             Active-DVI                              #
#                                                                     #
#                   Projet Cristal, INRIA Rocquencourt                #
#                                                                     #
#  Copyright 2002 Institut National de Recherche en Informatique et   #
#  en Automatique.  All rights reserved.  This file is distributed    #
#  under the terms of the GNU Lesser General Public License.          #
#                                                                     #
#  Jun Furuse, Didier Rmy and Pierre Weis.                           #
#  Contributions by Roberto Di Cosmo, Didier Le Botlan,               #
#  Xavier Leroy, and Alan Schmitt.                                    #
#                                                                     #
#  Based on Mldvi by Alexandre Miquel.                                #
#*********************************************************************#

# $Id: Makefile,v 1.43 2004/10/02 21:35:09 weis Exp $

include ../Makefile.config

# See also file MakeHTML to recompile HTML files for the Web site.

SETTEXINPUTS=TEXINPUTS=.:../tex:/usr/lib/hevea/:/usr/local/lib/hevea/:/usr/local/share/texmf/tex//:$$TEXINPUTS

LATEX=$(SETTEXINPUTS) latex
DVIPS=TEXPSHEADERS=.:../tex: dvips
HEVEA=$(PATH_HEVEA) -entities -I ../tex
IMAGEN=$(SETTEXINPUTS) imagen
PDFIMAGEN=pdfimagen
DVIPDFM=dvipdfm

all: manual.dvi manual.ps manual.pdf manual.html \
    splash.dvi splash.ps \
    scratch_write_splash.dvi scratch_write_splash.ps \
    scratch_draw_splash.dvi scratch_draw_splash.ps \
    mathmode.dvi \
    advi_remote.dvi advi_remote.html \
    advi.1

clean::
	$(RM) manual.advi manual.html
	$(RM) *~ *.out
	$(RM) *.aux *.log *.dvi *.toc *.ps
	$(RM) *.pdf *.pdfm
	$(RM) *.haux *.htoc *.ima
	$(MAKE) -f MakeHTML clean
	$(MAKE) -f MakeMan clean

distribute: all web

web:
	$(MAKE) -f MakeHTML all
	$(MAKE) -f MakeMan all

advi.1: ../doc_src/advi.man
	$(MAKE) -f MakeMan all


manual.dvi: ../tex/advi.sty manual.sty splash_contents.tex \
       scratch_write_splash_contents.tex scratch_draw_splash_contents.tex
splash.dvi: splash_contents.tex
scratch_write_splash.dvi: scratch_write_splash_contents.tex
scratch_draw_splash.dvi: scratch_draw_splash_contents.tex

ifeq ($(HAVE_HEVEA),true)
manual.html: manual.tex manual.sty macros.hva 
advi_remote.html: advi_remote.tex manual.sty macros.hva 
else
manual.html:
advi_remote.html:
endif

.SUFFIXES: .tex .dvi .advi .ps .pdf .pdfm .html .ima

.tex.dvi:
	# To avoid default hypertex.cfg if it exists.
	# Active-DVI really needs the hypertex driver...
	$(LATEX) '\def\driver{hypertex}\input' $<
	$(LATEX) '\def\driver{hypertex}\input' $<
	$(LATEX) '\def\driver{hypertex}\input' $<

.tex.ps:
	if [ -e $*.dvi ]; then \
	  $(MV) $*.dvi $*.advi; \
	fi
	$(LATEX) '\def\driver{dvips}\input' $<
	$(DVIPS) -o $@ $*.dvi
	  $(MV) $*.dvi $*.bdvi
	if [ -e $*.advi ]; then \
	  $(MV) $*.advi $*.dvi; \
	fi

.tex.pdf:
	if [ -e $*.dvi ]; then \
	  $(MV) $*.dvi $*.advi; \
	fi
	$(LATEX) '\def\driver{dvipdfm}\input' $<
	- $(DVIPDFM) -o $@ $*.dvi
	if [ -e $*.advi ]; then \
	  $(MV) $*.advi $*.dvi; \
	fi

.advi.dvi:
	cp -p $< $*.dvi

.html.ima:
	if [ -f $*.image.tex ]; then $(PDFIMAGEN) $*; fi
	touch $*.ima

.tex.html:
	$(HEVEA) -fix macros.hva -o $*.html $*.tex
