05babecda0dab6675663ffe6e74055568a91b782
[clsql.git] / doc / Makefile
1 ##############################################################################
2 # FILE IDENTIFICATION
3
4 #  Name:         Makefile
5 #  Purpose:      Makefile for the clsql documentation
6 #  Programer:    Kevin M. Rosenberg
7 #  Date Started: Mar 2002
8 #
9 #  CVS Id:   $Id$
10 #
11 # This file, part of CLSQL, is Copyright (c) 2002-2003 by Kevin M. Rosenberg
12 #
13 # CLSQL users are granted the rights to distribute and use this software
14 # as governed by the terms of the Lisp Lesser GNU Public License
15 # (http://opensource.franz.com/preamble.html), also known as the LLGPL.
16 ##############################################################################
17
18 DOCFILE_BASE_DEFAULT:=clsql
19 DOCFILE_EXT_DEFAULT:=xml
20
21
22 # Standard docfile processing
23
24 DEBIAN=$(shell expr "`cat /etc/issue 2> /dev/null`" : '.*Debian.*')
25 SUSE=$(shell expr "`cat /etc/issue 2> /dev/null`" : '.*SuSE.*')
26 SUSE91=$(shell expr "`cat /etc/issue 2> /dev/null`" : '.*SuSE Linux 9.1.*')
27 REDHAT=$(shell expr "`cat /etc/issue 2> /dev/null`" : '.*Red Hat.*')
28 MANDRAKE=$(shell expr "`cat /etc/issue 2> /dev/null`" : '.*Mandrake.*')
29 DARWIN=$(shell expr "`uname -a`" : '.*Darwin.*')
30
31
32 ifneq (${DEBIAN},0)
33 OS:=debian
34 else
35   ifneq (${SUSE91},0)
36     OS=suse91
37   else
38     ifneq (${SUSE},0)
39       OS=suse
40     else   
41       ifneq (${REDHAT},0)
42         OS=redhat
43       else   
44         ifneq (${MANDRAKE},0)
45           OS=mandrake
46         else   
47           ifneq (${DARWIN},0)
48             OS=darwin
49           endif 
50         endif
51       endif
52     endif
53   endif
54 endif
55
56 ifndef DOCFILE_BASE
57 DOCFILE_BASE=${DOCFILE_BASE_DEFAULT}
58 endif
59
60 ifndef DOCFILE_EXT
61 DOCFILE_EXT=${DOCFILE_EXT_DEFAULT}
62 endif
63
64 DOCFILE:=${DOCFILE_BASE}.${DOCFILE_EXT}
65 FOFILE:=${DOCFILE_BASE}.fo
66 PDFFILE:=${DOCFILE_BASE}.pdf
67 PSFILE:=${DOCFILE_BASE}.ps
68 DVIFILE:=${DOCFILE_BASE}.dvi
69 TXTFILE:=${DOCFILE_BASE}.txt
70 HTMLFILE:=${DOCFILE_BASE}.html
71 TMPFILES:=${DOCFILE_BASE}.aux ${DOCFILE_BASE}.out ${DOCFILE_BASE}.log
72 DOCFILES:=$(shell echo *.xml *.xsl)
73
74 ifeq ($(XSLTPROC),)
75   XSLTPROC:=xsltproc
76 endif
77
78 CATALOG:=`pwd`/catalog-${OS}.xml
79 CHECK:=XML_CATALOG_FILES="$(CATALOG)" xmllint --noout --xinclude --postvalid $(DOCFILE) || exit 1
80
81 .PHONY: all
82 all: html pdf 
83
84 .PHONY: dist
85 dist: html pdf
86
87 .PHONY: doc
88 doc: html pdf
89
90 .PHONY: check
91 check:
92         @echo "Operating system detected: ${OS}"
93         @$(CHECK)
94
95 .PHONY: html
96 html: html.tar.gz
97
98 html.tar.gz: $(DOCFILES) Makefile 
99         @rm -rf html
100         @mkdir html
101         @XML_CATALOG_FILES="$(CATALOG)" $(XSLTPROC) --stringparam chunker.output.encoding UTF-8 \
102                  --xinclude --output html/ html_chunk.xsl $(DOCFILE)
103         @GZIP='-9' tar czf html.tar.gz html 
104
105 .PHONY: fo
106 fo: ${FOFILE}
107
108 ${FOFILE}: $(DOCFILES) Makefile 
109         @XML_CATALOG_FILES="$(CATALOG)" xsltproc --xinclude --stringparam fop1.extensions 1 --output $(FOFILE) fo.xsl $(DOCFILE)
110
111 .PHONY: pdf
112 pdf: ${PDFFILE}
113
114 ${PDFFILE}: ${DOCFILES} Makefile
115         @$(MAKE) fo
116         @fop $(FOFILE) -pdf $(PDFFILE) > /dev/null
117
118 .PHONY: dvi
119 dvi: ${DVIFILE}
120
121 .PHONY: ps
122 ps: ${PSFILE}
123
124 ${PSFILE}: ${DOCFILES} Makefile
125         @$(MAKE) fo
126         @fop $(FOFILE) -ps $(PSFILE) > /dev/null
127
128
129 .PHONY: txt
130 txt: ${TXTFILE}
131
132 ${TXTFILE}: ${FOFILE}
133         @XML_CATALOG_FILES="$(CATALOG)" xsltproc --xinclude --output ${HTMLFILE} html.xsl $(DOCFILE)
134         lynx -dump ${HTMLFILE} > ${TXTFILE}
135
136 .PHONY: clean
137 clean: 
138         @rm -f *~ *.bak *.orig \#*\# .\#* texput.log
139         @rm -rf html ${PSFILE} ${HTMLFILE}
140         @rm -f ${TMPFILES} ${FOFILE}
141         @rm -f  ${DVIFILE} ${TXTFILE}
142
143 .PHONY: distclean
144 distclean: clean