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