## ----------------------------------------------------------------------------
##                                                                           --
##                      GNADE  : GNu Ada Database Environment                --
##                                                                           --
##  Filename        : $Source: /var/cvs/gnuada/gnade/doc/build/Makefile,v $
##  Description     : Top level makefile for the documentation
##  Author          : Juergen Pfeifer <juergen.pfeifer@gmx.net> 
##  Created On      : 17-Jan-2001
##  Last Modified By: $Author: me $
##  Last Modified On: $Date: 2001/05/26 12:23:48 $
##  Status          : $State: Exp $
##
##  Copyright (C) 2000-2001
##
##  GNADE is copyrighted by the persons and institutions enumerated in the   --
##  AUTHORS file. This file is located in the root directory of the          --
##  GNADE distribution.                                                      --
##                                                                           --
##  GNADE is free software;  you can redistribute it  and/or modify it under --
##  terms of the  GNU General Public License as published  by the Free Soft- --
##  ware  Foundation;  either version 2,  or (at your option) any later ver- --
##  sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
##  OUT 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  distributed with GNAT;  see file COPYING.  If not, write --
##  to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
##  MA 02111-1307, USA.                                                      --
##                                                                           --
##  As a special exception,  if other files  instantiate  generics from      --
##  GNADE Ada units, or you link GNADE Ada units or libraries with other     --
##  files  to produce an executable, these  units or libraries do not by     --
##  itself cause the resulting  executable  to  be covered  by the  GNU      --
##  General  Public  License.  This exception does not however invalidate    --
##  any other reasons why  the executable file  might be covered by the      --
##  GNU Public License.                                                      --
##                                                                           --
##  GNADE is implemented to work with GNAT, the GNU Ada compiler.            --
##                                                                           --
## ----------------------------------------------------------------------------
##
##  Functional Description
##  ======================
##  This makefile builds the various documentation formats. The input 
##  is SGML docbook.
##
##  If the aspell utility is installed on the system, a gobal spell check
##  is done which summerizes all missspellings. If the number of 
##  errors is to large consider the execution of a real spellcheck 
##  run.
##
##  Restrictions
##  ============
##  - Spellcheck is based upon the aspell utility.
##
##  References
##  ==========
##  None
##
##
sinclude ../../make.conf

##
## 
##
DOCBASE=gnade
DOCDIR=$(shell cd .. && pwd)
PARTS=$(DOCBASE).sgml esql.sgml odbc.sgml bindings.sgml \
		gpl.sgml gfdl.sgml faq.sgml porting.sgml gnudb.sgml

TARGETS= $(DOCDIR)/html/$(DOCBASE).html   \
		$(DOCDIR)/$(DOCBASE).ps   \
		$(DOCDIR)/$(DOCBASE).pdf 

##
## for all we do nothing
##
all ::  

##
## Build the documentation and check if possible spelling errors.
##
documentation :: $(USED_SPELLCHECKER) $(TARGETS)

doc :: 
	$(MAKE) USED_SPELLCHECKER="" documentation
##
## Generate PDF documents
##
$(DOCDIR)/$(DOCBASE).pdf :: $(DOCBASE).tex
	./docbuild.$(BUILD_DISTRIBUTION) --pdf $(DOCBASE).sgml
	mv $(DOCBASE).pdf $(DOCDIR)

$(DOCDIR)/$(DOCBASE).ps :: $(DOCBASE).tex
	./docbuild.$(BUILD_DISTRIBUTION) --ps $(DOCBASE).sgml
	mv $(DOCBASE).ps $(DOCDIR)

$(DOCDIR)/html/$(DOCBASE).html ::  $(PARTS) 
	./docbuild.$(BUILD_DISTRIBUTION) --html $(DOCBASE).sgml
	rm -rf $(DOCDIR)/html
	-mkdir -p $(DOCDIR)/html
	-mv *.html *.htm $(DOCDIR)/html

$(DOCBASE).tex :: $(PARTS)
	./docbuild.$(BUILD_DISTRIBUTION) --tex $(DOCBASE).sgml

##
## The gnade.words file contains all unknown words specific to 
## the GNADE project (abrevations, names etc..). This file has 
## to be edited manualy in order to remove real typing errors.
##
gnade.words: $(PARTS)
	cat $(PARTS) | aspell --lang=english --mode=sgml -l  | \
	    sort | uniq > gnade.words
	@echo "---------------------------------------------- "
	@echo "Remove typing errors from the gnade.words file "
	@echo "manually and execute make gnade-words.dat"
	@echo "-----------------------------------------------"

##
## gnerate a dictionary with gnade specific words
##
gnade-words.dat:  gnade.words
	aspell --lang=english create master ./gnade-words.dat < gnade.words

##
## perform the actual spell check by gnerating a list of 
## unknown words.
##
spellcheck_aspell:
	cat $(PARTS) | aspell --mode=sgml --lang=english \
	--add-extra-dicts=./gnade-words.master -l | sort | uniq

clean ::
	rm -f *.aux *.log *.tex *.dvi *.out *.pdf *.htm *.html *~ *.bak

distclean :: clean
	rm -f *.dvi *.ps *.pdf *.rtf
	rm -rf $(DOCDIR)/html 
	rm -rf $(DOCDIR)/*.pdf

