cdff6514cffd021e06eb6dcf79b8cdd1bdf69bbb
[privoxy.git] / doc / source / GNUmakefile.in
1 # Note:  Makefile is built automatically from Makefile.in
2 #
3 # $Id: GNUmakefile.in,v 1.3 2002/06/07 00:27:04 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
45 #############################################################################
46 # Build tools
47 #############################################################################
48
49 PROGRAM    = privoxy@EXEEXT@
50 ECHO       = echo
51 INSTALL    = @INSTALL@
52 RM         = rm -fr
53 SED           = sed
54 CAT        = cat
55 MV            = mv -f
56 WDUMP      = @WDUMP@ -dump
57 JADECAT    = @JADECAT@
58 JADEBIN    = @JADEBIN@
59 DOC_STATUS = @DOC_STATUS@
60 MAN2HTML   = @MAN2HTML@
61 # Note: Please make sure that -d ldp.dsl\#html stays the last option to
62 #       $(JADEBIN), because for some targets "-notoc" will be appended
63 #       to it (--> "ldp.dsl\#html-notoc"). 
64 DB         = $(JADEBIN) $(JADECAT) $(DOC_STATUS) -ihtml -t sgml  -D.. -d ldp.dsl\#html
65 G2H_CMD    = groff -mandoc -Thtml
66 TARGET_OS  = @host@
67 PERL       = perl
68 DOC_DIR    = .
69 DOC_TMP    = $(DOC_DIR)/tmp
70 ROOT             = ../..
71 DOK_WEB_USEM=$(ROOT)/webserver/user-manual
72
73 DOC_FILES = AUTHORS LICENSE README ChangeLog \
74                 `find ../text/ -type f | grep -v "CVS" | grep -v "\.\#" | grep -v ".*~" | grep -v ".cvsignore" | grep -v "TAGS"` \
75                 `find ../webserver/ -name "*.html" | grep -v "\(webserver\|team\)\/index\.html"` \
76                 `find ../webserver/ -name "*.css"` \
77                 $(ROOT)/privoxy.1
78
79 #############################################################################
80 # Phony targets
81 #############################################################################
82 .PHONY: all dok webserver dok-webserver clean dok-clean clobber ensure-wdump \
83 ensure-jadebin ensure-dkprefix user dok-user devel dok-devel faq dok-faq \
84 readme dok-readme authors dok-authors index dok-index webserver dok-webserver \
85 man dok-man man2html manuals dok-release dok-pdf dok-shtml announce config-file
86 #############################################################################
87 #
88 # Documentation
89 #
90 # converts *.sgml into html, text and man pages
91 #
92 #############################################################################
93 #
94 # Build the Manuals, etc            #########################################
95 # This does not build _all_ targets #########################################
96 all: dok-release dok-user dok-devel dok-faq dok-index dok-readme dok-authors dok-clean
97         @$(ECHO) Documentation created.
98
99 # Shortcuts. Use these targets.
100 clean: dok-clean
101 index: dok-release dok-webserver dok-index dok-clean
102 user: dok-release dok-user dok-clean
103 devel: dok-release dok-devel dok-clean
104 faq: dok-release dok-faq dok-clean
105 manuals: dok-release dok-user dok-devel dok-faq dok-clean
106 readme: dok-release dok-readme dok-clean
107 webserver: dok-release dok-webserver dok-clean
108 man: dok-release dok-man dok-clean
109 authors: dok-release dok-authors dok-clean
110
111 # 3 checks to make sure docs will be generated
112 ensure-wdump:
113 ifeq (@WDUMP@,false)
114         @$(ECHO)
115         @$(ECHO) "Cannot build docs; one of w3m, links, or lynx must be installed."
116         @$(ECHO) "You should install the appropriate package and rerun ./configure"
117         @exit 1
118 endif
119
120 ensure-jadebin:
121 ifeq (@JADEBIN@,false)
122         @$(ECHO)
123         @$(ECHO) "Cannot build docs; one of openjade or jade must be installed"
124         @$(ECHO) "You should install the appropriate package and rerun ./configure"
125         @exit 1
126 endif
127
128 ensure-dkprefix:
129 ifeq (@DKPREFIX@,false)
130         @$(ECHO)
131         @$(ECHO) "Cannot build docs; cannot find docbook-dsssl stylesheets"
132         @$(ECHO) "You should install the appropriate package and rerun ./configure"
133         @exit 1
134 endif
135
136 # user manual
137 dok-user: ensure-dkprefix ensure-jadebin ensure-wdump
138         cd $(DOC_TMP) && $(RM) * && $(DB) -iuser-man ../user-manual.sgml && cd .. && \
139         $(RM) ../webserver/user-manual/*.html && cp $(DOC_TMP)/*.html ../webserver/user-manual/
140         $(DB) -iuser-man -V nochunks user-manual.sgml > tmp.html && $(WDUMP) tmp.html > ../text/user-manual.txt
141
142 # developer manual
143 dok-devel: ensure-dkprefix ensure-jadebin ensure-wdump
144         cd $(DOC_TMP) && $(RM) * && $(DB) ../developer-manual.sgml && cd .. && \
145         $(RM) ../webserver/developer-manual/*.html && cp -f $(DOC_TMP)/*.html ../webserver/developer-manual/
146         $(DB) -V nochunks developer-manual.sgml > tmp.html && $(WDUMP) tmp.html > ../text/developer-manual.txt
147
148 # faq
149 dok-faq: ensure-dkprefix ensure-jadebin ensure-wdump
150         cd $(DOC_TMP) && $(RM) * && $(DB) ../faq.sgml && cd .. && \
151         $(RM) ../webserver/faq/*.html && cp $(DOC_TMP)/*.html ../webserver/faq/
152         $(DB) -V nochunks faq.sgml > tmp.html && $(WDUMP) tmp.html > ../text/faq.txt 
153
154 # man page, using one variant of man2html that reads page from stdin.
155 dok-man-suse: ensure-dkprefix ensure-jadebin ensure-wdump dok-release
156         $(RM) ../webserver/man-page/*.html
157 ifneq ($(MAN2HTML),false)
158         $(ECHO) "<html><head><title>Privoxy Man page</title><link rel=\"stylesheet\" type=\"text/css\" href=\"../p_web.css\"></head><body><H2>NAME</H2>" > \
159          ../webserver/man-page/privoxy-man-page.html
160         man $(ROOT)/privoxy.1 | $(MAN2HTML) -bare >> ../webserver/man-page/privoxy-man-page.html
161         $(ECHO) "</body></html>" >> ../webserver/man-page/privoxy-man-page.html
162 else
163         $(MAKE) groff2html
164 endif
165
166 # readme page
167 dok-readme: ensure-dkprefix ensure-jadebin ensure-wdump
168         $(DB)-notoc -V nochunks readme.sgml > tmp.html &&\
169         $(WDUMP) tmp.html > $(ROOT)/README
170
171 # index.sgml is used to create both the Home Page, and a local index
172 # for documentation (privoxy-index.html), etc.
173 #
174 # index.html for webserver:
175 dok-webserver: ensure-dkprefix ensure-jadebin ensure-wdump
176         cd webserver && $(DB)-notoc -ip-homepage -V nochunks index.sgml > ../../webserver/index.html
177         $(PERL) -pi.bak -e 's/..\/p_doc.css/p_doc.css/;\
178      s/<\/HEAD/\n<meta name=\"description\" content=\"Privoxy helps consumers reduce unwanted junk email and protect their privacy from direct marketing companies.\"><\/HEAD/;\
179         s/<\/HEAD/\n<meta name="MSSmartTagsPreventParsing" content="TRUE"><\/HEAD/;\
180         s/\.\d\. //'\
181      ../webserver/index.html
182
183 # privoxy-index.html for local documentation:
184 dok-index: ensure-dkprefix ensure-jadebin ensure-wdump
185         cd webserver && $(DB)-notoc -ip-index -V nochunks index.sgml > ../../webserver/privoxy-index.html
186         $(PERL) -pi.bak -e 's/..\/p_doc.css/p_doc.css/;\
187      s/<\/HEAD/\n<meta name=\"description\" content=\"Privoxy helps consumers reduce unwanted junk email and protect their privacy from direct marketing companies.\"><\/HEAD/;\
188         s/<\/HEAD/\n<meta name="MSSmartTagsPreventParsing" content="TRUE"><\/HEAD/;\
189         s/\.\d\. //'\
190      ../webserver/privoxy-index.html 
191
192 ## Make AUTHORS file
193 dok-authors: ensure-dkprefix ensure-jadebin ensure-wdump
194         $(DB) -V nochunks authors.sgml > tmp.html && $(WDUMP) \
195           tmp.html > ../../AUTHORS
196
197 # Make a man page, and then (lousy) HTML version.
198 # Requires docbook2man (short perl script), see comments 
199 # in privoxy-man-page.sgml. This target is not invoked from other dok targets.
200 # It is built separately due to dependencies on off-beat perl scripts.
201 # Note: docbook2man eats all command line arguments except file name. Bummer.
202 dok-man: ensure-dkprefix ensure-jadebin 
203         cd $(DOC_TMP) && $(RM) * && docbook2man $(DOC_STATUS) ../privoxy-man-page.sgml &&\
204         perl -pi.bak -e 's/ <URL:.*>//; s/\[ /\[/g' privoxy.1
205         cd $(DOC_TMP) && $(DB) ../privoxy-man-page.sgml &&\
206         $(MV) -f index.html privoxy-man-page.html
207      # This html is not used. See make man2html.
208         $(MV) -f $(DOC_TMP)/privoxy.1 $(ROOT)/privoxy.1
209         # Build a proper HTML man page.
210         $(MAKE) man2html
211
212 # This is laternate version of above, that does handle command line options,
213 # ie DOC_STATUS.
214 dok-man-test: ensure-dkprefix ensure-jadebin dok-release
215         cd $(DOC_TMP) && $(RM) * &&\
216         nsgmls $(DOC_STATUS) ../privoxy-man-page.sgml  | sgmlspl `find /usr/share/sgml -name docbook2man-spec.pl` &&\
217         perl -pi.bak -e 's/ <URL:.*>//; s/\[ /\[/g' privoxy.1
218         cd $(DOC_TMP) && $(DB) ../privoxy-man-page.sgml &&\
219         $(MV) -f index.html privoxy-man-page.html
220      # This html is not used. See make man2html.
221         $(MV) -f $(DOC_TMP)/privoxy.1 $(ROOT)/privoxy.1
222         $(MAKE) man2html
223         $(MAKE) clean
224
225 # For those with man2html ala RH7s.
226 man2html: ensure-dkprefix ensure-jadebin ensure-wdump
227         mkdir -p doc/webserver/man-page
228 ifneq ($(MAN2HTML),false)
229         $(MAN2HTML) privoxy.1 |grep -v "^Content-type" > tmp.html
230         $(PERL) -pi.bak -e 's/<A .*Contents<\/A>//; s/<A .*man2html<\/A>/man2html/' tmp.html
231         $(PERL) -pi.bak -e 's/(<\/HEAD>)/<LINK REL=\"STYLESHEET\" TYPE=\"text\/css\" HREF=\"..\/p_doc.css\"><\/HEAD>/' tmp.html
232 # Twice because my version of man2html is pulling in commas and periods in URLs.
233         $(PERL) -pi.bak -e 's/(<A.*),(">)/$$1$$2/g' tmp.html
234         $(PERL) -pi.bak -e 's,\.">,">,g' tmp.html
235 # Get rid of spurious \a from conversion. (How to do this with perl?)
236         $(SED) -e 's/\a//g' tmp.html > doc/webserver/man-page/privoxy-man-page.html && $(RM) tmp.*
237 else
238         $(MAKE) groff2html
239 endif
240
241 # Otherwise we get plain groff conversion.
242 groff2html:
243         $(G2H_CMD) $(ROOT)/privoxy.1 | $(SED) -e 's@</head>@<link REL="STYLESHEET" TYPE="text/css" HREF="../p_doc.css"></head>@' >\
244         ../webserver/man-page/privoxy-man-page.html
245
246 # Write VERSION and CODE_STATUS to tmp files so they can be read into the doc
247 # processing. This needs to go before any doc building (doh).
248 dok-release:
249         @$(ECHO) Setting doc version and status to $(VERSION), $(CODE_STATUS)
250         $(MAKE) dok-clean
251         mkdir -p $(DOC_TMP)
252         $(ECHO) -n $(VERSION) > $(DOC_DIR)/doc_version.tmp
253         $(ECHO) -n $(CODE_STATUS) > $(DOC_DIR)/doc_status.tmp
254
255 dok-pdf: dok-release 
256         $(RM) ../pdf/*.pdf
257         cp -f *.sgml ../pdf
258         cp -f *.dsl ../pdf
259         cd ../pdf && db2pdf --pdf -s ldp.dsl user-manual.sgml && mv user-manual.pdf privoxy-user-manual.pdf > /dev/null 2>&1
260         cd ../pdf && db2pdf --pdf -s ldp.dsl developer-manual.sgml && mv developer-manual.pdf privoxy-developer-manual.pdf > /dev/null 2>&1
261         cd ../pdf && db2pdf --pdf -s ldp.dsl faq.sgml && mv faq.pdf privoxy-faq.pdf > /dev/null 2>&1
262         $(RM) ../pdf/*.sgml ../pdf/*.dsl ../pdf/*.out ../pdf/*.tex ../pdf/*.log ../pdf/*.aux
263
264 # Generate single page html. Used only for creating pdf docs (ATM).
265 # Currently using: See http://www.easysw.com/htmldoc/pdf-o-matic.php.
266 # If using this generator, remember U-M has a couple of graphics in 
267 # a parallel directory.
268 #
269 dok-shtml: dok-release 
270         mkdir -p doc/source/temp # this directory not in cvs
271         cd doc/source && $(DB) -iuser-man -V nochunks user-manual.sgml > temp/privoxy-user-manual.html
272         cd doc/source && $(DB) -V nochunks developer-manual.sgml > temp/privoxy-developer-manual.html
273         cd doc/source && $(DB) -V nochunks faq.sgml > temp/privoxy-faq.html
274 # one could use html2ps and ps2pdf. well, that does not work. htmlps produces incorrect output.
275
276 # Create release announcement in text and html, with short and long versions.
277 # This is a standalone target, and must be invoked directly.
278 announce: dok-release ensure-wdump
279         cd $(DOC_TMP) && $(DB) -iannounce-big ../announce.sgml &&\
280         mv -f index.html announce.html && $(WDUMP) announce.html > announce.txt
281         cd $(DOC_TMP) && $(DB) ../announce.sgml &&\
282         mv -f index.html announce-mini.html && $(WDUMP) announce-mini.html > announce-mini.txt &&\
283         mv -f *html *txt $(ROOT) 
284         $(MAKE) dok-clean
285         @$(ECHO) Announce texts are done. Please check them. Some hand editing
286         @$(ECHO) may be required.
287
288 # The main Privoxy config file, generated from sgml sources. 
289 # NOTE: This will require some hand editing. The new file is outputted 
290 # as config.new so that problem sections can be compared to previous
291 # version. This is hardcored to w3m for html/text conversion. Also, 
292 # requires the shell util 'fmt'.
293 config-file: ensure-dkprefix ensure-jadebin ensure-wdump dok-release
294         $(DB)-notoc -iconfig-file -V nochunks config.sgml > tmp.html &&\
295         w3m -dump tmp.html |fmt -w 70 > $(ROOT)/config.new && $(RM) tmp.*
296         $(PERL) -pi.bak -e 's/^1\. \@\@TITLE\@\@/     /i;\
297                      /^\d\.\d\.\s+/ && tr/[a-z]/[A-Z]/;\
298                      $$header_len=0 unless $$hit_header;\
299                      if ($$hit_header) {\
300                         print "#  ";\
301                         for ($$i=1; $$i < $$header_len; $$i++) {print "=";}\
302                         print "\n";\
303                      };\
304                      $$hit_header=0;\
305                      $$hit_header=1 if m/^(\d\.)(\d\.)(\d\.)?\s/ && s/^(\d\.)//;\
306                      $$header_len = length($$_);\
307                                  s/^/#  /;  /^#  #{12,}/ && s/^#  #/####/;\
308                      s/^.*$$// if $$hit_option;\
309                      $$hit_option=0;\
310                      s/^\n//;  s/^#\s*-{20,}//;\
311                      $$hit_option=1 if s/^#\s+@@//;'   $(ROOT)/config.new
312         $(RM) $(ROOT)/*.bak *.tmp tmp.* $(DOC_TMP)
313         @$(ECHO)  "****************************************************"
314         @$(ECHO)  "The output file is config.new."
315         @$(ECHO)  "Now -- you need to hand edit the results!!!"
316         @$(ECHO)  "In particular, check the Debug levels, and the"
317         @$(ECHO)  "permit-access, forward & socks examples. They"
318         @$(ECHO)  "probably got hammered."
319         @$(ECHO)  "****************************************************"
320
321 # config file, alternate verison using lynx (perl stuff unfinished). Lynx
322 # does not do so good a job.
323 config-file-alt: dok-release ensure-wdump
324         $(ECHO) -e ".h2 JUSTIFY\\nJUSTIFY:FALSE" > tmp.lynx_cfg &&\
325         $(DB)-notoc -iconfig-file -V nochunks config.sgml > tmp.html &&\
326         lynx -cfg=tmp.lynx_cfg -width=78 -dump tmp.html > ../../config.new && $(RM) tmp.*
327         $(PERL) -pi -e 's/^(   )//;\
328                         s/:$\/:\n/' $(ROOT)/config.new
329
330 # This is mostly to catch cruft from build failures
331 dok-clean:
332         $(RM) $(DOC_TMP) `find $(ROOT) -name "tmp.*" -o -name "*.tmp" -o -name "*.bak" -o -name "*.fot"`
333
334 tidy:
335         $(RM) `find . -name "*~"`
336         $(RM) `find . -name ".\#*"`
337
338 clobber: tidy clean
339         $(RM) GNUmakefile ldp.dsl
340
341 distclean: clobber
342
343 coffee:
344          @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,\
345                   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,\
346                   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,\
347                   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,\
348                   193,51,228,11,1,0,0);'|zcat
349
350 #############################################################################
351
352 # $Log: GNUmakefile.in,v $
353 # Revision 1.3  2002/06/07 00:27:04  hal9
354 # Fixing man2html quirk that pulls in punctuation, and breaks URLs.
355 #
356 # Revision 1.2  2002/06/05 04:17:19  hal9
357 # Add dok-man-test target as temp workaround for docbook2man ignoring -i command
358 # line option.
359 #
360 # Revision 1.1  2002/06/05 00:28:28  hal9
361 # Moving all doc building to doc/source. Rewrite all targets (not well tested).
362 # Docs are now built without touching sgml source.
363 #