#
#  Makefile - Makefile for af documentation.
#  Copyright (C) 1992, 1993, 1994, 1995, 1996 Malc Arnold.
#
#  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 2, 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, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
##############################################################################
# RCS Info
#
# $Id: Makefile.in,v 2.1 1997/11/16 00:28:02 malc Exp $
#
##############################################################################
# Where do things go?
LIBDIR=@LIBDIR@
ETCDIR=@ETCDIR@
INFODIR=@INFODIR@
MAN1DIR=@MAN1DIR@
MAN5DIR=@MAN5DIR@
MAN1EXT=@MAN1EXT@
MAN5EXT=@MAN5EXT@

# Required programs
SHELL=/bin/sh
INSTALL=@INSTALL@
INSTALLDIR=../install.sh
SED=sed
MANCOMPRESS=@MANCOMPRESS@
INFOCOMPRESS=@INFOCOMPRESS@
MAKEINFO=makeinfo
TEXI2HTML=texi2html
HTMLOPTS=-monolithic
LATEX=latex
DVIPS=dvips
DVIPSOPTS=-D300 -q -f

# Install options
DIRINSTOPTS=@IDIROPTS@
DOCINSTOPTS=@IDOCOPTS@

# How to process a manual page
SEC1=@MAN1SEC@
SEC5=@MAN5SEC@
MAKEMAN=sed -e "s:%SEC1%:$(SEC1):g" -e "s:%SEC5%:$(SEC5):g" \
-e "s:%LIBDIR%:$(LIBDIR):g" -e "s:%ETCDIR%:$(ETCDIR):g"

# The files generated by Configure and latex
CONFIG=Makefile
LTXTMP=refcard.aux refcard.log

# What we must make.
TARGETS=$(MAN1) $(MAN5) $(HELP) $(INFO) $(HTML)
MAN1=af.$(MAN1EXT) afack.$(MAN1EXT) Rnaf.$(MAN1EXT)
MAN5=afalias.$(MAN5EXT) mailcap.af.$(MAN5EXT) \
mime.types.af.$(MAN5EXT) mime.charsets.af.$(MAN5EXT)
HELP=af.help
INFO=af.info
HTML=af.html
DVI=refcard.dvi
PS=refcard.ps

# Sources for the info and latex documents
TEXI=af.texi concepts.texi basics.texi message.texi \
folder.texi custom.texi glossary.texi
TEX=refcard.tex

# How to make it
all: $(TARGETS)

install: all
	$(INSTALLDIR) $(DIRINSTOPTS) $(LIBDIR)
	test "$(LIBDIR)" = "$(ETCDIR)" || $(INSTALLDIR) $(DIRINSTOPTS) $(ETCDIR)
	$(INSTALL) $(DOCINSTOPTS) $(HELP) $(LIBDIR)
	rm -f $(INFODIR)/$(INFO)*
	$(INSTALL) $(DOCINSTOPTS) $(INFO)* $(INFODIR)
	test -z "$(INFOCOMPRESS)" || $(INFOCOMPRESS) $(INFODIR)/$(INFO)*
	$(INSTALL) $(DOCINSTOPTS) $(MAN1) $(MAN1DIR)
	$(INSTALL) $(DOCINSTOPTS) $(MAN5) $(MAN5DIR)

clean:
	rm -f $(MAN1) $(MAN5) $(HTML) $(DVI) $(PS) $(LTXTMP) 

distclean: clean
	rm -f $(CONFIG)

spotless: distclean
	rm -f $(INFO)*

# Rules for generating manual pages
af.$(MAN1EXT): af.man
	$(MAKEMAN) af.man | $(MANCOMPRESS) > $@
afack.$(MAN1EXT): afack.man
	$(MAKEMAN) afack.man | $(MANCOMPRESS) > $@
Rnaf.$(MAN1EXT): Rnaf.man
	$(MAKEMAN) Rnaf.man | $(MANCOMPRESS) > $@
afalias.$(MAN5EXT): afalias.man
	$(MAKEMAN) afalias.man | $(MANCOMPRESS) > $@
mailcap.af.$(MAN5EXT): mailcap.man
	$(MAKEMAN) mailcap.man | $(MANCOMPRESS) > $@
mime.types.af.$(MAN5EXT): mime.types.man
	$(MAKEMAN) mime.types.man | $(MANCOMPRESS) > $@
mime.charsets.af.$(MAN5EXT): mime.charsets.man
	$(MAKEMAN) mime.charsets.man | $(MANCOMPRESS) > $@

# Rules for building the info manual
$(INFO): $(TEXI)
	$(MAKEINFO) af.texi

# And the HTML version
$(HTML): $(TEXI)
	$(TEXI2HTML) $(HTMLOPTS) af.texi

# And how to make the reference card
$(DVI):	$(TEX)
	$(LATEX) $(TEX)
$(PS):	$(DVI)
	$(DVIPS) $(DVIPSOPTS) < $(DVI) > $(PS)
