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