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