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