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