* Build HTML, text, and PDF versions of the documentation from source.
[privoxy.git] / debian / rules
1 #!/usr/bin/make -f
2 # Sample debian/rules that uses debhelper.
3 # GNU copyright 1997 to 1999 by Joey Hess.
4
5 # Uncomment this to turn on verbose mode.
6 #export DH_VERBOSE=1
7
8 # These are used for cross-compiling and for saving the configure script
9 # from having to guess our platform (since we know it already)
10 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
11 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
12
13 DEBDIR=`pwd`/debian/privoxy
14
15 OPTIMIZE=
16 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
17         OPTIMIZE=-O0
18 else
19         OPTIMIZE=-O2
20 endif
21
22 configure: configure-stamp
23 configure-stamp:
24         dh_testdir
25
26         autoheader
27         autoconf
28         env CFLAGS="$(OPTIMIZE) -g" \
29                 ./configure --prefix=/usr --sysconfdir=/etc \
30                 --mandir=/usr/share/man $(WITHDEBUG)
31
32         touch configure-stamp
33
34 build: build-stamp
35 build-stamp: configure-stamp 
36         dh_testdir
37
38         $(MAKE)
39
40 #       backup formatted upstream documentation:
41         for x in text webserver pdf; do \
42                 if [ ! -d doc/$$x.dist ]; then \
43                         cp -a doc/$$x doc/$$x.dist; \
44                 fi; \
45         done
46         for x in INSTALL README privoxy.1; do \
47                 if [ ! -f $$x.dist ]; then \
48                         cp -a $$x $$x.dist; \
49                 fi; \
50         done
51
52         (cd doc/source; $(MAKE) pdf)
53         (cd doc/source; $(MAKE) all)
54
55         touch build-stamp
56
57 clean:
58         dh_testdir
59         dh_testroot
60         rm -f build-stamp configure-stamp
61
62         -$(MAKE) clean
63         -$(MAKE) distclean
64         rm -f privoxy 
65         rm -f configure config.h GNUmakefile 
66         rm -f doc/source/ldp.dsl
67         rm -rf obj
68         rm -f ActivityConsole.jar
69         rm -f src/java/org/privoxy/activityconsole/*.class
70
71 #       restore formatted upstream documentation:
72         for x in text webserver pdf; do \
73                 if [ -d doc/$$x.dist ]; then \
74                         rm -rf doc/$$x; \
75                         mv doc/$$x.dist doc/$$x; \
76                 fi; \
77         done
78         for x in INSTALL README privoxy.1; do \
79                 if [ -f $$x.dist ]; then \
80                         rm -f $$x; \
81                         mv $$x.dist $$x; \
82                 fi; \
83         done
84
85         dh_clean
86
87 install: build
88         dh_testdir
89         dh_testroot
90         dh_clean -k
91         dh_installdirs
92
93         install -m 0755 privoxy $(DEBDIR)/usr/sbin/privoxy
94
95         sed -e 's/^\(\(trust\|proxy\)-info-url\|admin-address\)/#\1/'  \
96             -e 's/^\(enable-\(edit-actions\|remote-toggle\)\)[  ]*1/\1 0/' \
97             -e 's#^confdir .*#confdir /etc/privoxy#' \
98             -e 's#^logdir .*#logdir /var/log/privoxy#' \
99             -e 's%^#\(user-manual\).*%\1 /usr/share/doc/privoxy/user-manual%' \
100             -e 's/\(Sample Configuration File for Privoxy\).*/\1/' \
101             -e 's/Id: config,v.*/Id: config,v $$/' \
102                 < config > $(DEBDIR)/etc/privoxy/config
103         install -m 0644 default.action $(DEBDIR)/etc/privoxy/default.action
104         install -m 0644 standard.action $(DEBDIR)/etc/privoxy/standard.action
105         install -m 0644 user.action $(DEBDIR)/etc/privoxy/user.action
106         install -m 0644 default.filter $(DEBDIR)/etc/privoxy/default.filter
107         install -m 0644 trust $(DEBDIR)/etc/privoxy/trust
108
109         cp -r templates $(DEBDIR)/etc/privoxy/
110         rm -f $(DEBDIR)/etc/privoxy/templates/*~
111         rm -rf $(DEBDIR)/etc/privoxy/templates/CVS
112
113
114 # Build architecture-independent files here.
115 binary-indep: build install
116 # We have nothing to do by default.
117
118 # Build architecture-dependent files here.
119 binary-arch: build install
120         dh_testdir
121         dh_testroot
122 #       dh_installdebconf       
123         dh_installdocs -XCVS
124         (cd $(DEBDIR)/usr/share/doc/privoxy/; \
125          mv privoxy-index.html index.html)
126         dh_installexamples
127         dh_installmenu
128         dh_installlogrotate
129 #       dh_installemacsen
130 #       dh_installpam
131 #       dh_installmime
132         dh_installinit
133         dh_installcron
134         dh_installman
135         dh_installinfo
136 #       dh_undocumented
137         dh_installchangelogs ChangeLog
138         dh_link
139         dh_strip
140         dh_compress
141         dh_fixperms
142 #       dh_makeshlibs
143         dh_installdeb
144 #       dh_perl
145         dh_shlibdeps
146         dh_gencontrol
147         dh_md5sums
148         dh_builddeb
149
150 binary: binary-indep binary-arch
151 .PHONY: build clean binary-indep binary-arch binary install configure