Improved $(VERSION) handling, and related cleanups, with minor changes to most
[privoxy.git] / doc / source / GNUmakefile.in
1 # Note:  Makefile is built automatically from Makefile.in
2 #
3 # $Id: GNUmakefile.in,v 1.6 2002/09/06 01:58:28 hal9 Exp $
4 #
5 # Location: doc/source/Makefile.in 
6 # Purpose: Build documentation
7 #
8 # Written by and Copyright (C) 2002 the Privoxy
9 # team. http://www.privoxy.org/
10 #
11 # This program is free software; you can redistribute it 
12 # and/or modify it under the terms of the GNU General
13 # Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at
15 # your option) any later version.
16 #
17 # This program is distributed in the hope that it will
18 # be useful, but WITHOUT ANY WARRANTY; without even the
19 # implied warranty of MERCHANTABILITY or FITNESS FOR A
20 # PARTICULAR PURPOSE.  See the GNU General Public
21 # License for more details.
22 #
23 # The GNU General Public License should be included with
24 # this file.  If not, you can view it at
25 # http://www.gnu.org/copyleft/gpl.html
26 # or write to the Free Software Foundation, Inc., 59
27 # Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28 #
29
30 #############################################################################
31 # Set make command correctly
32 #############################################################################
33 @SET_MAKE@
34
35 #############################################################################
36 # Version number (for RPM)
37 #############################################################################
38
39 VERSION_MAJOR = @VERSION_MAJOR@
40 VERSION_MINOR = @VERSION_MINOR@
41 VERSION_POINT = @VERSION_POINT@
42 CODE_STATUS   = @CODE_STATUS@
43 VERSION       = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_POINT)
44 # Whatever the most recent stable version is.
45 STABLE      =  3.0.0
46
47 #############################################################################
48 # Build tools
49 #############################################################################
50
51 PROGRAM    = privoxy@EXEEXT@
52 ECHO       = echo
53 INSTALL    = @INSTALL@
54 RM         = rm -fr
55 SED           = sed
56 CAT        = cat
57 MV            = mv -f
58 WDUMP      = @WDUMP@ -dump
59 JADECAT    = @JADECAT@
60 JADEBIN    = @JADEBIN@
61 DOC_STATUS = @DOC_STATUS@
62 MAN2HTML   = @MAN2HTML@
63 DKPREFIX   = @DKPREFIX@
64 # Note: Please make sure that -d ldp.dsl\#html stays the last option to
65 #       $(JADEBIN), because for some targets "-notoc" will be appended
66 #       to it (--> "ldp.dsl\#html-notoc"). 
67 DB         = $(JADEBIN) $(JADECAT) $(DOC_STATUS) -ihtml -t sgml  -D.. -d ldp.dsl\#html
68 G2H_CMD    = groff -mandoc -Thtml
69 TARGET_OS  = @host@
70 PERL       = perl
71 DOC_DIR    = .
72 DOC_TMP    = $(DOC_DIR)/tmp
73 ROOT             = ../..
74 UTILS    = $(ROOT)/utils
75 DOK_WEB_USEM=$(ROOT)/webserver/user-manual
76
77 DOC_FILES = $(ROOT)/AUTHORS $(ROOT)/LICENSE $(ROOT)/README $(ROOT)/INSTALL $(ROOT)/ChangeLog \
78                 `find ../text/ -type f | grep -v "CVS" | grep -v "\.\#" | grep -v ".*~" | grep -v ".cvsignore" | grep -v "TAGS"` \
79                 `find ../webserver/ -name "*.html" | grep -v "\(webserver\|team\)\/index\.html"` \
80                 `find ../webserver/ -name "*.css"` \
81                 $(ROOT)/privoxy.1
82
83 #############################################################################
84 # Phony targets
85 #############################################################################
86 .PHONY: all dok webserver doc-webserver clean doc-clean clobber ensure-wdump \
87 ensure-jadebin ensure-dkprefix user doc-user devel doc-devel faq doc-faq \
88 readme doc-readme authors doc-authors index doc-index webserver doc-webserver \
89 man doc-man man2html manuals doc-release doc-pdf doc-shtml announce config-file
90 #############################################################################
91 #
92 # Documentation
93 #
94 # converts *.sgml into html, pdf, text and man pages
95 #
96 #############################################################################
97
98 #############################################################################
99 # Build the Manuals, etc            #########################################
100 # This does not build _all_ targets #########################################
101 all: $(DOC_DIR)/doc_version.tmp doc-user doc-devel doc-faq doc-webserver doc-index doc-readme doc-authors doc-man doc-clean
102         @$(ECHO) Documentation created.
103
104 #############################################################################
105 # Shortcuts. Use these targets if building docs selectively (ie not 'all').
106 #
107 # Both index pages (index.html and privoxy-index.html)
108 index: $(DOC_DIR)/doc_version.tmp doc-webserver doc-index doc-clean
109
110 # Just index.html
111 webserver: $(DOC_DIR)/doc_version.tmp doc-webserver doc-clean
112
113 # User Manual html and text
114 user: $(DOC_DIR)/doc_version.tmp doc-user doc-clean
115
116 # Developer Manual html and text
117 devel: $(DOC_DIR)/doc_version.tmp doc-devel doc-clean
118
119 # FAQ html and text
120 faq: $(DOC_DIR)/doc_version.tmp doc-faq doc-clean
121
122 # All formal manuals (html and text).
123 manuals: $(DOC_DIR)/doc_version.tmp doc-user doc-devel doc-faq doc-clean
124
125 # README and INSTALL
126 readme: $(DOC_DIR)/doc_version.tmp doc-readme doc-clean
127
128 # man page and html man page
129 man: $(DOC_DIR)/doc_version.tmp doc-man doc-clean
130
131 # AUTHORS file only.
132 authors: $(DOC_DIR)/doc_version.tmp doc-authors doc-clean
133
134 # PDF version of manuals.
135 pdf: $(DOC_DIR)/doc_version.tmp doc-pdf
136
137 # doh.
138 clean: doc-clean
139
140 # backward compatibility targets
141 dok-user: user
142 dok-faq: faq
143 dok-devel: devel
144 dok-index: index
145 dok-man: man
146 dok-readme: readme
147 dok: all
148
149 # 3 checks to make sure docs will be generated
150 ensure-wdump:
151 ifeq (@WDUMP@,false)
152         @$(ECHO)
153         @$(ECHO) "Cannot build docs; one of w3m, links, or lynx must be installed."
154         @$(ECHO) "You should install the appropriate package and rerun ./configure"
155         @exit 1
156 endif
157
158 ensure-jadebin:
159 ifeq (@JADEBIN@,false)
160         @$(ECHO)
161         @$(ECHO) "Cannot build docs; one of openjade or jade must be installed"
162         @$(ECHO) "You should install the appropriate package and rerun ./configure"
163         @exit 1
164 endif
165
166 ensure-dkprefix:
167 ifeq (@DKPREFIX@,false)
168         @$(ECHO)
169         @$(ECHO) "Cannot build docs; cannot find docbook-dsssl stylesheets"
170         @$(ECHO) "You should install the appropriate package and rerun ./configure"
171         @exit 1
172 endif
173
174 # Update release info, so it can be read by Docbook/jade, and run other
175 # checks.
176 $(DOC_DIR)/doc_version.tmp: ensure-dkprefix ensure-jadebin ensure-wdump doc-release
177         
178 # Write VERSION and CODE_STATUS to tmp files so they can be read into the doc
179 # processing. This needs to go before any doc building (doh).
180 doc-release:
181         @$(ECHO) Setting doc version and status to $(VERSION), $(CODE_STATUS)
182         $(MAKE) doc-clean
183         mkdir -p $(DOC_TMP)
184         $(ECHO) -n $(VERSION) > $(DOC_DIR)/doc_version.tmp
185         $(ECHO) -n $(CODE_STATUS) > $(DOC_DIR)/doc_status.tmp
186         $(ECHO) -n $(STABLE) > $(DOC_DIR)/doc_stable.tmp
187
188 # user manual
189 doc-user:
190         test -f $(DOC_DIR)/doc_version.tmp || exit 1
191         cd $(DOC_TMP) && $(RM) * && $(DB) -iuser-man ../user-manual.sgml && cd .. && \
192         $(RM) ../webserver/user-manual/*.html && cp $(DOC_TMP)/*.html ../webserver/user-manual/
193         $(DB) -iuser-man -V nochunks user-manual.sgml > tmp.html && $(WDUMP) tmp.html > ../text/user-manual.txt
194
195 # developer manual
196 doc-devel:
197         test -f $(DOC_DIR)/doc_version.tmp || exit 1
198         cd $(DOC_TMP) && $(RM) * && $(DB) ../developer-manual.sgml && cd .. && \
199         $(RM) ../webserver/developer-manual/*.html && cp -f $(DOC_TMP)/*.html ../webserver/developer-manual/
200         $(DB) -V nochunks developer-manual.sgml > tmp.html && $(WDUMP) tmp.html > ../text/developer-manual.txt
201
202 # faq
203 doc-faq:
204         test -f $(DOC_DIR)/doc_version.tmp || exit 1
205         cd $(DOC_TMP) && $(RM) * && $(DB) ../faq.sgml && cd .. && \
206         $(RM) ../webserver/faq/*.html && cp $(DOC_TMP)/*.html ../webserver/faq/
207         $(DB) -V nochunks faq.sgml > tmp.html && $(WDUMP) tmp.html > ../text/faq.txt 
208
209 # Build README and INSTALL files.
210 doc-readme:
211         test -f $(DOC_DIR)/doc_version.tmp || exit 1
212         $(DB)-notoc -V nochunks readme.sgml > tmp.html &&\
213         $(WDUMP) tmp.html > $(ROOT)/README ;\
214         $(DB)-notoc -V nochunks install.sgml > tmp.html &&\
215         $(WDUMP) tmp.html > $(ROOT)/INSTALL ;\
216         $(RM) tmp.*
217
218 # index.sgml is used to create both the Home Page, and a local index
219 # for documentation (privoxy-index.html), etc.
220 #
221 # index.html for webserver:
222 doc-webserver:
223         test -f $(DOC_DIR)/doc_version.tmp || exit 1
224         cd webserver && $(DB)-notoc -ip-homepage -V nochunks index.sgml > index.html ;\
225         $(PERL) -pi.bak -e 's/..\/p_doc.css/p_doc.css/;\
226      s/<\/HEAD/\n<meta name=\"description\" content=\"Privoxy helps consumers reduce unwanted junk email and protect their privacy from direct marketing companies.\"><\/HEAD/;\
227         s/<\/HEAD/\n<meta name="MSSmartTagsPreventParsing" content="TRUE"><\/HEAD/;\
228         s/\.\d\. //' index.html ;\
229         $(MV) index.html ../../webserver ;\
230         $(RM) *.html *.bak
231
232 # privoxy-index.html for bundling with locally installed documentation:
233 doc-index:
234         test -f $(DOC_DIR)/doc_version.tmp || exit 1
235         cd webserver && $(DB)-notoc -ip-index -V nochunks index.sgml > privoxy-index.html ;\
236         $(PERL) -pi.bak -e 's/..\/p_doc.css/p_doc.css/;\
237      s/<\/HEAD/\n<meta name=\"description\" content=\"Privoxy helps consumers reduce unwanted junk email and protect their privacy from direct marketing companies.\"><\/HEAD/;\
238         s/<\/HEAD/\n<meta name="MSSmartTagsPreventParsing" content="TRUE"><\/HEAD/;\
239         s/\.\d\. //' privoxy-index.html ;\
240         $(MV) privoxy-index.html ../../webserver ;\
241         $(RM) *.html *.bak
242
243 ## Make AUTHORS file
244 doc-authors:
245         test -f $(DOC_DIR)/doc_version.tmp || exit 1
246         $(DB) -V nochunks authors.sgml > tmp.html && $(WDUMP) \
247           tmp.html > ../../AUTHORS
248
249 # Make a man page, and then HTML version. Uses docbook2man (short perl script)
250 # in utils dir. 
251 doc-man:
252         test -f $(DOC_DIR)/doc_version.tmp || exit 1
253         cd $(DOC_TMP) && $(RM) * &&\
254         nsgmls $(DOC_STATUS) ../privoxy-man-page.sgml  | sgmlspl ../../../utils/docbook2man/docbook2man-spec.pl &&\
255         perl -pi.bak -e 's/ <URL:.*>//; s/\[ /\[/g' privoxy.1
256 #       cd $(DOC_TMP) && $(DB) ../privoxy-man-page.sgml &&\
257 #       $(MV) -f index.html privoxy-man-page.html
258      # This html is not used. See make man2html.
259         $(MV) -f $(DOC_TMP)/privoxy.1 $(ROOT)/privoxy.1
260         $(MAKE) man2html
261         $(MAKE) clean
262
263 # For those with man2html ala RH7s.
264 man2html:
265         test -f $(DOC_DIR)/doc_version.tmp || exit 1
266         mkdir -p ../webserver/man-page
267 ifneq ($(MAN2HTML),false)
268         $(MAN2HTML) $(ROOT)/privoxy.1 |grep -v "^Content-type" > tmp.html
269         $(PERL) -pi.bak -e 's/<A .*Contents<\/A>//; s/<A .*man2html<\/A>/man2html/' tmp.html
270         $(PERL) -pi.bak -e 's/(<\/HEAD>)/<LINK REL=\"STYLESHEET\" TYPE=\"text\/css\" HREF=\"..\/p_doc.css\"><\/HEAD>/' tmp.html
271 # Twice because my version of man2html is pulling in commas and periods in URLs.
272         $(PERL) -pi.bak -e 's/(<A.*),(">)/$$1$$2/g' tmp.html
273         $(PERL) -pi.bak -e 's,\.">,">,g' tmp.html
274 # Get rid of spurious \a from conversion. (How to do this with perl?)
275         $(SED) -e 's/\a//g' tmp.html > ../webserver/man-page/privoxy-man-page.html && $(RM) tmp.*
276 else
277         $(MAKE) groff2html
278 endif
279
280 # Otherwise we get plain groff conversion.
281 groff2html:
282         $(G2H_CMD) $(ROOT)/privoxy.1 | $(SED) -e 's@</head>@<link REL="STYLESHEET" TYPE="text/css" HREF="../p_doc.css"></head>@' >\
283         ../webserver/man-page/privoxy-man-page.html
284
285 # Make pdf docs from single page html. Requires htmldoc, see
286 # (http://www.easysw.com/htmldoc/). Note: 1.8.20 has a TOC bug.
287 # PDF docs are uploaded to webserver as zip archive.
288 doc-pdf: doc-shtml
289         @$(ECHO) -n "starting htmldoc version: "; htmldoc --version
290         cd $(UTILS)/ldp_print && $(RM) *html *bak *jpg *tmp *pdf *zip
291         cp -f $(DOC_TMP)/*html ../webserver/images/*jpg  $(UTILS)/ldp_print
292         cd $(UTILS)/ldp_print ;\
293         $(PERL) -pi.bak -e 's/\.\.\/images\///; s/(<\/?)SUB/$$1small/i;\
294                             s/\.\.\/user-manual\/index\.html/privoxy-user-manual.pdf/;\
295                                         s/\.\.\/developer-manual\/index\.html/privoxy-developer-manual.pdf/;\
296                                         s/\.\.\/faq\/index\.html/privoxy-faq.pdf/' *.html ;\
297         for i in developer-manual user-manual faq; do \
298                 ./ldp_print privoxy-$$i.html ;\
299                 $(ECHO) DONE: privoxy-$$i.pdf ;\
300         done ;\
301         $(MV) *.pdf  ../../doc/pdf ;\
302         $(RM) *html *bak *jpg *pdf *zip 
303         $(RM)  $(DOC_TMP)
304
305
306 # Generate single page html. Used only for creating pdf docs (ATM).
307 doc-shtml:
308         test -f $(DOC_DIR)/doc_version.tmp || exit 1
309         $(DB) -iuser-man -V nochunks user-manual.sgml > $(DOC_TMP)/privoxy-user-manual.html
310         $(DB) -V nochunks developer-manual.sgml > $(DOC_TMP)/privoxy-developer-manual.html
311         $(DB) -V nochunks faq.sgml > $(DOC_TMP)/privoxy-faq.html
312
313 # Create release announcement in text and html, with short and long versions.
314 # This is a standalone target, and must be invoked directly.
315 announce: $(DOC_DIR)/doc_version.tmp
316         cd $(DOC_TMP) && $(DB) -iannounce-big ../announce.sgml &&\
317         mv -f index.html announce.html && $(WDUMP) announce.html > announce.txt
318         cd $(DOC_TMP) && $(DB) ../announce.sgml &&\
319         mv -f index.html announce-mini.html && $(WDUMP) announce-mini.html > announce-mini.txt &&\
320         mv -f *html *txt $(ROOT) 
321         $(MAKE) doc-clean
322         @$(ECHO) Announce texts are done. Please check them. Some hand editing
323         @$(ECHO) may be required.
324
325 # The main Privoxy config file, generated from sgml sources. 
326 # NOTE: This will require some hand editing. The new file is outputted 
327 # as config.new so that problem sections can be compared to previous
328 # version. This is hardcored to w3m for html/text conversion. Also, 
329 # requires the shell util 'fmt'.
330 config-file: $(DOC_DIR)/doc_version.tmp
331         $(DB)-notoc -iconfig-file -V nochunks config.sgml > tmp.html &&\
332         w3m -dump tmp.html |fmt -w 70 > $(ROOT)/config.new && $(RM) tmp.*
333         $(PERL) -pi.bak -e 's/^1\. \@\@TITLE\@\@/     /i;\
334                      /^\d\.\d\.\s+/ && tr/[a-z]/[A-Z]/;\
335                      $$header_len=0 unless $$hit_header;\
336                      if ($$hit_header) {\
337                         print "#  ";\
338                         for ($$i=1; $$i < $$header_len; $$i++) {print "=";}\
339                         print "\n";\
340                      };\
341                      $$hit_header=0;\
342                      $$hit_header=1 if m/^(\d\.)(\d\.)(\d\.)?\s/ && s/^(\d\.)//;\
343                      $$header_len = length($$_);\
344                                  s/^/#  /;  /^#  #{12,}/ && s/^#  #/####/;\
345                      s/^.*$$// if $$hit_option;\
346                      $$hit_option=0;\
347                      s/^\n//;  s/^#\s*-{20,}//;\
348                      $$hit_option=1 if s/^#\s+@@//;'   $(ROOT)/config.new
349         $(RM) $(ROOT)/*.bak *.tmp tmp.* $(DOC_TMP)
350         @$(ECHO)  "****************************************************"
351         @$(ECHO)  "The output file is config.new."
352         @$(ECHO)  "Now -- you need to hand edit the results!!!"
353         @$(ECHO)  "In particular, check the Debug levels, and the"
354         @$(ECHO)  "permit-access, forward & socks examples. They"
355         @$(ECHO)  "probably got hammered."
356         @$(ECHO)  "****************************************************"
357
358 # config file, alternate verison using lynx (perl stuff unfinished). Lynx
359 # does not do so good a job.
360 config-file-alt: doc-release ensure-wdump
361         $(ECHO) -e ".h2 JUSTIFY\\nJUSTIFY:FALSE" > tmp.lynx_cfg &&\
362         $(DB)-notoc -iconfig-file -V nochunks config.sgml > tmp.html &&\
363         lynx -cfg=tmp.lynx_cfg -width=78 -dump tmp.html > ../../config.new && $(RM) tmp.*
364         $(PERL) -pi -e 's/^(   )//;\
365                         s/:$\/:\n/' $(ROOT)/config.new
366
367 # This is mostly to catch cruft from build failures
368 doc-clean:
369         $(RM) $(DOC_TMP) *.html `find $(ROOT) -name "tmp.*" -o -name "*.tmp" -o -name "*.bak" -o -name "*.fot"`
370
371 tidy:
372         $(RM) doc_* `find . -name "*~"` `find . -name ".\#*"`
373
374 clobber: tidy clean
375         $(RM) GNUmakefile ldp.dsl
376
377 distclean: clobber
378
379 coffee:
380          @perl -e 'print pack "C*", (31,139,8,8,153,63,226,60,2,3,99,111,102,102,101,101,0,109,143,205,13,192,32,8,133,\
381                   239,78,241,110,234,1,28,160,171,152,208,53,26,117,247,22,165,73,137,125,9,1,62,126,2,128,169,5,243,143,\
382                   13,139,49,164,65,100,149,152,102,73,141,88,73,178,116,205,100,69,253,36,102,81,49,83,236,19,225,171,131,\
383                   214,172,163,73,4,168,123,115,71,126,247,122,94,128,178,227,95,154,12,86,215,122,197,249,146,187,54,220,125,\
384                   193,51,228,11,1,0,0);'|zcat
385
386 #############################################################################
387
388 # $Log: GNUmakefile.in,v $
389 # Revision 1.6  2002/09/06 01:58:28  hal9
390 # Create a separate INSTALL file, and remove install instructions from README.
391 # INSTALL is built from dok-readme target.
392 #
393 # Revision 1.5  2002/09/05 23:12:04  hal9
394 # Updated Makefile with 3.0 changes (pdf and man targets, etc). Revise comments
395 # in privoxy-man-page.sgml to remove out of date comments.
396 #
397 # Revision 1.4  2002/08/08 01:02:26  hal9
398 # Update pdf2 target to dok-shtml (for single page html)
399 #
400 # Revision 1.3  2002/06/07 00:27:04  hal9
401 # Fixing man2html quirk that pulls in punctuation, and breaks URLs.
402 #
403 # Revision 1.2  2002/06/05 04:17:19  hal9
404 # Add dok-man-test target as temp workaround for docbook2man ignoring -i command
405 # line option.
406 #
407 # Revision 1.1  2002/06/05 00:28:28  hal9
408 # Moving all doc building to doc/source. Rewrite all targets (not well tested).
409 # Docs are now built without touching sgml source.
410 #