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