r8172: automated OS discovery
[uffi.git] / doc / Makefile
1 ##############################################################################
2 # FILE IDENTIFICATION
3
4 #  Name:         Makefile
5 #  Purpose:      Makefile for the uffi documentation
6 #  Programer:    Kevin M. Rosenberg
7 #  Date Started: Mar 2002
8 #
9 #  CVS Id:   $Id$
10 #
11 # This file, part of UFFI, is Copyright (c) 2002-2003 by Kevin M. Rosenberg
12 #
13 # UFFI 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:=uffi
19 DOCFILE_EXT_DEFAULT:=xml
20
21
22 # Standard docfile processing
23
24 DEBIAN=expr "`cat /etc/issue`" : '.*Debian.*'
25 SUSE=expr "`cat /etc/issue`" : '.*SuSE.*'
26 REDHAT=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 ifndef DOCFILE_BASE
41 DOCFILE_BASE=${DOCFILE_BASE_DEFAULT}
42 endif
43
44 ifndef DOCFILE_EXT
45 DOCFILE_EXT=${DOCFILE_EXT_DEFAULT}
46 endif
47
48 DOCFILE:=${DOCFILE_BASE}.${DOCFILE_EXT}
49 FOFILE:=${DOCFILE_BASE}.fo
50 PDFFILE:=${DOCFILE_BASE}.pdf
51 PSFILE:=${DOCFILE_BASE}.ps
52 DVIFILE:=${DOCFILE_BASE}.dvi
53 TXTFILE:=${DOCFILE_BASE}.txt
54 HTMLFILE:=${DOCFILE_BASE}.html
55 TMPFILES:=${DOCFILE_BASE}.aux ${DOCFILE_BASE}.out ${DOCFILE_BASE}.log
56 DOCFILES:=$(shell echo *.xml *.xsl)
57
58 CATALOG:=`pwd`/catalog-${OS}.xml
59 CHECK:=XML_CATALOG_FILES="$(CATALOG)" xmllint --noout --xinclude --postvalid $(DOCFILE) || exit 1
60
61 .PHONY: all
62 all: html pdf 
63
64 .PHONY: dist
65 dist: html pdf
66
67 .PHONY: doc
68 doc: html pdf
69
70 .PHONY: check
71 check:
72         @$(CHECK)
73
74 .PHONY: html
75 html: html.tar.gz
76
77 html.tar.gz: $(DOCFILES) Makefile 
78         @rm -rf html
79         @mkdir html
80         @XML_CATALOG_FILES="$(CATALOG)" xsltproc --xinclude --output html/ html_chunk.xsl $(DOCFILE)
81         @GZIP='-9' tar czf html.tar.gz html 
82
83 .PHONY: fo
84 fo: ${FOFILE}
85
86 ${FOFILE}: $(DOCFILES) Makefile 
87         @XML_CATALOG_FILES="$(CATALOG)" xsltproc --xinclude --output $(FOFILE) fo.xsl $(DOCFILE)
88
89 .PHONY: pdf
90 pdf: ${PDFFILE}
91
92 ${PDFFILE}: ${DOCFILES} Makefile
93         @$(MAKE) fo
94         @fop $(FOFILE) -pdf $(PDFFILE) > /dev/null
95
96 .PHONY: dvi
97 dvi: ${DVIFILE}
98
99 .PHONY: ps
100 ps: ${PSFILE}
101
102 ${PSFILE}: ${DOCFILES} Makefile
103         @$(MAKE) fo
104         @fop $(FOFILE) -ps $(PSFILE) > /dev/null
105
106
107 .PHONY: txt
108 txt: ${TXTFILE}
109
110 ${TXTFILE}: ${FOFILE}
111         @XML_CATALOG_FILES="$(CATALOG)" xsltproc --xinclude --output ${HTMLFILE} html.xsl $(DOCFILE)
112         lynx -dump ${HTMLFILE} > ${TXTFILE}
113
114 .PHONY: clean
115 clean: 
116         @rm -f *~ *.bak *.orig \#*\# .\#* texput.log
117         @rm -rf html ${PSFILE} ${HTMLFILE}
118         @rm -f ${TMPFILES} ${FOFILE}
119         @rm -f  ${DVIFILE} ${TXTFILE}
120
121 .PHONY: distclean
122 distclean: clean