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