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