get rid of a compiler warning
[privoxy.git] / GNUmakefile.in
1 # Note:  GNUmakefile is built automatically from GNUmakefile.in
2 #
3 # $Id: GNUmakefile.in,v 1.263 2017/06/01 13:22:46 ler762 Exp $
4 #
5 # Written by and Copyright (C) 2001-2017 members of the
6 # Privoxy team. https://www.privoxy.org/
7 #
8 # Based on the Internet Junkbuster originally written
9 # by and Copyright (C) 1997 Anonymous Coders and
10 # Junkbusters Corporation.  http://www.junkbusters.com
11 #
12 # This program is free software; you can redistribute it
13 # and/or modify it under the terms of the GNU General
14 # Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at
16 # your option) any later version.
17 #
18 # This program is distributed in the hope that it will
19 # be useful, but WITHOUT ANY WARRANTY; without even the
20 # implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE.  See the GNU General Public
22 # License for more details.
23 #
24 # The GNU General Public License should be included with
25 # this file.  If not, you can view it at
26 # http://www.gnu.org/copyleft/gpl.html
27 # or write to the Free Software Foundation, Inc., 59
28 # Temple Place - Suite 330, Boston, MA  02111-1307, USA.
29 #
30
31 #############################################################################
32 # Set make command correctly
33 #############################################################################
34 @SET_MAKE@
35
36 #############################################################################
37 # Version number (for RPM)
38 #############################################################################
39
40 VERSION_MAJOR = @VERSION_MAJOR@
41 VERSION_MINOR = @VERSION_MINOR@
42 VERSION_POINT = @VERSION_POINT@
43 CODE_STATUS   = @CODE_STATUS@
44 VERSION       = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_POINT)
45 SNAPVERSION   = $(VERSION)-$(shell date "+%Y%m%d")
46
47 SOURCE_DATE_EPOCH = @SOURCE_DATE_EPOCH@
48 MTREE_SPEC_FILE = privoxy-$(VERSION)-$(CODE_STATUS).spec
49
50 #############################################################################
51 # "make install" directories and variables
52 #############################################################################
53
54 #User Group paras
55 USER         = @USER@
56 GROUP      = @GROUP@
57
58 datarootdir  = @datarootdir@
59 prefix       = @prefix@
60 exec_prefix  = @exec_prefix@
61 CONF_BASE    = @sysconfdir@
62 SBIN_DEST    = @sbindir@
63 MAN_DIR      = @mandir@
64 MAN_DEST     = $(MAN_DIR)/man1
65 MAN_PAGE     = privoxy.1
66 SHARE_DEST   = @datadir@
67 DOC_DEST     = $(SHARE_DEST)/doc/privoxy
68 VAR_DEST     = @localstatedir@
69 LOGS_DEST    = $(VAR_DEST)/log/privoxy
70 PIDS_DEST    = $(VAR_DEST)/run
71
72 # if $prefix = /usr/local then the default CONFDEST change from
73 # CONF_DEST = $(CONF_BASE) to CONF_DEST = $(CONF_BASE)/privoxy
74 # by the target rule CONF_DEST
75 #
76 # also if the $prefix is /usr/local and there is no
77 # $(SHARE_DEST)/doc, it checks for $prefix/doc and installs there
78 # instead in this situation
79 #
80 # finally if $prefix=/usr/local and VAR_DEST=$prefix/var it
81 # changes this to /var for storing the logs and pidfile
82
83 # used in source dir only, the install goes to $share_dest/doc/privoxy
84 DOK_WEB = doc/webserver/
85
86 # Install usage should be compatible with install-sh.
87 INSTALL    = @INSTALL@
88 # Binaries
89 BIN_MODE         = 0755
90 # Support files, docs, etc.
91 RA_MODE   = 0644
92 # Directory
93 DIR_MODE   = 0755
94 # Files daemon writes to.
95 RWD_MODE   = 0660
96 INSTALL_P  = -m $(BIN_MODE)
97 INSTALL_T  = -m $(RA_MODE)
98 INSTALL_D  = -m $(DIR_MODE) -d
99 INSTALL_R  = -m $(RWD_MODE)
100
101 # install options for superuser install
102 #INSTALL_S  = -g @GROUP@ -o @USER@
103
104 #############################################################################
105 # Build tools
106 #############################################################################
107
108 PROGRAM    = privoxy@EXEEXT@
109 CC         = @CC@
110 ECHO       = echo
111 GZIP_PROG  = gzip
112
113 # id -u is not universal. FIXME: need to set from configure. Breaks on
114 # Solaris.
115 #ID         = id -u
116 ID         = id
117 LD         = @CC@
118 RM         = rm -f
119 CP         = cp -f
120 RMDIR      = rmdir
121 MKDIR      = ./mkinstalldirs
122 STRIP_PROG = strip
123 SED        = sed
124 GREP       = grep
125 CAT        = cat
126 MV         = mv
127 TAR        = tar
128 LN         = ln
129 TOUCH      = touch
130 KILL       = kill
131 CHMOD      = chmod
132 CHOWN      = chown
133 CHGRP      = chgrp
134 GROUPS     = groups
135 W3M_DUMP   = env -u LANG LC_ALL=C @W3M@ -dump
136 W3M_DUMP_UTF8 = @W3M@ -dump
137 JADECAT    = @JADECAT@
138 JADEBIN    = @JADEBIN@
139 DB         = $(JADEBIN) $(JADECAT) -ihtml -t sgml  -D.. -d ldp.dsl\#html
140 DB2HTML    = @DB2HTML@
141 MAN2HTML   = @MAN2HTML@
142 G2H_CMD    = groff -mandoc -Thtml
143 TARGET_OS  = @host@
144 PERL       = perl
145 DOC_DIR    = doc/source
146 DOC_TMP    = $(DOC_DIR)/tmp
147 DOC_STATUS = @DOC_STATUS@
148 TIDY       = tidy -modify -indent -wrap 120 --tidy-mark no
149 RSYNC      = rsync -av -c --chmod=D755,F644
150
151 # Program to do LF->CRLF
152 DOSFILTER  = $(PERL) -p -e 's/\n/\r\n/'
153 CVSROOT    = :pserver:anonymous@ijbswa.cvs.sourceforge.net:/cvsroot/ijbswa
154 #TMPDIR     := $(shell mktemp -d /tmp/$(PROGRAM).XXXXXX)
155 # If your SF user name differs from your local one,
156 # change this to "ssh -l sf-username"
157 SSH     = ssh
158 WWW_ROOT = /home/project-web/ijbswa
159 # SourceForge login name used by the 'sf-shell' target (optional)
160 SOURCE_FORGE_NAME = ''
161
162 #############################################################################
163 # Setup for make distribution for now.
164 #############################################################################
165
166 TAR_ARCH = /tmp/privoxy-$(VERSION).tar.gz
167 GEN_DIST_TAR_NAME = privoxy-$(TARGET_OS)-$(VERSION)-$(CODE_STATUS).tar
168
169 #############################################################################
170 # We include these files in our distributions
171 #############################################################################
172 CONFIGS =       config trust default.action match-all.action \
173                 user.action default.filter user.filter \
174                 regression-tests.action
175
176 # take care that no CVS .cvsignore or other crappy files
177 # are included here
178 # and escape every '#' in the find. doh.
179 CONFIG_FILES = $(CONFIGS) \
180                 `find templates/ -type f | grep -v "CVS" | grep -v "\.\#" | grep -v ".*~" | grep -v ".cvsignore" | grep -v "TAGS" | sort`
181
182 DOC_FILES = AUTHORS LICENSE README ChangeLog INSTALL \
183                 `find doc/webserver/ -name "*.html" | grep -v "\(webserver\|team\)\/index\.html" | sort` \
184                 `find doc/webserver/ -name "*.css" | sort` \
185                 $(MAN_PAGE)
186
187 #############################################################################
188 # Filenames and libraries
189 #############################################################################
190
191 C_SRC  = actions.c cgi.c cgiedit.c cgisimple.c deanimate.c encode.c \
192          errlog.c filters.c gateway.c jbsockets.c jcc.c \
193          list.c loadcfg.c loaders.c miscutil.c parsers.c ssplit.c \
194          urlmatch.c
195
196 C_OBJS = $(C_SRC:.c=.@OBJEXT@)
197 C_HDRS = $(C_SRC:.c=.h) project.h actionlist.h
198
199 CLIENT_TAG_SRC = @FEATURE_CLIENT_TAGS_ONLY@client-tags.c
200 CLIENT_TAG_OBJS = @FEATURE_CLIENT_TAGS_ONLY@client-tags.@OBJEXT@
201
202 FUZZ_SRC = @FUZZ_ONLY@fuzz.c
203 FUZZ_OBJS = @FUZZ_ONLY@fuzz.@OBJEXT@
204
205 W32_SRC   = @WIN_ONLY@w32log.c w32taskbar.c win32.c w32svrapi.c
206 W32_FILES = @WIN_ONLY@w32.res
207 W32_OBJS  = @WIN_ONLY@$(W32_SRC:.c=.@OBJEXT@) $(W32_FILES)
208 W32_HDRS  = @WIN_ONLY@w32log.h w32taskbar.h win32.h w32res.h w32svrapi.h
209 W32_LIB   = @WIN_ONLY@-lwsock32 -lcomctl32
210 W32_INIS  = @WIN_ONLY@config.txt trust.txt
211
212 PCRS_SRC     = @STATIC_PCRS_ONLY@pcrs.c
213 PCRS_OBJS    = @STATIC_PCRS_ONLY@$(PCRS_SRC:.c=.@OBJEXT@)
214 PCRS_HDRS    = @STATIC_PCRS_ONLY@$(PCRS_SRC:.c=.h)
215
216 PCRE_SRC     = @STATIC_PCRE_ONLY@pcre/get.c pcre/maketables.c pcre/study.c pcre/pcre.c
217 PCRE_OBJS    = @STATIC_PCRE_ONLY@$(PCRE_SRC:.c=.@OBJEXT@)
218 PCRE_HDRS    = @STATIC_PCRE_ONLY@pcre/config.h pcre/chartables.c pcre/internal.h pcre/pcre.h
219
220 # No REGEX (maybe because dynamically linked pcreposix):
221 REGEX_SRC    =
222 @STATIC_PCRE_ONLY@REGEX_SRC = pcre/pcreposix.c
223
224 REGEX_OBJS   = $(REGEX_SRC:.c=.@OBJEXT@)
225 REGEX_HDRS   = $(REGEX_SRC:.c=.h)
226
227 # Dependencies introduced by #include "project.h".
228 PROJECT_H_DEPS = project.h $(REGEX_HDRS) $(PCRS_HDRS) @STATIC_PCRE_ONLY@pcre/pcre.h
229
230 # Socket libraries for platforms that need them explicitly defined
231 SOCKET_LIB   = @SOCKET_LIB@
232
233 # PThreads library, if needed.
234 PTHREAD_LIB  = @PTHREAD_ONLY@@PTHREAD_LIB@
235
236 SRCS         = $(C_SRC) $(CLIENT_TAG_SRC) $(FUZZ_SRC) $(W32_SRC)  $(PCRS_SRC)  $(PCRE_SRC)  $(REGEX_SRC)
237 OBJS         = $(C_OBJS) $(CLIENT_TAG_OBJS) $(FUZZ_OBJS) $(W32_OBJS) $(PCRS_OBJS) $(PCRE_OBJS) $(REGEX_OBJS)
238 HDRS         = $(C_HDRS) $(W32_HDRS) $(PCRS_HDRS) $(PCRE_OBJS) $(REGEX_HDRS)
239 LIBS         = @LIBS@ $(W32_LIB) $(SOCKET_LIB) $(PTHREAD_LIB)
240
241
242 #############################################################################
243 # Compiler switches
244 #############################################################################
245
246 # The flag "-mno-win32" can be used by Cygwin to emulate a un?x type build.
247 # The flag "-mwindows -mno-cygwin" will cause Cygwin to use MingW32 for a
248 # Win32 GUI build.
249 # The flag "-pthread" is required if using Pthreads under Linux (and
250 # possibly other OSs).
251 SPECIAL_CFLAGS = @SPECIAL_CFLAGS@
252
253 # Add your flags here
254 OTHER_CFLAGS =
255
256 CFLAGS = @CFLAGS@ @CPPFLAGS@ $(OTHER_CFLAGS) $(SPECIAL_CFLAGS) -Wall \
257          @STATIC_PCRE_ONLY@ -Ipcre
258
259 LDFLAGS = @LDFLAGS@ $(DEBUG_CFLAGS) $(SPECIAL_CFLAGS)
260
261
262 #############################################################################
263 # Build section.
264 #
265 # There should NOT be any targets above this line.
266 #############################################################################
267 all: $(PROGRAM) default.action
268
269
270 #############################################################################
271 # Phony targets
272 #############################################################################
273 .PHONY: all inifiles \
274 win-dist tarball-dist dok webserver clean clobber tags \
275 install CONF_DEST LOG_DEST \
276 PID_DEST check_doc install-strip uninstall GROUP_T
277
278 #############################################################################
279 # Define this explicitly because Solaris is broken!
280 #############################################################################
281 %.o: %.c
282         $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
283
284
285 #############################################################################
286 # Strip master copy comments from default.action:
287 #############################################################################
288 default.action: default.action.master
289         $(GREP) -v '^#MASTER#' default.action.master > $@
290 #############################################################################
291 # Win32 config files
292 #############################################################################
293
294 inifiles: $(W32_INIS)
295
296 config.txt: config
297         $(SED) -e 's!\trustfile trust!trustfile trust.txt!' \
298                -e 's!\logfile logfile!logfile privoxy.log!' \
299                -e 's!#Win32-only: !!' \
300                < $< | \
301                $(DOSFILTER) > $@
302         # LF to CRLF in default.action
303         $(DOSFILTER) <default.action >default.action.txt && mv default.action.txt default.action
304         # LF to CRLF in default.filter
305         $(DOSFILTER) <default.filter >default.filter.txt && mv default.filter.txt default.filter
306
307 trust.txt: trust
308         $(DOSFILTER) < $< > $@
309
310 #############################################################################
311 # Pre-dist check:
312 #############################################################################
313 dist-check:
314         @if [ -d CVS ]; then \
315            $(ECHO) "***************************************************"; \
316            $(ECHO) "***                                             ***"; \
317            $(ECHO) "***                  WARNING                    ***"; \
318            $(ECHO) "***                                             ***"; \
319            $(ECHO) "*** The presence of a CVS subdirectory suggests ***"; \
320            $(ECHO) "*** that you are trying to build a distribution ***"; \
321            $(ECHO) "*** package based on a checked out, not an      ***"; \
322            $(ECHO) "*** exported copy of the source tree. Please    ***"; \
323            $(ECHO) "*** see \"Releasing a new version\" in the        ***"; \
324            $(ECHO) "*** developer manual.                           ***"; \
325            $(ECHO) "***                                             ***"; \
326            $(ECHO) "***************************************************"; \
327            $(ECHO) "Type \"yes i am sure\" if you are sure that you"; \
328            $(ECHO) -n "really want to proceed: "; \
329            read answer; \
330            if [ "$$answer" != "yes i am sure" ]; then exit 1; fi \
331          fi;
332
333
334 #############################################################################
335 # create tar.gz from CVS:
336 # This make-target is usually called through 'create-archive'. If you
337 # run 'make create-snapshot' without setting SNAPVERSION, you'll get a
338 # tar.gz with the current date in the name.
339 # The main usage is to run it as follows (Red Hat example):
340 # make SNAPVERSION=1.6x create-snapshot
341 # This creates a tar.gz.
342 #############################################################################
343 create-snapshot:
344         @tag=`cvs -d $(CVSROOT) status Makefile | awk ' /Sticky Tag/ { print $$3 } '` 2> /dev/null; \
345         [ x"$$tag" = x"(none)" ] && tag=HEAD; \
346         echo "*** Creating package from $$tag!"; \
347         TMPDIR=$(shell mktemp -d /tmp/$(PROGRAM).XXXXXX); \
348         cd $$TMPDIR ; cvs -Q -d $(CVSROOT) export -r $$tag current || echo "Um... export aborted."; \
349         cd $$TMPDIR/current; \
350         $(TAR) --exclude ".cvsignore" --exclude "CVS" \
351                 -czf /tmp/$(PROGRAM)-$(VERSION).tar.gz .; \
352         $(RM) -rf $$TMPDIR
353         @echo "Resulting file is /tmp/$(PROGRAM)-$(VERSION).tar.gz"
354
355
356 #############################################################################
357 # looks at the version of Makefile and exports a corresponding source-tree
358 # example: if the Makefile has the sticky tag v_2_9_13, you'll get
359 # privoxy-*-2.4.13.tar.gz.
360 #############################################################################
361 create-archive:
362         make SNAPVERSION=$(SNAPVERSION) create-snapshot
363
364 #############################################################################
365 # generic distribution
366 #############################################################################
367 gen-dist: dist-check
368         @$(ECHO) ""
369         @$(ECHO) "You have run autoconf && autoheader && ./configure right?"
370         @$(ECHO) ""
371         $(MAKE) $(PROGRAM)
372         $(STRIP_PROG) $(PROGRAM)
373         $(LN) -s `pwd` ../privoxy-$(VERSION)-$(CODE_STATUS)
374 # add program
375         (cd .. && $(TAR) --exclude "PACKAGERS" -cvhf $(GEN_DIST_TAR_NAME) privoxy-$(VERSION)-$(CODE_STATUS)/$(PROGRAM))
376 # add config files
377         for foo in $(CONFIG_FILES); do \
378                 (cd .. && $(TAR) --exclude "PACKAGERS" -uvhf $(GEN_DIST_TAR_NAME) privoxy-$(VERSION)-$(CODE_STATUS)/$$foo;) \
379         done;
380 # add documentation
381         for foo in $(DOC_FILES); do \
382                 (cd .. && $(TAR) --exclude "PACKAGERS" -uvhf $(GEN_DIST_TAR_NAME) privoxy-$(VERSION)-$(CODE_STATUS)/$$foo;) \
383         done;
384 # add tools
385         (cd .. && $(TAR) -uvhf $(GEN_DIST_TAR_NAME) privoxy-$(VERSION)-$(CODE_STATUS)/tools)
386 # and zip the archive
387         $(RM) ../privoxy-$(VERSION)-$(CODE_STATUS)
388         $(GZIP_PROG) ../$(GEN_DIST_TAR_NAME)
389         @$(ECHO) Distribution with binary created.
390
391 # anonymously ncftps the package to sourceforge
392 gen-upload:
393         ncftpput -u anonymous -p ijbswa-developers@lists.sourceforge.net upload.sourceforge.net /incoming ../$(GEN_DIST_TAR_NAME).gz
394         @$(ECHO) -------------------------------------------------------
395         @$(ECHO) Now goto
396         @$(ECHO) https://sourceforge.net/project/admin/editpackages.php?group_id=11118
397         @$(ECHO) ... and release the files.
398         @$(ECHO) -------------------------------------------------------
399
400 # use with care
401 gen-clean:
402         $(RM) ../$(GEN_DIST_TAR_NAME)*
403
404 #############################################################################
405 # Tarball distribution: No CVS dirs, dotfiles, debian build dir,
406 # (FIXME:) only parts of the static / generated docs mix in doc/webserver
407 #############################################################################
408
409 tarball-dist: dist-check clean clobber
410         $(LN) -s `pwd` ../privoxy-$(VERSION)-$(CODE_STATUS)
411
412         for i in `find . -type f -a -not \( -path "*/CVS*" -o -name ".*" \
413         -o -path "*/debian/*" -o -path "*/actions/*" -o -name "*.php" -o \
414         -name "PACKAGERS" -o -path "*.git/*" \) | sort`; do \
415            files="$$files privoxy-$(VERSION)-$(CODE_STATUS)/$$i"; \
416         done &&  \
417         cd .. && $(TAR) -cvhf privoxy-$(VERSION)-$(CODE_STATUS)-src.tar $$files ; \
418
419 # and zip the archive
420         $(RM) ../privoxy-$(VERSION)-$(CODE_STATUS)
421         $(GZIP_PROG) ../privoxy-$(VERSION)-$(CODE_STATUS)-src.tar
422         @$(ECHO) Tarball distribution created.
423
424 # Create a mtree spec file that can be used to get a reproducible tar ball
425 mtree-spec:
426         $(LN) -s `pwd` ../privoxy-$(VERSION)-$(CODE_STATUS)
427         $(ECHO) "#mtree 2.0" > $(MTREE_SPEC_FILE)
428         for i in `find . -type f -a -not \( -path "*/CVS*" -o -name ".*" \
429         -o -path "*/debian/*" -o -path "*/actions/*" -o -name "*.php" -o \
430         -name "PACKAGERS" -o -path "*.git/*" -o -name "*.spec" \) | env -i sort`; do \
431            $(ECHO) "privoxy-$(VERSION)-$(CODE_STATUS)/$$i time=$(SOURCE_DATE_EPOCH) type=file uname=privoxy gname=privoxy mode=0555"; \
432         done >> $(MTREE_SPEC_FILE)
433         $(RM) ../privoxy-$(VERSION)-$(CODE_STATUS)
434
435 # Create a reproducible tarball.
436 # Requires a tar implementation with mtree support.
437 reproducible-tarball-dist: dist-check clean clobber mtree-spec
438         $(LN) -s `pwd` ../privoxy-$(VERSION)-$(CODE_STATUS)
439
440         $(TAR) cvhf privoxy-$(VERSION)-$(CODE_STATUS)-src.tar -C .. @privoxy-$(VERSION)-$(CODE_STATUS)/$(MTREE_SPEC_FILE)
441         $(GZIP_PROG) -n privoxy-$(VERSION)-$(CODE_STATUS)-src.tar
442         $(RM) ../privoxy-$(VERSION)-$(CODE_STATUS) $(MTREE_SPEC_FILE)
443         @$(ECHO) Reproducible tarball distribution created.
444
445 # anonymously ncftps the tarball to sourceforge
446 tarball-upload:
447         ncftpput -u anonymous -p ijbswa-developers@lists.sourceforge.net upload.sourceforge.net /incoming ../privoxy-$(VERSION)-$(CODE_STATUS)-src.tar.gz
448         @$(ECHO) -------------------------------------------------------
449         @$(ECHO) Now goto
450         @$(ECHO) https://sourceforge.net/project/admin/editpackages.php?group_id=11118
451         @$(ECHO) ... and release the files.
452         @$(ECHO) -------------------------------------------------------
453
454 tarball-clean:
455         $(RM) ../privoxy-$(VERSION)-$(CODE_STATUS)-src.tar.gz
456
457 #############################################################################
458 #
459 # Documentation
460 #
461 # converts doc/source/*.sgml into html and man pages
462 #
463 #############################################################################
464
465 # developer manual
466 dok-devel:
467         $(RM) doc/webserver/developer-manual/*.html
468         $(RM) -r doc/source/developer-manual
469         mkdir -p doc/source/developer-manual
470         cd doc/source/developer-manual && $(DB) ../developer-manual.sgml && cd .. && cp developer-manual/*.html ../webserver/developer-manual/
471
472 # user manual
473 dok-user:
474         $(RM) doc/webserver/user-manual/*.html
475         $(RM) -r doc/source/user-manual/
476         mkdir -p doc/source/user-manual
477         cd doc/source/user-manual && $(DB) -iuser-man ../user-manual.sgml && cd .. && cp user-manual/*.html ../webserver/user-manual/
478         # FIXME: temp fix so same stylesheet gets in more than one place so it works
479         # for all doc set-ups, including the 'user manual' config option in local
480         # system where it MUST be in same directory as html.
481         $(PERL) -pi.bak -e 's/<\/head/\n<LINK REL=\"STYLESHEET\" TYPE=\"text\/css\" HREF=\"p_doc.css\">\n<\/head/i' doc/webserver/user-manual/*html && \
482         rm doc/webserver/user-manual/*html.bak
483
484 # faq
485 dok-faq:
486         $(RM) doc/webserver/faq/*.html
487         $(RM) -r doc/source/faq
488         mkdir -p doc/source/faq
489         cd doc/source/faq && $(DB) ../faq.sgml && cd .. && cp faq/*.html ../webserver/faq/
490
491 # man page, one variation. Try to use the next target, just 'make man'.
492 dok-man:
493         $(RM) doc/man/* doc/webserver/man-page/*.html
494         echo MAN2HTML is $(MAN2HTML)
495         @if [ $(MAN2HTML) != "false" ]; then \
496                 $(ECHO) "<html><head><title>Privoxy Man page</title><link rel=\"stylesheet\" type=\"text/css\" href=\"../p_web.css\"></head><body><H2>NAME</H2>" > doc/webserver/man-page/privoxy-man-page.html; \
497                 man ./$(MAN_PAGE) | $(MAN2HTML) -bare >> doc/webserver/man-page/privoxy-man-page.html; \
498                 $(ECHO) "</body></html>" >> doc/webserver/man-page/privoxy-man-page.html; \
499         else \
500                 $(MAKE) groff2html; \
501         fi;
502
503 # Build man page from sgml. This requires the SGMLSpm perl module.
504 # See CPAN, or your favorite perl repository. This is the preferred
505 # target for man page generation!
506 man: dok-release
507         mkdir -p doc/source/temp && cd doc/source/temp && $(RM) * ;\
508         nsgmls ../privoxy-man-page.sgml  | sgmlspl ../../../utils/docbook2man/docbook2man-spec.pl &&\
509         perl -pi.bak -e 's/ <URL:.*>//; s/\[ /\[/g' $(MAN_PAGE) ;\
510         perl -pi.bak -e "s/\[ /\[/g;s/á/\\\\['a]/g;s/é/\\\\['e]/g" $(MAN_PAGE); \
511         perl -pi.bak -e "s/ö/\\\\[:o]/g" $(MAN_PAGE); \
512         perl -pi.bak -e 's/([ {])-([a-z])/$$1\\-$$2/g' $(MAN_PAGE); \
513         perl -pi.bak -e 's/ --([a-z])/ \\-\\-$$1/g' $(MAN_PAGE); \
514         perl -pi.bak -e 's/\\fB--/\\fB\\-\\-/g' $(MAN_PAGE); \
515         $(DB) ../privoxy-man-page.sgml && $(MV) -f $(MAN_PAGE) ../../../$(MAN_PAGE)
516
517 # For those with man2html ala RH7s.
518 man2html:
519         mkdir -p doc/webserver/man-page
520         @if [ $(MAN2HTML) != "false" ]; then \
521                 $(MAN2HTML) $(MAN_PAGE) |grep -v "^Content-type" > tmp.html; \
522                 $(PERL) -pi.bak -e 's/<A .*Contents<\/A>//; s/<A .*man2html<\/A>/man2html/' tmp.html; \
523                 $(PERL) -pi.bak -e 's/(<\/HEAD>)/<LINK REL=\"STYLESHEET\" TYPE=\"text\/css\" HREF=\"..\/p_doc.css\"><\/HEAD>/' tmp.html; \
524                 $(PERL) -pi.bak -e 's/(<A.*),(">)/$$1$$2/g' tmp.html; \
525                 $(PERL) -pi.bak -e 's,\.">,">,g' tmp.html; \
526                 $(PERL) -pi.bak -e "s/\['a\]/\&aacute;/g;s/\['e\]/\&eacute;/g" tmp.html; \
527                 $(SED) -e 's/\a//g' tmp.html > doc/webserver/man-page/privoxy-man-page.html && $(RM) tmp.*; \
528         else \
529                 $(MAKE) groff2html; \
530         fi;
531
532 # Otherwise we get plain groff conversion.
533 groff2html:
534         $(G2H_CMD) ./$(MAN_PAGE) | $(SED) -e 's@</head>@<link REL="STYLESHEET" TYPE="text/css" HREF="../p_doc.css"></head>@' > doc/webserver/man-page/privoxy-man-page.html
535
536
537 # readme page and INSTALL file
538 dok-readme: dok-release
539         cd doc/source && $(DB)-notoc -V nochunks readme.sgml > tmp.html &&\
540         $(W3M_DUMP) tmp.html > ../../README ;\
541         $(DB)-notoc -V nochunks install.sgml > tmp.html &&\
542         $(W3M_DUMP) tmp.html > ../../INSTALL ;\
543         $(RM) tmp.*
544
545 # index.sgml is used to create both the Home Page, and a local index
546 # for documentation, etc.
547 #
548 # index.html for webserver:
549 dok-webserver:
550         cd doc/source/webserver && $(DB)-notoc -ip-homepage -V nochunks index.sgml > ../../webserver/index.html
551         $(PERL) -pi.bak -e 's/..\/p_doc.css/p_doc.css/;\
552         s/<\/HEAD/\n<meta name=\"description\" content=\"Privoxy helps users to protect their privacy.\"><\/HEAD/;\
553         s/\.\d\. //;\
554         s/__copy/&copy;/;\
555         s@(<SUB)@<p style="text-align: center">\1@; s@(</SUB)@\1></p@' \
556      doc/webserver/index.html && $(RM) doc/webserver/*.bak
557
558 # privoxy-index.html for local documentation:
559 dok-index:
560         cd doc/source/webserver && $(DB)-notoc -ip-index -V nochunks index.sgml > ../../webserver/privoxy-index.html
561         $(PERL) -pi.bak -e 's/..\/p_doc.css/p_doc.css/;\
562         s/<\/HEAD/\n<meta name=\"description\" content=\"Privoxy helps users to protect their privacy.\"><\/HEAD/;\
563         s/\.\d\. //;\
564         s/__copy/&copy;/' \
565      doc/webserver/privoxy-index.html && $(RM) doc/webserver/*.bak
566
567 # Main documentation target.
568 dok: dok-release dok-devel dok-user dok-faq dok-readme dok-webserver dok-authors dok-index
569         @$(ECHO) Documentation created.
570
571 ## Make AUTHORS file
572 dok-authors:
573         cd doc/source && $(DB) -V nochunks authors.sgml > tmp.html && $(W3M_DUMP_UTF8) \
574           tmp.html > ../../AUTHORS && $(RM) tmp.html
575
576 # Set doc entities for VERSION and CODE_STATUS in sgml docs. Toggle content
577 # exceptions accordingly. This needs to go before any doc building (doh).
578 dok-release:
579         @$(ECHO) Setting doc version and status to $(VERSION), $(CODE_STATUS)
580         @$(PERL) -pi.bak -e 's/<!entity +p-version.*>/<!entity p-version "$(VERSION)">/;\
581      s/<!entity +p-status.*>/<!entity p-status "$(CODE_STATUS)">/' \
582      doc/source/*sgml doc/source/*/*sgml
583         $(RM) -r doc/source/*bak doc/source/*/*bak
584         @if [ $(CODE_STATUS) = "stable" ]; then \
585                 $(ECHO) Setting docs to stable $(VERSION); \
586                 $(PERL) -pi.bak -e 's/<!entity +% +p-stable.*>/<!entity % p-stable "INCLUDE">/;\
587                         s/<!entity +% +p-not-stable.*>/<!entity % p-not-stable "IGNORE">/' \
588                 doc/source/*sgml doc/source/*/*sgml; \
589         else \
590                 $(ECHO) Setting docs to not stable $(VERSION); \
591                 $(PERL) -pi.bak -e 's/<!entity +% +p-stable.*>/<!entity % p-stable "IGNORE">/; \
592                         s/<!entity +% +p-not-stable.*>/<!entity % p-not-stable "INCLUDE">/' \
593                 doc/source/*sgml doc/source/*/*sgml; \
594         fi;
595         $(RM) -r doc/source/*bak doc/source/*/*bak;
596
597 # The main Privoxy config file, generated from sgml sources.
598 # NOTE: This will require some hand editing.
599 config-file: dok-release generate-config-file
600
601         $(RM) config.bak config.html
602         @$(ECHO)  "****************************************************"
603         @$(ECHO)  "The config file has been optimistically updated"
604         @$(ECHO)  "Now -- you may need to hand edit the results!"
605         @$(ECHO)  "In particular, check the Debug levels, the"
606         @$(ECHO)  "permit-access, forward & socks examples and the"
607         @$(ECHO)  "various user-manual examples, which all"
608         @$(ECHO)  "might have gotten hammered."
609         @$(ECHO)  "****************************************************"
610
611 generate-config-file:
612         cd doc/source && $(DB)-notoc -iconfig-file -V nochunks config.sgml > ../../config.html
613         $(W3M_DUMP) -cols 67 config.html > config
614         $(PERL) -i.bak utils/prepare-configfile.pl config
615
616 #############################################################################
617 #
618 # Webserver
619 #
620 # moves documentation to webserver
621 #
622 #############################################################################
623 sf-shell:
624         @sf_name=$(SOURCE_FORGE_NAME); \
625         [ -n "$${sf_name}" ] || read -p "Enter SourceForge username: " sf_name || exit 1; \
626         echo "Opening shell for $${sf_name} ..."; \
627         ssh -t $${sf_name},ijbswa@shell.sourceforge.net create
628
629 webserver: clean-editor-files
630         @$(ECHO) -------------------------------------------------------
631         @$(ECHO) You will need to "create" a SF shell first:
632         @$(ECHO)    ssh -t SF-USER-ID,ijbswa@shell.sourceforge.net create
633         @$(ECHO) Please make sure your documentation files are up to date.
634         @$(ECHO) Note that this command updates the home page and copys
635         @$(ECHO) all stuff to the webserver, it will not remove obsolete documents.
636         @$(ECHO) Note that a botched upload can result in the documentation
637         @$(ECHO) on the website becoming unreachable! Also the CSS files
638         @$(ECHO) currently seem to end up at the wrong place.
639         @$(ECHO) -------------------------------------------------------
640
641         @$(ECHO) Replacing the user-manual symlink
642         @$(SSH) shell.sourceforge.net "cd $(WWW_ROOT)/htdocs && rm user-manual \
643          && mkdir -p $(VERSION)/user-manual && ln -s $(VERSION)/user-manual user-manual"
644
645         @$(ECHO) Uploading html
646         @cd doc/webserver; \
647           upload=`find . -type f -a -not \( -path "*/CVS*" -o -path "*/results*" \)`; \
648           $(TAR) cf - $$upload | $(SSH) shell.sourceforge.net 'cd $(WWW_ROOT)/htdocs/; tar xvm 2>&1 | grep -v timestamp'
649
650 web-actions:
651         @$(ECHO) Updating the actions on the webserver ...
652         @$(RSYNC) doc/webserver/actions/*.php shell.sourceforge.net:$(WWW_ROOT)/htdocs/actions
653
654 web-homepage:
655         @$(ECHO) "Updating the home page (index.html) only (be careful in case of version changes) ..."
656         @$(RSYNC) doc/webserver/index.html shell.sourceforge.net:$(WWW_ROOT)/htdocs/
657
658 web-faq:
659         @$(ECHO) Updating the FAQ on the webserver ...
660         @$(RSYNC) doc/webserver/faq/*.html shell.sourceforge.net:$(WWW_ROOT)/htdocs/faq
661
662 web-sponsors:
663         @$(ECHO) "Updating the sponsor page (index.html) only ..."
664         @$(RSYNC) doc/webserver/sponsors/index.html shell.sourceforge.net:$(WWW_ROOT)/htdocs/sponsors/
665
666 web-user-manual:
667         @$(ECHO) Updating the user manual on the webserver (do not use in case of version changes) ...
668         @$(RSYNC) doc/webserver/user-manual/*.html shell.sourceforge.net:$(WWW_ROOT)/htdocs/user-manual/
669
670 #############################################################################
671 #
672 # Try to clean up the generated HTML files.
673 #
674 # The files are such a mess that some of them require two tidy runs in a
675 # row as the first one aborts prematurely. The vanilla tidy output renders
676 # poorly because it contains a bit too much whitespace, so we additionally
677 # run the files through perl to fix this again.
678 #
679 #############################################################################
680 dok-tidy:
681         for html_file in `find doc/webserver -name "*.html"`; do \
682                 $(ECHO) "------ begin processing $$html_file" >&2 ; \
683                 $(TIDY) $$html_file || $(TIDY) $$html_file; \
684                 $(PERL) -i'' -e 's@^\s*<br>\s*$$@@; s@ +$$@@;' -n -p $$html_file; \
685         done
686
687
688 #############################################################################
689 # Source file dependencies
690 #############################################################################
691
692 actions.@OBJEXT@:   actions.c   actions.h   config.h $(PROJECT_H_DEPS) errlog.h filters.h jcc.h list.h loaders.h miscutil.h actionlist.h ssplit.h
693 cgi.@OBJEXT@:       cgi.c       cgi.h       config.h $(PROJECT_H_DEPS) cgiedit.h cgisimple.h jbsockets.h list.h pcrs.h encode.h ssplit.h jcc.h filters.h actions.h errlog.h miscutil.h
694 cgiedit.@OBJEXT@:   cgiedit.c   cgiedit.h   config.h $(PROJECT_H_DEPS) cgi.h list.h pcrs.h encode.h ssplit.h jcc.h filters.h actionlist.h actions.h errlog.h miscutil.h
695 cgisimple.@OBJEXT@: cgisimple.c cgisimple.h config.h $(PROJECT_H_DEPS) cgi.h list.h pcrs.h encode.h ssplit.h jcc.h filters.h actions.h errlog.h miscutil.h urlmatch.h
696 deanimate.@OBJEXT@: deanimate.c deanimate.h config.h $(PROJECT_H_DEPS)
697 encode.@OBJEXT@:    encode.c    encode.h    config.h
698 errlog.@OBJEXT@:    errlog.c    errlog.h    config.h $(PROJECT_H_DEPS) @WIN_ONLY@w32log.h
699 filters.@OBJEXT@:   filters.c   filters.h   config.h $(PROJECT_H_DEPS) errlog.h encode.h gateway.h jbsockets.h jcc.h loadcfg.h parsers.h ssplit.h cgi.h deanimate.h urlmatch.h @WIN_ONLY@win32.h
700 gateway.@OBJEXT@:   gateway.c   gateway.h   config.h $(PROJECT_H_DEPS) errlog.h jbsockets.h jcc.h loadcfg.h
701 jbsockets.@OBJEXT@: jbsockets.c jbsockets.h config.h $(PROJECT_H_DEPS) filters.h
702 jcc.@OBJEXT@:       jcc.c       jcc.h       config.h $(PROJECT_H_DEPS) errlog.h filters.h gateway.h jbsockets.h loadcfg.h loaders.h miscutil.h parsers.h @WIN_ONLY@w32log.h win32.h w32svrapi.h cgi.h
703 list.@OBJEXT@:      list.c      list.h      config.h $(PROJECT_H_DEPS) list.h miscutil.h
704 loadcfg.@OBJEXT@:   loadcfg.c   loadcfg.h   config.h $(PROJECT_H_DEPS) errlog.h filters.h gateway.h jbsockets.h jcc.h loaders.h miscutil.h parsers.h @WIN_ONLY@w32log.h win32.h
705 loaders.@OBJEXT@:   loaders.c   loaders.h   config.h $(PROJECT_H_DEPS) errlog.h encode.h filters.h gateway.h jcc.h loadcfg.h miscutil.h parsers.h ssplit.h
706 miscutil.@OBJEXT@:  miscutil.c  miscutil.h  config.h
707 parsers.@OBJEXT@:   parsers.c   parsers.h   config.h $(PROJECT_H_DEPS) errlog.h filters.h jbsockets.h jcc.h loadcfg.h loaders.h miscutil.h ssplit.h
708 ssplit.@OBJEXT@:    ssplit.c    ssplit.h    config.h miscutil.h
709 urlmatch.@OBJEXT@:  urlmatch.c  urlmatch.h  config.h $(PROJECT_H_DEPS) errlog.h miscutil.h ssplit.h
710 client-tags.@OBJEXT@: client-tags.c client-tags.h config.h $(PROJECT_H_DEPS) errlog.h miscutil.h ssplit.h
711 fuzz.@OBJEXT@: fuzz.c config.h $(PROJECT_H_DEPS) errlog.h miscutil.h ssplit.h
712
713 # GNU regex
714 gnu_regex.@OBJEXT@: gnu_regex.c gnu_regex.h config.h
715
716 # PCRS
717 pcrs.@OBJEXT@: pcrs.c pcrs.h config.h @STATIC_PCRE_ONLY@pcre/pcre.h
718
719 # PCRE
720 pcre/get.@OBJEXT@:        pcre/get.c        pcre/config.h pcre/internal.h pcre/pcre.h
721 pcre/maketables.@OBJEXT@: pcre/maketables.c pcre/config.h pcre/internal.h pcre/pcre.h
722 pcre/pcre.@OBJEXT@:       pcre/pcre.c       pcre/config.h pcre/internal.h pcre/pcre.h pcre/chartables.c
723 pcre/pcreposix.@OBJEXT@:  pcre/pcreposix.c  pcre/config.h pcre/internal.h pcre/pcre.h pcre/pcreposix.h
724 pcre/study.@OBJEXT@:      pcre/study.c      pcre/config.h pcre/internal.h pcre/pcre.h
725
726 # An auxiliary program makes the PCRE default character table source
727
728 pcre/chartables.c:   pcre/dftables@EXEEXT@
729                 pcre/dftables@EXEEXT@ >pcre/chartables.c
730
731 pcre/dftables@EXEEXT@:       pcre/dftables.c pcre/maketables.c pcre/pcre.h pcre/internal.h pcre/config.h
732                 $(CC) -o pcre/dftables@EXEEXT@ $(CFLAGS) pcre/dftables.c
733
734 # Win32
735 w32log.@OBJEXT@: w32log.c errlog.h config.h jcc.h loadcfg.h miscutil.h pcre/pcre.h pcre/pcreposix.h pcrs.h project.h w32log.h w32taskbar.h win32.h
736 w32taskbar.@OBJEXT@: w32taskbar.c config.h w32log.h w32taskbar.h
737 win32.@OBJEXT@: win32.c config.h jcc.h loadcfg.h pcre/pcre.h pcre/pcreposix.h pcrs.h project.h w32log.h win32.h w32svrapi.h
738
739 w32.res: w32.rc w32res.h icons/radar-01.ico icons/radar-02.ico icons/radar-03.ico icons/radar-04.ico icons/radar-05.ico icons/radar-06.ico icons/radar-07.ico icons/radar-08.ico icons/idle.ico icons/privoxy.ico config.h
740         windres -F pe-i386 -D__MINGW32__=0.2 -O coff -i $< -o $@
741
742 # AmigaOS
743 @AMIGAOS_ONLY@OBJS += amiga.o
744 @AMIGAOS_ONLY@ifeq ($(shell $(CC) -dumpmachine), m68k-amigaos)
745 @AMIGAOS_ONLY@CFLAGS += -D__AMIGAVERSION__=\"$(VERSION_MAJOR).$(VERSION_MINOR)$(VERSION_POINT)\" -D__AMIGADATE__=\"`date +%d.%m.%Y`\" -W -m68020 -noixemul -fbaserel -msmall-code
746 @AMIGAOS_ONLY@LDFLAGS += -m68020 -noixemul -fbaserel
747 @AMIGAOS_ONLY@LIBS = -lm /gg/lib/libb/libm020/libnix/swapstack.o
748 @AMIGAOS_ONLY@else
749 @AMIGAOS_ONLY@CFLAGS += -D__AMIGAVERSION__=\"$(VERSION_MAJOR).$(VERSION_MINOR)$(VERSION_POINT)\" -D__AMIGADATE__=\"`date +%d.%m.%Y`\" -Wextra -D__USE_INLINE__ -D__NO_INTUITION_RJ_MACROS
750 @AMIGAOS_ONLY@endif
751 @AMIGAOS_ONLY@amiga.o: amiga.c amiga.h config.h
752
753
754 $(PROGRAM): $(OBJS) $(W32_FILES)
755         $(LD) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS)
756
757 clean:
758         $(RM) a.out $(OBJS) $(W32_FILES) $(W32_INIS) $(PROGRAM) default.action \
759                 config.base config.tmp \
760                 `find . \( -name TAGS -o -name tags \) -a -not -path "./.git/*"` \
761                 `find . -name "*.orig" -a -not -name rc.privoxy.orig -a -not -path "./.git/*"`
762
763 clean-editor-files:
764         $(RM) `find . -name "*~"`
765         $(RM) `find . -name "#*#"` # Emacs backup files
766         $(RM) `find . -name ".\#*"`
767
768 clobber: clean-editor-files
769         $(RM) GNUmakefile configure config.h.in config.h config.cache config.status config.log logfile \
770               privoxy.log core *.tar.gz *.tar privoxy-cl.spec doc/source/ldp.dsl config.new
771         $(RM) -r autom4te.cache
772
773 #
774 # FIXME: What is all this?
775 #
776         $(RM) cscope.*  *.pdb *.lib *.exp
777
778 distclean: clobber
779
780 tags: $(SRCS) $(HDRS)
781         etags $(SRCS) $(HDRS)
782
783 CONF_DEST:=$(shell if [ "$(prefix)" = "/usr/local" ] && [ "$(CONF_BASE)" = "$(prefix)/etc" ];then \
784                 $(ECHO) "$(CONF_BASE)/privoxy";\
785          else\
786                  $(ECHO) "$(CONF_BASE)";\
787          fi)
788
789 LOG_DEST:=$(shell if [ "$(prefix)" = "/usr/local" ] && [ "$(LOGS_DEST)" = "$(prefix)/var/log/privoxy" ];then \
790                 $(ECHO) "/var/log/privoxy" ;\
791          else\
792                  $(ECHO) "$(LOGS_DEST)";\
793          fi)
794
795 PID_DEST:=$(shell if [ "$(prefix)" = "/usr/local" ] && [ "$(PIDS_DEST)" = "$(prefix)/var/run" ];then \
796                 $(ECHO) "/var/run" ;\
797          else\
798                  $(ECHO) "$(PIDS_DEST)";\
799          fi)
800
801 check_doc:=$(shell if [ ! -d "$(SHARE_DEST)/doc" ] && [ "$(prefix)" = "/usr/local" ]  && [ -d "$(prefix)/doc" ];then \
802                 $(ECHO) "1";\
803          else\
804                  $(ECHO) "0";\
805          fi)
806
807 # If USER is specified but no GROUP, assume there is a GROUP of same name.
808 GROUP_T:=$(shell if [ x$(GROUP) = x ] && [ x$(USER) != x ];then \
809                 $(ECHO) "$(USER)" ;\
810          else\
811                  $(ECHO) "$(GROUP)";\
812          fi)
813
814 install-strip:
815         $(MAKE) install STRIP=-s
816
817 # FIXME: Test USER and GROUP on Slack to make sure this works as
818 # intended.
819 #
820 # FIXME: id handling needs help, probably via configure, since 'id -u' is not
821 # universally reliable (eg Solaris). Group handling could be better.
822 # Perhaps the whole user/group validation should be done here, and simplified.
823 PROGRAM_V = Privoxy $(VERSION) $(CODE_STATUS)
824 install: CONF_DEST LOG_DEST PID_DEST check_doc GROUP_T
825         @# Quick test for valid USER.
826         @if [ -n "$(USER)" ]; then \
827                 $(ID) $(USER) >/dev/null || exit 1;\
828         fi
829         @# Test for valid group. FIXME. USER does not have to belong to GROUP
830         @# for file ownership purposes.
831 #       if [ -n "$(GROUP_T)" ] && [ -n "$(USER)" ] && ! $(GROUPS) $(USER) | $(GREP) "\<$(GROUP_T)\>" >/dev/null; then \
832 #               $(ECHO) Group $(GROUP_T) for User $(USER) is invalid && exit 1 ;\
833 #       fi
834
835         @$(ECHO) "Creating directories, and preparing $(PROGRAM_V) installation"
836         $(CHMOD) $(DIR_MODE) $(MKDIR)
837         @$(MKDIR) $(DESTDIR)$(SBIN_DEST) $(DESTDIR)$(prefix) $(DESTDIR)$(CONF_DEST) \
838                 $(DESTDIR)$(CONF_DEST)/templates $(DESTDIR)$(SHARE_DEST) \
839                 $(DESTDIR)$(LOG_DEST) $(DESTDIR)$(PID_DEST)
840         @# Install the executable binary, strip if invoked as install-strip
841         @test -n "$(STRIP)" &&\
842         $(ECHO) Installing $(PROGRAM) stripped executable to $(SBIN_DEST) ||\
843         $(ECHO) Installing $(PROGRAM) executable to $(DESTDIR)$(SBIN_DEST)
844         $(INSTALL) $(INSTALL_P) $(STRIP) $(PROGRAM) $(DESTDIR)$(SBIN_DEST)
845
846         @# Install the DOCS and man page. install-sh only does one file at a time.
847         @# FIXME: only handles jpegs.
848         -@if [ $(check_doc) = 0 ]; then \
849                 DOC=$(DOC_DEST) ;\
850         else \
851                 DOC=$(prefix)/doc/privoxy ;\
852         fi;\
853         $(MKDIR) $(DESTDIR)$$DOC $(DESTDIR)$$DOC/user-manual $(DESTDIR)$$DOC/faq $(DESTDIR)$$DOC/developer-manual \
854              $(DESTDIR)$$DOC/man-page $(DESTDIR)$$DOC/images $(DESTDIR)$(MAN_DEST) ;\
855         if [ -d "$(DOK_WEB)" ]; then \
856                 $(ECHO) Installing FAQ, Manual, and other docs to $(DESTDIR)$$DOC;\
857           for i in user-manual developer-manual faq; do \
858                for ii in $(DOK_WEB)/$$i/*html; do \
859                     $(INSTALL) $(INSTALL_T) $$ii $(DESTDIR)$$DOC/$$i;\
860                done ;\
861           done ;\
862                 for i in $(DOK_WEB)/user-manual/*jpg; do \
863                $(INSTALL) $(INSTALL_T) $$i $(DESTDIR)$$DOC/user-manual;\
864           done ;\
865                 $(INSTALL) $(INSTALL_T) $(DOK_WEB)/man-page/*html $(DESTDIR)$$DOC/man-page;\
866                 $(INSTALL) $(INSTALL_T) $(DOK_WEB)/privoxy-index.html $(DESTDIR)$$DOC/index.html;\
867                 $(INSTALL) $(INSTALL_T) AUTHORS $(DESTDIR)$$DOC;\
868                 $(INSTALL) $(INSTALL_T) LICENSE $(DESTDIR)$$DOC;\
869                 $(INSTALL) $(INSTALL_T) README $(DESTDIR)$$DOC;\
870                 $(INSTALL) $(INSTALL_T) ChangeLog $(DESTDIR)$$DOC;\
871                 $(INSTALL) $(INSTALL_T) $(DOK_WEB)/p_doc.css $(DESTDIR)$$DOC;\
872                 $(INSTALL) $(INSTALL_T) $(DOK_WEB)/p_doc.css $(DESTDIR)$$DOC/user-manual;\
873         fi
874         @# Not all platforms support gzipped man pages.
875         @$(ECHO) Installing man page to $(DESTDIR)$(MAN_DEST)/$(MAN_PAGE)
876         -$(INSTALL) $(INSTALL_T) $(MAN_PAGE)  $(DESTDIR)$(MAN_DEST)/$(MAN_PAGE)
877
878         @# Change the config file default directories according to the configured ones
879         @$(ECHO) Rewriting config for this installation
880         @if [ -f config.base ] ; then \
881                 $(CAT) config >config~ ;\
882                 $(MV) config.base config ;\
883         fi
884         $(SED) 's+^confdir \.+confdir $(CONF_DEST)+' config | \
885         $(SED) 's+^logdir \.+logdir $(LOG_DEST)+' >config.tmp
886         -@if [ $(check_doc) = 0 ]; then \
887       $(SED) 's+^#\?user-manual .*+user-manual $(DOC_DEST)/user-manual/+' config.tmp >config.updated ;\
888         else \
889       $(SED) 's+^#\?user-manual .*+user-manual $(prefix)/doc/privoxy/user-manual/+' config.tmp >config.updated ;\
890         fi;\
891         $(MV) config config.base
892         $(MV) config.updated config
893
894         @# Install the config support files. Test for root install, and abort
895         @# if there is no privoxy user, and no other user was enabled during
896         @# configure. Later, install init script if appropriate.
897         @$(ECHO) Installing templates to $(DESTDIR)$(CONF_DEST)/templates
898         @for i in `find templates -type f`; do \
899                 $(INSTALL) $(INSTALL_T) $$i $(DESTDIR)$(CONF_DEST)/templates ;\
900         done
901
902         @# FIXME: group/user validation is overly convoluted.
903         @# If superuser install ... we require a minimum of group ownership
904         @# of those files the daemon writes to, to be non-root owned.
905         @if [ "`$(ID) |sed 's/(.*//' |sed 's/.*=//'`" = "0" ] ;then\
906                 if [ x$(USER) = x ] || [ $(USER) = root ]; then \
907                         if [ x$(GROUP) = x ] || [ $(GROUP) = root ]; then \
908                                 if [ "`$(ID) privoxy`" ] && \
909                                         $(GROUPS) privoxy | $(SED) 's/^.*://' |$(GREP) "\<privoxy\>" >/dev/null; then \
910                                         $(ECHO) "Warning: Setting group owner to privoxy";\
911                                         GROUP_T=privoxy ;\
912                                 else \
913                                         $(ECHO)  "******************************************************************" ;\
914                                         $(ECHO)  " WARNING! WARNING! installing config files as root!" ;\
915                                         $(ECHO)  " It is strongly recommended to run $(PROGRAM) as a non-root user," ;\
916                                         $(ECHO)  " and to install the config files as that user and/or group!" ;\
917                                         $(ECHO)  " Please read INSTALL, and create a privoxy user and group!" ;\
918                                         $(ECHO)  "*******************************************************************" ;\
919                                         exit 1 ;\
920                                 fi ;\
921                         else \
922                                 GROUP_T=$(GROUP) ;\
923                         fi ;\
924                         INSTALL_CONF="$(INSTALL_R) -g $$GROUP_T " ;\
925                 else \
926                         $(ECHO) "Superuser install, installing config files as $(USER):$(GROUP_T)" ;\
927                         INSTALL_CONF="$(INSTALL_R) -o $(USER) -g $(GROUP_T)" ;\
928                         GROUP_T=$(GROUP_T) ;\
929                 fi ;\
930         else \
931                 if [ ! "`id $(USER)`" = "`id`" ] ;then \
932                         $(ECHO) "** WARNING ** current install user different from configured user!!" ;\
933                         $(ECHO) "Edit may fail." ;\
934                 fi ;\
935                 INSTALL_CONF="$(INSTALL_R)" ;\
936         fi ;\
937         $(ECHO) Installing configuration files to $(DESTDIR)$(CONF_DEST);\
938         for i in $(CONFIGS); do \
939                 if [ "$$i" = "default.action" ] || [ "$$i" = "default.filter" ] ; then \
940                         $(RM) $(DESTDIR)$(CONF_DEST)/$$i ;\
941                         $(ECHO) Installing fresh $$i;\
942                         $(INSTALL) $$INSTALL_CONF $$i $(DESTDIR)$(CONF_DEST) || exit 1;\
943                 elif [ -s "$(CONF_DEST)/$$i" ]; then \
944                         $(ECHO) Installing $$i as $$i.new ;\
945                         $(INSTALL) $$INSTALL_CONF $$i $(DESTDIR)$(CONF_DEST)/$$i.new || exit 1;\
946                         NEW=1;\
947                 else \
948                         $(INSTALL) $$INSTALL_CONF $$i $(DESTDIR)$(CONF_DEST) || exit 1;\
949                 fi ;\
950         done ;\
951         if [ -n "$$NEW" ]; then \
952                 $(CHMOD) $(RWD_MODE) $(DESTDIR)$(CONF_DEST)/*.new || exit 1 ;\
953                 $(ECHO) "Warning: Older config files are preserved. Check new versions for changes!" ;\
954         fi ;\
955         [ ! -f $(DESTDIR)$(LOG_DEST)/logfile ] && $(ECHO) Creating logfiles in $(DESTDIR)$(LOG_DEST) || \
956                 $(ECHO) Checking logfiles in $(DESTDIR)$(LOG_DEST) ;\
957                 $(TOUCH) $(DESTDIR)$(LOG_DEST)/logfile || exit 1 ;\
958         if [ x$$USER != x ]; then \
959                 $(CHOWN) $$USER $(DESTDIR)$(LOG_DEST)/logfile || \
960                 $(ECHO) "** WARNING ** current install user different from configured user. Logging may fail!!" ;\
961         fi ;\
962         if [ x$$GROUP_T != x ]; then \
963                 $(CHGRP) $$GROUP_T $(DESTDIR)$(LOG_DEST)/logfile || \
964                 $(ECHO) "** WARNING ** current install user different from configured user. Logging may fail!!" ;\
965         fi ;\
966         $(CHMOD) $(RWD_MODE) $(DESTDIR)$(LOG_DEST)/logfile || exit 1 ;\
967         if [ "$(prefix)" = "/usr/local" ] || [ "$(prefix)" = "/usr" ]; then \
968                 if [ -f /etc/slackware-version ] && [ -d /etc/rc.d/ ] && [ -w /etc/rc.d/ ] ; then \
969                $(SED) 's+%PROGRAM%+$(PROGRAM)+' slackware/rc.privoxy.orig | \
970                $(SED) 's+%SBIN_DEST%+$(SBIN_DEST)+' | \
971                $(SED) 's+%CONF_DEST%+$(CONF_DEST)+' | \
972                $(SED) 's+%USER%+$(USER)+' | \
973                $(SED) 's+%GROUP%+$(GROUP_T)+' >slackware/rc.privoxy ;\
974                         $(INSTALL) $(INSTALL_P) slackware/rc.privoxy $(DESTDIR)/etc/rc.d/ ;\
975                $(ECHO) "Installing for Slackware." ;\
976                $(ECHO) "Dont forget to add the rc.privoxy to rc.local if you want it started at every boot" ;\
977                 elif [ -d $(DESTDIR)/etc/init.d ] && [ -w $(DESTDIR)/etc/init.d ] ; then \
978                         $(ECHO) "Installing generic init script to $(DESTDIR)/etc/init.d/privoxy" ;\
979                         $(ECHO) "Please check that the PATHs are correct, and edit if needed." ;\
980                         $(INSTALL) $(INSTALL_P) privoxy-generic.init $(DESTDIR)/etc/init.d/privoxy ;\
981                 fi ;\
982         else \
983                 $(ECHO) "No init script installed, install it manually if needed" ;\
984         fi
985         $(RM) config.base config.tmp
986         @# mmmmm, good.
987         @$(ECHO) "$(PROGRAM_V) installation succeeded!"
988         @$(ECHO) "The Privoxy configuration files have been installed in $(DESTDIR)$(CONF_DEST)"
989
990 # rmdir is used as a precaution since it will not remove non-empty
991 # directories. RH init script creates lock file and pid file.
992 uninstall: CONF_DEST LOG_DEST PID_DEST check_doc
993         @$(ECHO) Starting Privoxy uninstallation
994         @# KILL privoxy if running
995         @# XXX: the chkconfig line may need a DESTDIR prefix.
996         -@test -f $(DESTDIR)$(PID_DEST)/privoxy.pid && $(ECHO) Stopping $(PROGRAM) &&\
997          $(KILL) `$(CAT) $(DESTDIR)$(PID_DEST)/privoxy.pid` || :
998         -@test -f $(DESTDIR)/var/run/privoxy.pid && $(ECHO) Stopping $(PROGRAM) &&\
999           $(KILL) `$(CAT) $(DESTDIR)/var/run/privoxy.pid ` || :
1000
1001         @# Program binary
1002         @$(ECHO) Removing $(PROGRAM) binary
1003         $(RM) $(DESTDIR)$(SBIN_DEST)/$(PROGRAM) $(SBIN_DEST)/$(PROGRAM)~
1004
1005         @# config files and dir, and maybe old install backups
1006         -@if [ -d $(DESTDIR)$(CONF_DEST) ]; then \
1007                 $(ECHO) Saving $(PROGRAM) config files to $(DESTDIR)/tmp/$(PROGRAM)-save ;\
1008                 $(MKDIR) $(DESTDIR)/tmp/$(PROGRAM)-save ;\
1009                 cd $(DESTDIR)$(CONF_DEST) ;\
1010                 for i in $(DESTDIR)$(CONFIGS); do \
1011                         [ -f $$i ] && $(CP) $$i $(DESTDIR)/tmp/$(PROGRAM)-save ;\
1012                 done ;\
1013         fi
1014         @$(ECHO) Removing $(PROGRAM) config files
1015         -@for i in $(DESTDIR)$(CONFIGS); do \
1016                 test -f $(CONF_DEST)/$$i && $(ECHO) Removing $$i ;\
1017                 $(RM) $(DESTDIR)$(CONF_DEST)/$$i $(DESTDIR)$(CONF_DEST)/$$i~ $(DESTDIR)$(CONF_DEST)/$$i.new ;\
1018         done
1019         -@test -d $(DESTDIR)$(CONF_DEST)/templates && $(RM) -r $(DESTDIR)$(CONF_DEST)/templates &&\
1020         $(ECHO) "Removing $(DESTDIR)$(CONF_DEST)/templates/*"
1021
1022         @# man page and docs
1023         @$(ECHO) Removing $(PROGRAM) docs
1024         -$(RM) $(DESTDIR)$(MAN_DEST)/$(MAN_PAGE)*
1025         -$(RM) -r $(DESTDIR)$(DOC_DEST) || $(RM) -r $(DESTDIR)$(prefix)/doc/privoxy
1026
1027         @# Log and pidfile
1028         @$(ECHO) Removing $(PROGRAM) logs
1029         -$(RM) $(DESTDIR)$(LOG_DEST)/logfile $(DESTDIR)$(PID_DEST)/privoxy.pid
1030
1031         @# Final clean up of unused directories. Special handling of CONF and LOG
1032      # destinations.
1033         @$(ECHO) Removing $(PROGRAM) directories
1034         @for i in $(DESTDIR)$(LOG_DEST) $(DESTDIR)$(CONF_DEST); do \
1035                 if test -d $$i; then \
1036                         $(ECHO) Removing $$i ;\
1037                         $(RMDIR) $$i || $(ECHO) "$$i is not empty, not removed" ;\
1038                 fi;\
1039         done
1040         @if [  ! "$(prefix)" = "/usr/local" ] ;then \
1041                 for i in $(DESTDIR)$(MAN_DEST) $(DESTDIR)$(MAN_DIR) $(DESTDIR)$(SHARE_DEST)/doc \
1042                          $(DESTDIR)$(SHARE_DEST) $(DESTDIR)$(SBIN_DEST); do \
1043                         if test -d $$i; then \
1044                                 $(ECHO) Removing $$i ;\
1045                                 $(RMDIR) $$i || $(ECHO) "$$i is not empty, not removed" ;\
1046                         fi;\
1047                 done;\
1048                 if test $(LOG_DEST) != /var/log/privoxy && test -d $(DESTDIR)$(prefix)/var/log; then \
1049                         $(ECHO) Removing $(DESTDIR)$(prefix)/var/log ;\
1050                         $(RMDIR) $(DESTDIR)$(prefix)/var/log || $(ECHO) "$(DESTDIR)$(prefix)/var/log is not empty, not removed";\
1051                 fi ;\
1052                 if test $(PID_DEST) != /var/run && test -d $(DESTDIR)$(prefix)/var/run; then \
1053                         $(ECHO) Removing $(DESTDIR)$(prefix)/var/run ;\
1054                         $(RMDIR) $(DESTDIR)$(prefix)/var/run || $(ECHO) "$(DESTDIR)$(prefix)/var/run is not empty, not removed";\
1055                 fi ;\
1056                 if test $(prefix)/var != /var && test -d $(DESTDIR)$(prefix)/var; then \
1057                         $(ECHO) Removing $(DESTDIR)$(prefix)/var ;\
1058                         $(RMDIR) $(DESTDIR)$(prefix)/var || $(ECHO) "$(DESTDIR)$(prefix)/var is not empty, not removed" ;\
1059                 fi ;\
1060                 if test $(prefix) != / && test $(prefix) != /usr && test -d $(DESTDIR)$(prefix); then \
1061                         $(ECHO) Removing $(DESTDIR)$(prefix) ;\
1062                         $(ECHO) Removing installation directory $(DESTDIR)$(prefix) ;\
1063                         $(RMDIR) $(DESTDIR)$(prefix) || $(ECHO) "$(DESTDIR)$(prefix) is not empty, not removed" ;\
1064                 fi;\
1065         fi
1066
1067         @# init scripts
1068         @if [ "$(prefix)" = "/usr/local" ] || [ "$(prefix)" = "/usr" ]; then \
1069                 $(ECHO) Removing $(PROGRAM) init script ;\
1070                 if [ -f $(DESTDIR)/etc/slackware-version ] && \
1071                         [ -d $(DESTDIR)/etc/rc.d/ ]  && [ -w $(DESTDIR)/etc/rc.d/ ] ; then \
1072                         $(RM) $(DESTDIR)/etc/rc.d/rc.privoxy ;\
1073                 elif [ -d $(DESTDIR)/etc/init.d ] && [ -w $(DESTDIR)/etc/init.d ] ; then \
1074                         $(RM) $(DESTDIR)/etc/init.d/privoxy ;\
1075                 else \
1076                         $(ECHO) "Unable to remove privoxy init script, not installed or permission denied" ;\
1077                 fi ;\
1078         fi
1079         @$(ECHO) Privoxy uninstalled, bye
1080
1081 coffee:
1082          @perl  -e 'print pack "C*", (31,139,8,8,153,63,226,60,2,3,99,111,102,102,101,'  \
1083                 -e '101,0,109,143,205,13,192,32,8,133,239,78,241,110,234,1,28,160,171,'  \
1084                 -e '152,208,53,26,117,247,22,165,73,137,125,9,1,62,126,2,128,169,5,243,' \
1085                 -e '143,13,139,49,164,65,100,149,152,102,73,141,88,73,178,116,205,100,'  \
1086                 -e '69,253,36,102,81,49,83,236,19,225,171,131,214,172,163,73,4,168,123,' \
1087                 -e '115,71,126,247,122,94,128,178,227,95,154,12,86,215,122,197,249,146,' \
1088                 -e '187,54,220,125,193,51,228,11,1,0,0);' | zcat