Imported Upstream version 3.2.0
[debian/amanda] / packaging / deb / rules
1 #!/usr/bin/make -f
2 # debian/rules for amanda using debhelper. GNU copyright 2008 by Dan Locks, 
3 # based on work by Bdale Garbee.
4
5 #       Warning - do *not* use -j on an SMP machine, or the build gets
6 #               confused... some sort of race condition in the makefiles?
7
8 # Uncomment this to turn on verbose mode.
9 #export DH_VERBOSE=1
10 AMVER=3.2alpha
11
12 # These are variables that the user can override.  They get used in various
13 # places during configure, build, and install.
14 PREFIX=/usr
15 BINDIR=$(PREFIX)/bin
16 LIBDIR=$(PREFIX)/lib
17 AMLIBDIR=$(LIBDIR)/amanda
18 LIBEXECDIR=$(PREFIX)/libexec
19 AMLIBEXECDIR=$(LIBEXECDIR)/amanda
20 MANDIR=$(PREFIX)/share/man
21 DOCDIR=$(PREFIX)/share/doc
22 SYSCONFDIR=/etc
23 LOCALSTATEDIR=/var
24 AMANDAHOMEDIR=$(LOCALSTATEDIR)/lib/amanda
25 LOGDIR=$(LOCALSTATEDIR)/log/amanda
26 # Extract the perl site_lib directory.  This is used to install amanda's perl 
27 # libs. If configure finds a different install or you specify a different path using
28 # --with-amperldir= make sure you change this variable as well.
29 PERLSITELIB=$(shell perl -V:installsitelib|sed -e"s:installsitelib='/::;s:'\;::")
30 AMANDAUSER=amandabackup
31 AMANDAGROUP=disk
32 WITHOUT_SERVER="False"
33 WITHOUT_CLIENT="False"
34
35 r=$(shell pwd)/debian/tmp
36 server=$(shell pwd)/debian/amanda-backup-server
37 client=$(shell pwd)/debian/amanda-backup-client
38
39 log=$(shell pwd)/debian/dpkg.log
40
41 # These are used for cross-compiling and for saving the configure script
42 # from having to guess our platform (since we know it already)
43 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
44 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
45
46 WD=$(shell pwd)
47
48 build: build-stamp 
49 build-stamp: /sbin/dump /usr/bin/smbclient 
50         dh_testdir
51         ./configure \
52                 MAKEFLAGS="-j1 " \
53                 CFLAGS="-pipe " \
54                 MAILER=/usr/bin/mail \
55                 --quiet \
56                 --host=$(DEB_HOST_GNU_TYPE) \
57                 --build=$(DEB_BUILD_GNU_TYPE) \
58                 --prefix=$(PREFIX) \
59                 --bindir=$(BINDIR) \
60                 --mandir=$(MANDIR) \
61                 --libexecdir=$(LIBEXECDIR) \
62                 --enable-shared \
63                 --sysconfdir=$(SYSCONFDIR) \
64                 --localstatedir=$(LOCALSTATEDIR) \
65                 --with-amdatadir=$(AMANDAHOMEDIR) \
66                 --with-gnutar-listdir=$(AMANDAHOMEDIR)/gnutar-lists \
67                 --with-index-server=localhost \
68                 --with-tape-server=localhost \
69                 --with-user=$(AMANDAUSER) \
70                 --with-group=$(AMANDAGROUP) \
71                 --with-fqdn \
72                 --with-bsd-security \
73                 --with-bsdtcp-security \
74                 --with-bsdudp-security \
75                 --with-amandahosts \
76                 --with-smbclient=$(BINDIR)/smbclient \
77                 --with-debugging=$(LOGDIR) \
78                 --with-ssh-security \
79                 --with-assertions \
80                 --enable-s3-device \
81                 --disable-installperms
82         touch missing
83         # There's probably a better way to do this.  Preinst and postrm are the
84         # same for client and server, but we leave room for differences by just
85         # appending here.
86         cat $(WD)/debian/preinst >> $(WD)/debian/amanda-backup-client.preinst
87         cat $(WD)/debian/preinst >> $(WD)/debian/amanda-backup-server.preinst
88         cat $(WD)/debian/postrm >> $(WD)/debian/amanda-backup-client.postrm
89         cat $(WD)/debian/postrm >> $(WD)/debian/amanda-backup-server.postrm
90         make -s LIBTOOLFLAGS=--silent
91         touch build-stamp
92
93 clean:
94         dh_testdir >> $(log) 2>&1
95         dh_testroot >> $(log) 2>&1
96         -make -s LIBTOOLFLAGS=--silent clean
97         -make -s LIBTOOLFLAGS=--silent distclean
98         -rm -f build-stamp missing config/config.h common-src/genversion
99         -find . -type d -name .deps -exec rm -rf {} \;
100         -test -r /usr/share/misc/config.sub && \
101                 cp -f /usr/share/misc/config.sub config/config.sub
102         -test -r /usr/share/misc/config.guess && \
103                 cp -f /usr/share/misc/config.guess config/config.guess
104         dh_clean >> $(log) 2>&1
105
106 # Build architecture-dependent files here.
107 binary-arch: build
108         echo "---->dh_testdir: " >> $(log)
109         dh_testdir >> $(log) 2>&1
110         echo "---->dh_testroot: " >> $(log)
111         dh_testroot >> $(log) 2>&1
112         echo "---->dh_clean: " >> $(log)
113         dh_clean -k >> $(log) 2>&1
114         echo "---->dh_installdirs: " >> $(log)
115         dh_installdirs -v >> $(log) 2>&1
116         make -s LIBTOOLFLAGS=--silent install DESTDIR=$(r)
117         echo "---->dh_installdocs: " >> $(log)
118         dh_installdocs -v >> $(log) 2>&1
119         install -d $(r)/$(DOCDIR)/amanda-common/examples
120         cp -a example/* $(r)/$(DOCDIR)/amanda-common/examples
121         cp ChangeLog $(r)/$(DOCDIR)/amanda-common/changelog
122         echo "---->dh_installchangelogs: " >> $(log)
123         dh_installchangelogs -v >> $(log) 2>&1
124         # Here's how we get the perl modules installed into sitelib
125         echo $(PERLSITELIB)/* >> debian/amanda-backup-server.install
126         echo "---->dh_install -v --fail-missing: " >> $(log)
127         dh_install -v --sourcedir=$(r) >> $(log) 2>&1
128         echo "---->dh_strip: " >> $(log)
129         dh_strip >> $(log) 2>&1
130         echo "---->dh_compress: " >> $(log)
131         dh_compress >> $(log) 2>&1
132         echo "---->dh_fixperms: " >> $(log)
133         dh_fixperms -v >> $(log) 2>&1
134         # fix perms manually
135         chown -R $(AMANDAUSER):$(AMANDAGROUP) debian/*/var/lib/*
136         #chmod -R u=rwX,g=rwX,o-rwx debian/*/var/lib/*
137         chown -R $(AMANDAUSER):$(AMANDAGROUP) $(client)/$(LOGDIR) $(server)/$(LOGDIR)
138         #chmod -R u=rwX,g=rwX,o-rwx $(server)/$(LOGDIR)
139         chown -R $(AMANDAUSER):$(AMANDAGROUP)  $(client)/$(SYSCONFDIR)/amanda $(server)/$(SYSCONFDIR)/amanda
140         chmod -R u=rwX,g=rwX,o-rwx $(client)/$(SYSCONFDIR)/amanda
141         chmod -R u=rwX,g=rwX,o-rwx $(server)/$(SYSCONFDIR)/amanda
142         chown -R $(AMANDAUSER):$(AMANDAGROUP) $(client)/$(AMANDAHOMEDIR)/gnutar-lists $(server)/$(AMANDAHOMEDIR)/gnutar-lists
143         chmod -R u=rwX,g=rwX,o-rwx  $(client)/$(AMANDAHOMEDIR)/gnutar-lists $(server)/$(AMANDAHOMEDIR)/gnutar-lists
144         # .. setuid
145         chown root:disk \
146                 $(client)/$(AMLIBEXECDIR)/application/amgtar \
147                 $(client)/$(AMLIBEXECDIR)/application/amstar \
148                 $(client)/$(AMLIBEXECDIR)/killpgrp \
149                 $(client)/$(AMLIBEXECDIR)/rundump \
150                 $(client)/$(AMLIBEXECDIR)/runtar \
151                 $(client)/$(AMLIBEXECDIR)/calcsize \
152                 $(server)/$(AMLIBEXECDIR)/application/amgtar \
153                 $(server)/$(AMLIBEXECDIR)/application/amstar \
154                 $(server)/$(AMLIBEXECDIR)/killpgrp \
155                 $(server)/$(AMLIBEXECDIR)/rundump \
156                 $(server)/$(AMLIBEXECDIR)/runtar \
157                 $(server)/$(AMLIBEXECDIR)/calcsize \
158                 $(server)/$(AMLIBEXECDIR)/dumper \
159                 $(server)/$(AMLIBEXECDIR)/planner \
160                 $(server)/usr/sbin/amcheck
161         chmod u=srwx,g=rx,o=r \
162                 $(client)/$(AMLIBEXECDIR)/application/amgtar \
163                 $(client)/$(AMLIBEXECDIR)/application/amstar \
164                 $(client)$(AMLIBEXECDIR)/killpgrp \
165                 $(client)$(AMLIBEXECDIR)/rundump \
166                 $(client)$(AMLIBEXECDIR)/runtar \
167                 $(client)$(AMLIBEXECDIR)/calcsize \
168                 $(server)/$(AMLIBEXECDIR)/application/amgtar \
169                 $(server)/$(AMLIBEXECDIR)/application/amstar \
170                 $(server)$(AMLIBEXECDIR)/killpgrp \
171                 $(server)$(AMLIBEXECDIR)/rundump \
172                 $(server)$(AMLIBEXECDIR)/runtar \
173                 $(server)$(AMLIBEXECDIR)/calcsize \
174                 $(server)$(AMLIBEXECDIR)/dumper \
175                 $(server)$(AMLIBEXECDIR)/planner \
176                 $(server)/usr/sbin/amcheck
177         echo "Amanda version $(AMVER)" >  $(server)/$(AMANDAHOMEDIR)/amanda-release 
178         echo "Amanda version $(AMVER)" >  $(client)/$(AMANDAHOMEDIR)/amanda-release 
179         install -o root -g root -m 0644 debian/amanda-backup-client.lintian \
180                 $(client)/usr/share/lintian/overrides/amanda-backup-client
181         install -o root -g root -m 0644 debian/amanda-backup-server.lintian \
182                 $(server)/usr/share/lintian/overrides/amanda-backup-server
183         dh_makeshlibs  >> $(log) 2>&1
184         dh_perl >> $(log) 2>&1
185         dh_shlibdeps -l"$(r)/usr/lib:$(client)/usr/lib:$(server)/usr/lib" >> $(log) 2>&1
186         dh_installdeb >> $(log) 2>&1
187         dh_gencontrol >> $(log) 2>&1
188         dh_md5sums  >> $(log) 2>&1
189         dh_builddeb  >> $(log) 2>&1
190
191 source diff:                                                                  
192         @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
193
194 binary: binary-arch
195 .PHONY: build clean binary-arch binary