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