# $Header: /home/amb/CVS/cxref/doc/Makefile.in,v 1.11 2010-10-19 18:18:04 amb Exp $
#
# C Cross Referencing & Documentation tool. Version 1.6d.
#
# Documentation Makefile.
#
# Written by Andrew M. Bishop
#
# This file Copyright 1995-2010 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=@srcdir@
VPATH=@srcdir@

# The installation locations

prefix=@prefix@
datarootdir=@datarootdir@
mandir=$(DESTDIR)@mandir@

# The installation program.

INSTALL=@INSTALL@

# 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  -D_Float128='long double' -O. -NREADME-TMP -xref README.c
	../src/cxref  -D_Float128='long double' -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 \
	  )

########
