r9457: Reworked CLSQL file structure.
[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`" : '.*Debian.*')
25 SUSE=$(shell expr "`cat /etc/issue`" : '.*SuSE.*')
26 REDHAT=$(shell expr "`cat /etc/issue`" : '.*RedHat.*')
27
28 ifneq (${DEBIAN},0)
29 OS:=debian
30 else
31   ifneq (${SUSE},0)
32     OS=suse
33   else   
34     ifneq (${REDHAT},0)
35       OS=redhat
36     endif
37   endif
38 endif
39
40
41 ifndef DOCFILE_BASE
42 DOCFILE_BASE=${DOCFILE_BASE_DEFAULT}
43 endif
44
45 ifndef DOCFILE_EXT
46 DOCFILE_EXT=${DOCFILE_EXT_DEFAULT}
47 endif
48
49 DOCFILE:=${DOCFILE_BASE}.${DOCFILE_EXT}
50 FOFILE:=${DOCFILE_BASE}.fo
51 PDFFILE:=${DOCFILE_BASE}.pdf
52 PSFILE:=${DOCFILE_BASE}.ps
53 DVIFILE:=${DOCFILE_BASE}.dvi
54 TXTFILE:=${DOCFILE_BASE}.txt
55 HTMLFILE:=${DOCFILE_BASE}.html
56 TMPFILES:=${DOCFILE_BASE}.aux ${DOCFILE_BASE}.out ${DOCFILE_BASE}.log
57 DOCFILES:=$(shell echo *.xml *.xsl)
58
59 ifeq ($(XSLTPROC),)
60   XSLTPROC:=xsltproc
61 endif
62
63 CATALOG:=`pwd`/catalog-${OS}.xml
64 CHECK:=XML_CATALOG_FILES="$(CATALOG)" xmllint --noout --xinclude --postvalid $(DOCFILE) || exit 1
65
66 .PHONY: all
67 all: html pdf 
68
69 .PHONY: dist
70 dist: html pdf
71
72 .PHONY: doc
73 doc: html pdf
74
75 .PHONY: check
76 check:
77         @echo "Operating system detected: ${OS}"
78         @$(CHECK)
79
80 .PHONY: html
81 html: html.tar.gz
82
83 html.tar.gz: $(DOCFILES) Makefile 
84         @rm -rf html
85         @mkdir html
86         @XML_CATALOG_FILES="$(CATALOG)" $(XSLTPROC) --stringparam chunker.output.encoding ISO-8859-1 \
87                  --xinclude --output html/ html_chunk.xsl $(DOCFILE)
88         @GZIP='-9' tar czf html.tar.gz html 
89
90 .PHONY: fo
91 fo: ${FOFILE}
92
93 ${FOFILE}: $(DOCFILES) Makefile 
94         @XML_CATALOG_FILES="$(CATALOG)" xsltproc --xinclude --output $(FOFILE) fo.xsl $(DOCFILE)
95
96 .PHONY: pdf
97 pdf: ${PDFFILE}
98
99 ${PDFFILE}: ${DOCFILES} Makefile
100         @$(MAKE) fo
101         @fop $(FOFILE) -pdf $(PDFFILE) > /dev/null
102
103 .PHONY: dvi
104 dvi: ${DVIFILE}
105
106 .PHONY: ps
107 ps: ${PSFILE}
108
109 ${PSFILE}: ${DOCFILES} Makefile
110         @$(MAKE) fo
111         @fop $(FOFILE) -ps $(PSFILE) > /dev/null
112
113
114 .PHONY: txt
115 txt: ${TXTFILE}
116
117 ${TXTFILE}: ${FOFILE}
118         @XML_CATALOG_FILES="$(CATALOG)" xsltproc --xinclude --output ${HTMLFILE} html.xsl $(DOCFILE)
119         lynx -dump ${HTMLFILE} > ${TXTFILE}
120
121 .PHONY: clean
122 clean: 
123         @rm -f *~ *.bak *.orig \#*\# .\#* texput.log
124         @rm -rf html ${PSFILE} ${HTMLFILE}
125         @rm -f ${TMPFILES} ${FOFILE}
126         @rm -f  ${DVIFILE} ${TXTFILE}
127
128 .PHONY: distclean
129 distclean: clean