Add OpenAFS-debug.*.plist to .gitignore
[openafs.git] / src / packaging / Debian / rules.in
1 #!/usr/bin/make -f
2 # Based on the sample debian/rules that uses debhelper. 
3 # GNU copyright 1997 by Joey Hess.
4
5 # Use quilt to manage patches.
6 include /usr/share/quilt/quilt.make
7
8 # Uncomment this to turn on verbose mode. 
9 #export DH_VERBOSE=1
10
11 # This has to be exported to make some magic below work.
12 export DH_OPTIONS
13
14 # Tell Autoconf the correct system types.
15 DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
16 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
17 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
18     SYSTEM = --build $(DEB_HOST_GNU_TYPE)
19 else
20     SYSTEM = --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
21 endif
22
23 # Determine whether we're building with optimization.  This doesn't really
24 # work at the moment due to upstream problems.
25 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
26     DEBIAN_OPT_FLAGS = --disable-optimize --disable-lwp-optimize
27     DEBIAN_KERN_FLAGS = --disable-kernel-optimize
28 else
29     DEBIAN_OPT_FLAGS =
30     DEBIAN_KERN_FLAGS =
31 endif
32
33 SYS_NAME  := $(shell sh debian/sysname)
34
35 package    = openafs
36 srcpkg     = openafs-modules-source
37
38 # These packages have lintian overrides.
39 LINTIAN_PACKAGES = openafs-dbserver openafs-client openafs-fileserver
40
41 # The /usr/share/doc directory for these packages should be a symlink to
42 # /usr/share/doc/openafs-client.  Any package on this list must depend on
43 # openafs-client.
44 DOC_PACKAGES = libpam-openafs-kaserver openafs-dbserver openafs-fileserver \
45         openafs-kpasswd
46
47 # These variable is used only by get-orig-source, which will normally only be
48 # run by maintainers.
49 VERSION   = @VERSION@
50 DEBVERS   = @VERSION@.dfsg1
51 UPSTREAM  = /afs/grand.central.org/software/openafs/$(VERSION)
52
53 # Download the upstream source, merge in the doc tarball, and do the
54 # repackaging that we have to do for DFSG reasons.  This assumes AFS is
55 # mounted, as it's generally only used by the package maintainers.
56 get-orig-source:
57         cp $(UPSTREAM)/openafs-$(VERSION)-src.tar.bz2 .
58         tar xjf openafs-$(VERSION)-src.tar.bz2
59         rm openafs-$(VERSION)-src.tar.bz2
60         cp $(UPSTREAM)/openafs-$(VERSION)-doc.tar.bz2 .
61         tar xjf openafs-$(VERSION)-doc.tar.bz2
62         rm openafs-$(VERSION)-doc.tar.bz2
63         rm -r openafs-$(VERSION)/src/packaging/MacOS
64         rm -r openafs-$(VERSION)/src/platform/DARWIN
65         rm -r openafs-$(VERSION)/src/WINNT
66         rm openafs-$(VERSION)/src/afs/sysctl.h
67         rm openafs-$(VERSION)/src/util/fstab.c
68         mv openafs-$(VERSION) openafs_$(DEBVERS).orig
69         tar cf openafs_$(DEBVERS).orig.tar openafs_$(DEBVERS).orig
70         rm -r openafs_$(DEBVERS).orig
71         gzip -9 openafs_$(DEBVERS).orig.tar
72
73 configure: configure-stamp
74 configure-stamp: patch
75         @if test x"$(SYS_NAME)" = x"UNKNOWN" ; then exit 1 ; fi
76         dh_testdir
77         sh regen.sh
78         afslogsdir=/var/log/openafs afslocaldir=/var/lib/openafs/local \
79             sh configure \
80             --with-afs-sysname=$(SYS_NAME) --disable-kernel-module \
81             --prefix=/usr --mandir=\$${prefix}/share/man \
82             --sysconfdir=/etc --libexecdir=/usr/lib \
83             --localstatedir=/var/lib --with-krb5-conf=/usr/bin/krb5-config \
84             --enable-supergroups --enable-largefile-fileserver \
85             --enable-bos-new-config \
86             --enable-debug --enable-lwp-debug \
87             $(DEBIAN_OPT_FLAGS) $(SYSTEM)
88         chmod a+x src/libafs/make_kbuild_makefile.pl         
89         touch configure-stamp
90
91 build: build-arch build-indep
92 build-arch: configure-stamp build-stamp
93 build-indep:
94 build-stamp:
95         dh_testdir
96         mkdir -p $(CURDIR)/debian/tmp
97         $(MAKE) install_nolibafs DESTDIR=$(CURDIR)/debian/tmp
98         chmod +x debian/afs-rootvol debian/afs-newcell
99         touch build-stamp
100
101 clean: unpatch
102         dh_testdir
103         dh_testroot
104         rm -f build-stamp configure-stamp install-stamp
105         [ ! -f Makefile ] || $(MAKE) distclean
106         dh_clean
107
108 install: install-stamp
109 install-stamp: DH_OPTIONS=
110 install-stamp: build-stamp
111         dh_testdir
112         dh_testroot
113         dh_installdirs
114         dh_install
115
116         set -e; for pkg in $(LINTIAN_PACKAGES) ; do \
117             install -d debian/$$pkg/usr/share/lintian/overrides; \
118             install -m 644 -c debian/$$pkg.lintian \
119                 debian/$$pkg/usr/share/lintian/overrides/$$pkg; \
120         done
121         set -e; for pkg in $(DOC_PACKAGES) ; do \
122             ln -s openafs-client debian/$$pkg/usr/share/doc/$$pkg; \
123         done
124
125         mv debian/openafs-client/usr/bin/pagsh \
126             debian/openafs-client/usr/bin/pagsh.openafs
127         mv debian/openafs-client/usr/share/man/man1/pagsh.1 \
128             debian/openafs-client/usr/share/man/man1/pagsh.openafs.1
129         mv debian/openafs-client/usr/bin/up \
130             debian/openafs-client/usr/bin/afs-up
131         mv debian/openafs-client/usr/share/man/man1/up.1 \
132             debian/openafs-client/usr/share/man/man1/afs-up.1
133
134         install -m 644 -c debian/tmp/usr/lib/pam_afs.so.1 \
135             debian/libpam-openafs-kaserver/lib/security/pam_afs.so
136         install -m 644 -c debian/tmp/usr/lib/pam_afs.krb.so.1 \
137             debian/libpam-openafs-kaserver/lib/security/pam_afs.krb.so
138
139         install -d debian/openafs-dbserver/usr/share/man/man8
140         ( cd debian && pod2man --section 8 --center "Debian GNU/Linux" \
141             afs-rootvol ) \
142             >debian/openafs-dbserver/usr/share/man/man8/afs-rootvol.8
143         ( cd debian && pod2man --section 8 --center "Debian GNU/Linux" \
144             afs-newcell ) \
145             >debian/openafs-dbserver/usr/share/man/man8/afs-newcell.8
146
147         touch install-stamp
148
149 # Rules for building the openafs-modules-source package.
150 binary-source:
151         dh_testdir
152         dh_testroot
153         -rm -rf debian/$(srcpkg) debian/substvars
154         install -d debian/$(srcpkg)/usr/src/modules/$(package)
155         find . \( -name \*.o -o -path ./debian -o -path \*/.svn \
156             -o -path ./src/WINNT -o -path ./doc -o -path ./obj \
157             -o -path ./$(SYS_NAME) -o -path ./.pc \) -prune -o -print | \
158                 cpio -admp debian/$(srcpkg)/usr/src/modules/$(package)
159         mkdir -p debian/$(srcpkg)/usr/src/modules/$(package)/debian
160         cp debian/changelog debian/copyright debian/module/* \
161             debian/$(srcpkg)/usr/src/modules/$(package)/debian/
162         chmod 755 debian/$(srcpkg)/usr/src/modules/$(package)/debian/rules
163         rm -f debian/$(srcpkg)/usr/src/modules/$(package)/*-stamp
164         cd debian/$(srcpkg)/usr/src/modules/$(package) && \
165             $(MAKE) distclean
166         -cd debian/$(srcpkg)/usr/src/modules/$(package) && \
167             rm -rf src/libafs/rx src/libafs/afs src/libafs/afsint
168         chown -R root.src debian/$(srcpkg)
169         find debian/$(srcpkg) -type d | xargs chmod 755
170         find debian/$(srcpkg) -type f -perm -100 | xargs chmod 755
171         find debian/$(srcpkg) -type f -not -perm -100 | xargs chmod 644
172         chmod 775 debian/$(srcpkg)/usr/src/modules
173         cd debian/$(srcpkg)/usr/src && \
174             tar cf $(package).tar modules && \
175             rm -r modules
176         gzip -9 debian/$(srcpkg)/usr/src/$(package).tar
177         chmod 644 debian/$(srcpkg)/usr/src/$(package).tar.gz
178
179 # Build architecture-independent files here.  Pass -i to all debhelper
180 # commands in this target to reduce clutter.
181 #
182 # Also install debian/openafs-client.NEWS in the openafs-modules-source
183 # package.
184 binary-indep: DH_OPTIONS=-i
185 binary-indep: install-stamp binary-source
186         dh_testdir
187         dh_testroot
188         dh_installchangelogs NEWS
189         install -m 644 debian/openafs-client.NEWS \
190             debian/$(srcpkg)/usr/share/doc/$(srcpkg)/NEWS.Debian
191         dh_installdocs -XAdminReference -XQuickStartWindows -Xwinnotes
192         dh_installexamples
193         dh_link
194         dh_compress
195         dh_fixperms
196         dh_installdeb
197         dh_gencontrol
198         dh_md5sums
199         dh_builddeb
200
201 # Build architecture-dependent files here.  Pass -a to all debhelper commands
202 # in this target to reduce clutter.
203 #
204 # We would like to install debugging information for everything, but currently
205 # OpenAFS's makefiles strip all binaries when installed except for the
206 # fileserver and the volserver.  This is fixed in OpenAFS's development
207 # branch.  Until that's released, only retain debugging information for the
208 # fileserver and the volserver.
209 binary-arch: DH_OPTIONS=-a
210 binary-arch: install-stamp
211         dh_testdir
212         dh_testroot
213         dh_installchangelogs NEWS
214         dh_installdocs
215         dh_installdebconf
216         DH_OPTIONS= dh_installinit -popenafs-client -r -- defaults 25 18
217         DH_OPTIONS= dh_installinit -popenafs-fileserver -r
218         dh_link
219         dh_strip --dbg-package=openafs-dbg
220         dh_compress
221         dh_fixperms
222         chmod 700 debian/openafs-client/var/cache/openafs
223         chmod 700 debian/openafs-dbserver/var/lib/openafs/db
224         chmod 700 debian/openafs-fileserver/etc/openafs/server
225         dh_perl
226         dh_installdeb
227         dh_shlibdeps
228         dh_gencontrol
229         dh_md5sums
230         dh_builddeb
231
232 binary: binary-indep binary-arch
233
234 .PHONY: binary binary-arch binary-indep binary-source build build-arch
235 .PHONY: build-indep clean configure install