# $Header: /home/amb/cxref/doc/RCS/Makefile.in 1.10 2005/02/01 18:45:07 amb Exp $
#
# C Cross Referencing & Documentation tool. Version 1.6a.
#
# Documentation Makefile.
#
# Written by Andrew M. Bishop
#
# This file Copyright 1995,96,99,2001,2004,05 Andrew M. Bishop
# It may be distributed under the GNU Public License, version 2, or
# any higher version.  See section COPYING of the GNU Public license
# for conditions under which this file may be redistributed.
#

# autoconf things

srcdir=.


# The installation locations

prefix=
mandir=$(DESTDIR)${prefix}/share/man

# The installation program.

INSTALL=/usr/bin/install -c -o root -g wheel

# The Perl program

PERL=perl

# The LaTeX and dvips programs

LATEX=latex
DVIPS=dvips

########

SOURCE_FILES= \
cxref.c       \
cxref.h       \
autoconfig.h  \
datatype.h    \
comment.c     \
file.c        \
func.c        \
preproc.c     \
type.c        \
var.c         \
xref.c        \
warn-raw.c    \
latex.c       \
latex-style.c \
html.c        \
html-style.c  \
rtf.c         \
sgml.c        \
parse-yacc.h  \
parse-lex.c   \
parse-yacc.c  \
parse-yy.h    \
slist.c       \
memory.h      \
memory.c      \
version.h

########

docs : faq-html readme examples

all : docs

########

install :
	[ -d $(mandir)/man1 ] || $(INSTALL) -d $(mandir)/man1
	$(INSTALL) -m 644 $(srcdir)/README.man $(mandir)/man1/cxref.1

########

clean :
	-rm -f *~ \
	example/*

####

distclean : clean
	-rm -f Makefile

########

faq-html : $(srcdir)/FAQ $(srcdir)/FAQ-html.pl
	[ "x$(PERL)" = "x" ] || $(PERL) $(srcdir)/FAQ-html.pl < $(srcdir)/FAQ > FAQ.html

########

readme : $(srcdir)/README.c
	[ -f README.c ] || cp $(srcdir)/README.c .
	../src/cxref -O. -NREADME-TMP -xref README.c
	../src/cxref -O. -NREADME-TMP -xref README.c -latex -html-src -rtf -sgml
	mv README.c.tex README_c.tex
	[ "x$(LATEX)" = "x" ] || $(LATEX) $(srcdir)/README.tex > /dev/null 2>&1
	[ "x$(LATEX)" = "x" ] || $(LATEX) $(srcdir)/README.tex
	[ "x$(DVIPS)" = "x" ] || $(DVIPS) README.dvi -o README.ps
	@rm -f README.aux README.log README.toc
	@rm -f README-TMP.*

########

examples :
	-@[ ! "$(srcdir)" = "." ] && \
	echo "CXREF: " && \
	echo "CXREF: Not creating example cross-reference of cxref source code." && \
	echo "CXREF: Compiling outside of source tree makes this too complex." && \
	echo "CXREF: "
#
# Create the cross reference files, output files and index
#
	@[ ! "$(srcdir)" = "." ] || \
	  ( cd ../src ; \
	  for file in $(SOURCE_FILES) ; do \
	     echo Cross referencing $$file ; \
	     ./cxref -xref -O../doc/example -Ncxref $$file; \
	  done ; \
	  for file in $(SOURCE_FILES) ; do \
	     echo Documenting $$file ; \
	     ./cxref -warn-xref -xref -O../doc/example -Ncxref -latex -html-src -rtf -sgml $$file; \
	  done ; \
	  echo Indexing ; \
	  ./cxref -index-all -O../doc/example -Ncxref -latex -html -rtf -sgml \
	  )
#
# Create the final output and cross references using latex
#
	@[ ! "$(srcdir)" = "." ] || [ "x$(LATEX)" = "x" ] || \
	  ( cd example ; \
	  echo Running LaTeX ; \
	  $(LATEX) cxref.tex > /dev/null 2>&1 ; \
	  $(LATEX) cxref.tex \
	  )

########