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