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