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